|
|
|
@ -26,16 +26,40 @@ |
|
|
|
|
// See doc/COPYRIGHT.rdoc for more details.
|
|
|
|
|
// ++
|
|
|
|
|
|
|
|
|
|
angular |
|
|
|
|
.module('openproject.inplace-edit') |
|
|
|
|
.directive('inplaceEditorDisplayPane', inplaceEditorDisplayPane); |
|
|
|
|
function InplaceEditorDisplayPaneController($scope, HookService, I18n:op.I18n) { |
|
|
|
|
var field = $scope.field; |
|
|
|
|
|
|
|
|
|
this.getAriaLabel = function() { |
|
|
|
|
return I18n.t('js.work_packages.edit_attribute', { attribute: field.getKeyValue() }); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
this.placeholder = field.placeholder; |
|
|
|
|
|
|
|
|
|
this.startEditing = function() { |
|
|
|
|
if (!field.isEditable()) { |
|
|
|
|
throw 'Trying to edit the non editable field "' + field.name + '"'; |
|
|
|
|
} |
|
|
|
|
var fieldController = $scope.fieldController; |
|
|
|
|
fieldController.isEditing = true; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// for dynamic type that is set by plugins
|
|
|
|
|
// refactor to a service method the whole extraction
|
|
|
|
|
this.getDynamicDirectiveName = function() { |
|
|
|
|
return HookService.call('workPackageOverviewAttributes', { |
|
|
|
|
type: field.getSchema(field.resource).props[field.name].type, |
|
|
|
|
field: field.name, |
|
|
|
|
workPackage: field.resource |
|
|
|
|
})[0]; |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function inplaceEditorDisplayPane(EditableFieldsState, $timeout) { |
|
|
|
|
return { |
|
|
|
|
replace: true, |
|
|
|
|
transclude: true, |
|
|
|
|
require: '^workPackageField', |
|
|
|
|
templateUrl: '/components/inplace-edit/directives/display-pane/display-pane.directive.html', |
|
|
|
|
require: '^wpField', |
|
|
|
|
templateUrl: '/components/inplace-edit/display-pane/display-pane.directive.html', |
|
|
|
|
controller: InplaceEditorDisplayPaneController, |
|
|
|
|
controllerAs: 'displayPaneController', |
|
|
|
|
|
|
|
|
@ -50,7 +74,8 @@ function inplaceEditorDisplayPane(EditableFieldsState, $timeout) { |
|
|
|
|
|
|
|
|
|
if (strategy !== scope.displayStrategy) { |
|
|
|
|
scope.displayStrategy = strategy; |
|
|
|
|
scope.templateUrl = '/templates/inplace-edit/display/fields/' + strategy +'.html'; |
|
|
|
|
scope.templateUrl = |
|
|
|
|
'/components/inplace-edit/field-templates/display/' + strategy + '.html'; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
@ -78,34 +103,7 @@ function inplaceEditorDisplayPane(EditableFieldsState, $timeout) { |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
inplaceEditorDisplayPane.$inject = ['EditableFieldsState', '$timeout']; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function InplaceEditorDisplayPaneController($scope, HookService) { |
|
|
|
|
var field = $scope.field; |
|
|
|
|
|
|
|
|
|
this.getAriaLabel = function() { |
|
|
|
|
return I18n.t('js.work_packages.edit_attribute', { attribute: field.getKeyValue() }); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
this.placeholder = field.placeholder; |
|
|
|
|
|
|
|
|
|
this.startEditing = function() { |
|
|
|
|
if (!field.isEditable()) { |
|
|
|
|
throw 'Trying to edit the non editable field "' + field.name + '"'; |
|
|
|
|
} |
|
|
|
|
var fieldController = $scope.fieldController; |
|
|
|
|
fieldController.isEditing = true; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// for dynamic type that is set by plugins
|
|
|
|
|
// refactor to a service method the whole extraction
|
|
|
|
|
this.getDynamicDirectiveName = function() { |
|
|
|
|
return HookService.call('workPackageOverviewAttributes', { |
|
|
|
|
type: field.getSchema(field.resource).props[field.name].type, |
|
|
|
|
field: field.name, |
|
|
|
|
workPackage: field.resource |
|
|
|
|
})[0]; |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
InplaceEditorDisplayPaneController.$inject = ['$scope', 'HookService']; |
|
|
|
|
angular |
|
|
|
|
.module('openproject.inplace-edit') |
|
|
|
|
.directive('inplaceEditorDisplayPane', inplaceEditorDisplayPane); |