Add definingProject as group to version

pull/3780/head
Oliver Günther 9 years ago
parent 33aac52d88
commit 955c1194f2
  1. 2
      frontend/app/components/inplace-edit/directives/field-edit/edit-drop-down/edit-drop-down.directive.html
  2. 5
      frontend/app/components/inplace-edit/directives/field-edit/edit-drop-down/edit-drop-down.directive.js
  3. 4
      frontend/app/components/inplace-edit/services/work-package-field.service.js
  4. 6
      frontend/app/services/version-service.js
  5. 6
      frontend/app/work_packages/services/index.js
  6. 22
      frontend/app/work_packages/services/work-package-field-configuration-service.js

@ -10,6 +10,6 @@
title="{{ fieldController.editTitle }}"
class="inplace-edit-select form--select"
id="inplace-edit--write-value--{{::field.name}}"
ng-options="option as option.name for option in customEditorController.allowedValues track by option.hrefTracker">
ng-options="option.name group by customEditorController.optionGroup(option) for option in customEditorController.allowedValues track by option.hrefTracker">
</select>
</div>

@ -92,6 +92,11 @@ function InplaceEditorDropDownController($q, $scope, I18n, WorkPackageFieldConfi
});
};
this.optionGroup = function(option) {
return WorkPackageFieldConfigurationService
.getDropDownOptionGroup($scope.field.name, option);
};
var addEmptyOption = function(values) {
var emptyOption = { props: { href: null,
name: $scope.field.placeholder } };

@ -140,9 +140,9 @@ function WorkPackageFieldService($q, $http, $filter, I18n, WorkPackagesHelper,
function getEmbeddedAllowedValues(workPackage, field) {
var options = [];
var schema = getSchema(workPackage);
var allowedValues = schema.props[field]._links.allowedValues;
var allowedValues = schema.props[field]._embedded.allowedValues;
options = _.map(allowedValues, function(item) {
return _.extend({}, item, { name: item.title });
return _.extend({}, item, { name: item.name || item.title });
});
return options;

@ -30,6 +30,12 @@ module.exports = function($http, PathHelper) {
var VersionService = {
getDefininingProject: function(resource) {
if (resource._links && resource._links.definingProject) {
return resource._links.definingProject.title;
}
},
getVersions: function(projectIdentifier) {
var url;

@ -51,8 +51,10 @@ angular.module('openproject.workPackages.services')
attributes: []
}
])
.factory('WorkPackageFieldConfigurationService',
require('./work-package-field-configuration-service'))
.factory('WorkPackageFieldConfigurationService', [
'VersionService',
require('./work-package-field-configuration-service')
])
.service('WorkPackagesOverviewService', [
'WORK_PACKAGE_ATTRIBUTES',
require('./work-packages-overview-service')

@ -26,14 +26,19 @@
// See doc/COPYRIGHT.rdoc for more details.
//++
module.exports = function() {
module.exports = function(VersionService) {
function getDropdownSortingStrategy(field) {
var sorting;
switch(field) {
case 'version':
sorting = function(field) {
return field.title.toLowerCase();
sorting = function(option) {
var definingProject = VersionService.getDefininingProject(option) || '';
// This is a hack to work around limited lodash multi-attribute
// sorting and works fine for string-based sorting in our case.
// TODO Possibly refactor when v3 hits
return definingProject + '_' + option.name.toLowerCase();
};
break;
default:
@ -42,7 +47,16 @@ module.exports = function() {
return sorting;
}
function getDropDownOptionGroup(field, option) {
switch(field) {
case 'version':
return VersionService.getDefininingProject(option);
break;
}
}
return {
getDropdownSortingStrategy: getDropdownSortingStrategy
getDropdownSortingStrategy: getDropdownSortingStrategy,
getDropDownOptionGroup: getDropDownOptionGroup
};
};

Loading…
Cancel
Save