Remove forcedEditState flag

pull/3991/head
Alex Dik 9 years ago
parent 5b43900804
commit b49e851fac
  1. 6
      frontend/app/components/inplace-edit/directives/edit-pane/edit-pane.directive.js
  2. 4
      frontend/app/components/inplace-edit/directives/field-edit/edit-drop-down/edit-drop-down.directive.js
  3. 4
      frontend/app/components/inplace-edit/directives/work-package-field/work-package-field.directive.js
  4. 9
      frontend/app/components/inplace-edit/services/editable-fields-state.service.js
  5. 3
      frontend/app/components/routes/controllers/work-package-show.controller.js
  6. 10
      frontend/app/components/work-packages/directives/work-package-comment/work-package-comment.directive.js
  7. 3
      frontend/app/work_packages/controllers/details-tab-overview-controller.js

@ -59,9 +59,9 @@ function inplaceEditorEditPane($timeout, EditableFieldsState, FocusHelper, inpla
});
};
if (!EditableFieldsState.forcedEditState) {
if (!inplaceEditAll.state) {
element.bind('keydown keypress', function(e) {
if (e.keyCode === 27 && !inplaceEditAll.state) {
if (e.keyCode === 27) {
scope.$apply(function() {
scope.editPaneController.discardEditing();
});
@ -70,7 +70,7 @@ function inplaceEditorEditPane($timeout, EditableFieldsState, FocusHelper, inpla
}
scope.$watch('fieldController.isEditing', function(isEditing) {
if (isEditing && !inplaceEditAll.state && !EditableFieldsState.forcedEditState) {
if (isEditing && !inplaceEditAll.state) {
scope.focusInput();
} else if (inplaceEditAll.state && EditableFieldsState.isFocusField(field.name)) {

@ -52,8 +52,8 @@ function inplaceEditorDropDown(EditableFieldsState, FocusHelper, inplaceEditAll)
scope.customEditorController.updateAllowedValues(field.name).then(function() {
EditableFieldsState.isBusy = false;
if (!EditableFieldsState.forcedEditState) {
inplaceEditAll.state || FocusHelper.focusUiSelect(element);
if (!inplaceEditAll.state) {
FocusHelper.focusUiSelect(element);
}
});
}

@ -46,7 +46,7 @@ function workPackageField() {
};
}
function WorkPackageFieldController($scope, EditableFieldsState, inplaceEditForm) {
function WorkPackageFieldController($scope, EditableFieldsState, inplaceEditForm, inplaceEditAll) {
var workPackage = EditableFieldsState.workPackage;
this.state = EditableFieldsState;
$scope.field = inplaceEditForm.getForm(workPackage.props.id, workPackage).field(this.fieldName);
@ -55,7 +55,7 @@ function WorkPackageFieldController($scope, EditableFieldsState, inplaceEditForm
if (field.isEditable()) {
this.state.isBusy = false;
this.isEditing = this.state.forcedEditState;
this.isEditing = inplaceEditAll.state;
this.editTitle = I18n.t('js.inplace.button_edit', { attribute: field.getLabel() });
}
}

@ -38,24 +38,23 @@ function EditableFieldsState(inplaceEditErrors, inplaceEditAll) {
errors: inplaceEditErrors.errors,
isBusy: false,
currentField: null,
forcedEditState: false,
focusField: 'subject',
isFocusField: function (field) {
return this.focusField === field;
return EditableFieldsState.focusField === field;
},
isActiveField: function (field) {
return !(this.forcedEditState || inplaceEditAll.state) && this.currentField === field;
return !inplaceEditAll.state && EditableFieldsState.currentField === field;
},
getPendingFormChanges: function () {
var form = this.workPackage.form;
var form = EditableFieldsState.workPackage.form;
return form.pendingChanges = form.pendingChanges || angular.copy(form.embedded.payload.props);
},
discard: function (fieldName) {
delete this.getPendingFormChanges()[fieldName];
delete EditableFieldsState.getPendingFormChanges()[fieldName];
if (inplaceEditErrors.errors && inplaceEditErrors.hasOwnProperty(fieldName)) {
delete inplaceEditErrors.errors[fieldName];

@ -277,7 +277,6 @@ function WorkPackageShowController($scope, $rootScope, $state, latestTab, workPa
});
function activate() {
EditableFieldsState.forcedEditState = false;
$scope.$watch('workPackage.schema', function(schema) {
if (schema) {
WorkPackagesDisplayHelper.setFocus();
@ -286,7 +285,7 @@ function WorkPackageShowController($scope, $rootScope, $state, latestTab, workPa
});
vm.groupedFields = WorkPackagesOverviewService.getGroupedWorkPackageOverviewAttributes();
$scope.$watchCollection('vm.workPackage.form', function(form) {
$scope.$watchCollection('vm.workPackage.form', function() {
var schema = WorkPackageFieldService.getSchema(vm.workPackage);
var otherGroup = _.find(vm.groupedFields, {groupName: 'other'});
otherGroup.attributes = [];

@ -30,8 +30,8 @@ angular
.module('openproject.workPackages.directives')
.directive('workPackageComment', workPackageComment);
function workPackageComment($rootScope, $timeout, $location, EditableFieldsState, FocusHelper, I18n,
inplaceEditMultiStorage, ConfigurationService, AutoCompleteHelper, NotificationsService) {
function workPackageComment($timeout, $location, EditableFieldsState, FocusHelper,
inplaceEditMultiStorage, ConfigurationService, AutoCompleteHelper, inplaceEditAll) {
function commentFieldDirectiveController($scope, $element) {
var field = {},
@ -49,7 +49,7 @@ function workPackageComment($rootScope, $timeout, $location, EditableFieldsState
ctrl.placeholder = I18n.t('js.label_add_comment_title');
ctrl.state.isBusy = false;
ctrl.isEditing = ctrl.state.forcedEditState;
ctrl.isEditing = inplaceEditAll.state;
ctrl.isRequired = true;
ctrl.canAddComment = !!ctrl.workPackage.links.addComment;
@ -113,7 +113,7 @@ function workPackageComment($rootScope, $timeout, $location, EditableFieldsState
};
ctrl.isActive = function() {
if (EditableFieldsState.forcedEditState) {
if (inplaceEditAll.state) {
return false;
}
return ctrl.field === EditableFieldsState.currentField;
@ -124,7 +124,7 @@ function workPackageComment($rootScope, $timeout, $location, EditableFieldsState
EditableFieldsState.currentField = ctrl.field;
};
if (!EditableFieldsState.forcedEditState) {
if (!inplaceEditAll.state) {
$element.bind('keydown keypress', function(e) {
if (e.keyCode === 27) {
$scope.$apply(function() {

@ -33,10 +33,8 @@ module.exports = function(
EditableFieldsState,
WorkPackageDisplayHelper,
NotificationsService,
I18n,
WorkPackageAttachmentsService
) {
'use strict';
var vm = this;
vm.groupedFields = [];
@ -57,7 +55,6 @@ module.exports = function(
});
function activate() {
EditableFieldsState.forcedEditState = false;
$scope.$watch('workPackage.schema', function(schema) {
if (schema) {
WorkPackageDisplayHelper.setFocus();

Loading…
Cancel
Save