Fix listing of attributes on fullscreen WorkPackage page.

pull/3563/head
Tim Habermaas 9 years ago committed by Stefan Botzenhart
parent bc5df6e051
commit 4d19852d1c
  1. 1
      frontend/app/routing.js
  2. 4
      frontend/app/work_packages/controllers/index.js
  3. 56
      frontend/app/work_packages/controllers/work-package-show-controller.js

@ -72,6 +72,7 @@ angular.module('openproject')
url: '/{workPackageId:[0-9]+}?query_props', url: '/{workPackageId:[0-9]+}?query_props',
templateUrl: '/templates/work_packages.show.html', templateUrl: '/templates/work_packages.show.html',
controller: 'WorkPackageShowController', controller: 'WorkPackageShowController',
controllerAs: 'vm',
resolve: { resolve: {
workPackage: function(WorkPackageService, $stateParams) { workPackage: function(WorkPackageService, $stateParams) {
return WorkPackageService.getWorkPackage($stateParams.workPackageId); return WorkPackageService.getWorkPackage($stateParams.workPackageId);

@ -126,7 +126,11 @@ angular.module('openproject.workPackages.controllers')
'CommonRelationsHandler', 'CommonRelationsHandler',
'ChildrenRelationsHandler', 'ChildrenRelationsHandler',
'ParentRelationsHandler', 'ParentRelationsHandler',
'WorkPackagesOverviewService',
'WorkPackageFieldService',
'EditableFieldsState', 'EditableFieldsState',
'WorkPackagesDisplayHelper',
'NotificationsService',
require('./work-package-show-controller') require('./work-package-show-controller')
]) ])
.controller('WorkPackagesController', [ .controller('WorkPackagesController', [

@ -41,7 +41,12 @@ module.exports = function($scope,
WorkPackageService, WorkPackageService,
CommonRelationsHandler, CommonRelationsHandler,
ChildrenRelationsHandler, ChildrenRelationsHandler,
ParentRelationsHandler ParentRelationsHandler,
WorkPackagesOverviewService,
WorkPackageFieldService,
EditableFieldsState,
WorkPackagesDisplayHelper,
NotificationsService
) { ) {
$scope.$on('$stateChangeSuccess', function(event, toState){ $scope.$on('$stateChangeSuccess', function(event, toState){
latestTab.registerState(toState.name); latestTab.registerState(toState.name);
@ -203,4 +208,53 @@ module.exports = function($scope,
$state.current.url.replace(/\//, ''), $state.current.url.replace(/\//, ''),
$scope.workPackage $scope.workPackage
); );
// Stuff copied from DetailsTabOverviewController
var vm = this;
vm.groupedFields = [];
vm.hideEmptyFields = true;
vm.workPackage = $scope.workPackage;
vm.isGroupHideable = WorkPackagesDisplayHelper.isGroupHideable;
vm.isFieldHideable = WorkPackagesDisplayHelper.isFieldHideable;
vm.getLabel = WorkPackagesDisplayHelper.getLabel;
vm.isSpecified = WorkPackagesDisplayHelper.isSpecified;
vm.hasNiceStar = WorkPackagesDisplayHelper.hasNiceStar;
vm.showToggleButton = WorkPackagesDisplayHelper.showToggleButton;
activate();
function activate() {
EditableFieldsState.forcedEditState = false;
$scope.$watch('workPackage.schema', function(schema) {
if (schema) {
WorkPackagesDisplayHelper.setFocus();
vm.workPackage = $scope.workPackage;
}
});
vm.groupedFields = WorkPackagesOverviewService.getGroupedWorkPackageOverviewAttributes();
$scope.$watchCollection('vm.workPackage.form', function(form) {
var schema = WorkPackageFieldService.getSchema(vm.workPackage);
var otherGroup = _.find(vm.groupedFields, {groupName: 'other'});
otherGroup.attributes = [];
_.forEach(schema.props, function(prop, propName) {
if (propName.match(/^customField/)) {
otherGroup.attributes.push(propName);
}
});
otherGroup.attributes.sort(function(a, b) {
var getLabel = function(field) {
return vm.getLabel(vm.workPackage, field);
};
var left = getLabel(a).toLowerCase(),
right = getLabel(b).toLowerCase();
return left.localeCompare(right);
});
});
$scope.$on('workPackageUpdatedInEditor', function() {
NotificationsService.addSuccess(I18n.t('js.label_successful_update'));
});
}
}; };

Loading…
Cancel
Save