|
|
|
@ -26,37 +26,57 @@ |
|
|
|
|
// See doc/COPYRIGHT.rdoc for more details.
|
|
|
|
|
// ++
|
|
|
|
|
|
|
|
|
|
angular |
|
|
|
|
.module('openproject.workPackages.directives') |
|
|
|
|
.directive('wpGroupHeader', wpGroupHeader); |
|
|
|
|
import {wpDirectivesModule} from '../../../angular-modules'; |
|
|
|
|
|
|
|
|
|
function wpGroupHeader() { |
|
|
|
|
return { |
|
|
|
|
restrict: 'A', |
|
|
|
|
link: function(scope) { |
|
|
|
|
export class WorkPackageGroupHeaderController { |
|
|
|
|
constructor(public $scope, public I18n) { |
|
|
|
|
this.pushGroup(this.currentGroup); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
scope.currentGroup = scope.row.groupName; |
|
|
|
|
public get resource() { |
|
|
|
|
return this.$scope.resource; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
scope.currentGroupObject = _.find(scope.resource.groups, function(o) { |
|
|
|
|
var value = o.value == null ? '' : o.value; |
|
|
|
|
return value === scope.row.groupName; |
|
|
|
|
}); |
|
|
|
|
public get currentGroup() { |
|
|
|
|
return this.$scope.row.groupName; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (scope.currentGroupObject && scope.currentGroupObject.value === null) { |
|
|
|
|
scope.currentGroupObject.value = I18n.t('js.placeholders.default'); |
|
|
|
|
} |
|
|
|
|
public get currentGroupObject() { |
|
|
|
|
return this.$scope.groupHeaders[this.currentGroup]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Return the group name. As the internal value may be emtpy (''), |
|
|
|
|
* we return the default placeholder in that case. |
|
|
|
|
*/ |
|
|
|
|
public get currentGroupName() { |
|
|
|
|
const value = this.currentGroupObject.value; |
|
|
|
|
|
|
|
|
|
if (value === '') { |
|
|
|
|
return this.I18n.t('js.placeholders.default'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pushGroup(scope.currentGroup); |
|
|
|
|
return value; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
scope.toggleCurrentGroup = function() { |
|
|
|
|
scope.groupExpanded[scope.currentGroup] = !scope.groupExpanded[scope.currentGroup]; |
|
|
|
|
}; |
|
|
|
|
public toggleCurrentGroup() { |
|
|
|
|
this.$scope.groupExpanded[this.currentGroup] = !this.$scope.groupExpanded[this.currentGroup]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function pushGroup(group) { |
|
|
|
|
if (scope.groupExpanded[group] === undefined) { |
|
|
|
|
scope.groupExpanded[group] = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
public pushGroup(group) { |
|
|
|
|
if (this.$scope.groupExpanded[group] === undefined) { |
|
|
|
|
this.$scope.groupExpanded[group] = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function wpGroupHeader() { |
|
|
|
|
return { |
|
|
|
|
restrict: 'A', |
|
|
|
|
controller: WorkPackageGroupHeaderController, |
|
|
|
|
controllerAs: '$ctrl', |
|
|
|
|
bindToController: true, |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
wpDirectivesModule.directive('wpGroupHeader', wpGroupHeader); |