Refactor wpCreateButton directive

pull/4471/head
Alex Dik 9 years ago
parent 67313c8066
commit 7758e2328b
  1. 21
      frontend/app/components/wp-buttons/wp-create-button/wp-create-button.controller.ts
  2. 8
      frontend/app/components/wp-buttons/wp-create-button/wp-create-button.directive.html
  3. 2
      frontend/app/components/wp-buttons/wp-create-button/wp-create-button.directive.ts

@ -29,26 +29,25 @@
import {wpButtonsModule} from '../../../angular-modules';
export default class WorkPackageCreateButtonController {
public projectIdentifier: string;
public text: any;
public types: any;
public projectIdentifier:string;
public text:any;
public types:any;
public stateName:string;
public allowed;
public get inProjectContext() {
return !!this.projectIdentifier;
}
constructor(
protected $state,
protected I18n
) {
constructor(protected $state,
protected I18n) {
this.text = {
button: I18n.t('js.label_work_package'),
create: I18n.t('js.label_create_work_package')
};
}
public createWorkPackage() {
this.$state.go(this.stateName, {projectPath: this.projectIdentifier});
}
public isDisabled() {
return !this.allowed || this.$state.includes('**.new');
}

@ -1,10 +1,10 @@
<div class="wp-create-button">
<button class="button -alt-highlight add-work-package"
ui-sref="{{ vm.stateName }}({ projectPath: vm.projectIdentifier })"
ng-disabled="vm.isDisabled()"
aria-label="{{ ::vm.text.create }}">
ng-click="$ctrl.createWorkPackage()"
ng-disabled="$ctrl.isDisabled()"
aria-label="{{ ::$ctrl.text.create }}">
<i class="button--icon icon-add"></i>
<span class="button--text" ng-bind="::vm.text.button" aria-hidden="true"></span>
<span class="button--text" ng-bind="::$ctrl.text.button" aria-hidden="true"></span>
</button>
</div>

@ -40,7 +40,7 @@ function wpCreateButton() {
},
bindToController: true,
controllerAs: 'vm',
controllerAs: '$ctrl',
controller: 'WorkPackageCreateButtonController'
}
}

Loading…
Cancel
Save