Isolate the directive scope

pull/4023/head
Alex Dik 9 years ago
parent 62cd9c40fd
commit 924eda1912
  1. 9
      frontend/app/components/wp-buttons/wp-list-view-button/wp-list-view-button.directive.html
  2. 15
      frontend/app/components/wp-buttons/wp-list-view-button/wp-list-view-button.directive.js

@ -1,14 +1,15 @@
<label for="work-packages-list-view-button" <label for="work-packages-list-view-button"
ng-attr-accesskey="{{ isActive() ? undefined : '8' }}" ng-attr-accesskey="{{ isActive() ? undefined : '8' }}"
class="hidden-for-sighted"> class="hidden-for-sighted">
{{ getActivationActionLabel(!isActive()) + ' ' + I18n.t('js.button_list_view') }}
{{ text.label }}
</label> </label>
<button id="work-packages-list-view-button" <button id="work-packages-list-view-button"
ng-disabled="editAll.state" ng-disabled="isDisabled()"
class="button" class="button"
title="{{ getActivationActionLabel(!isActive()) + ' ' + I18n.t('js.button_list_view') }}" title="{{ text.label }}"
ng-click="openListView()" ng-click="openListView()"
ng-class="{ '-active': isActive() }"> ng-class="{ '-active': isActive() }">
<i class="icon-view-list button--icon"></i> <i class="icon-view-list button--icon"></i>
<span class="hidden-for-sighted">{{ getActivationActionLabel(!isActive()) + ' ' + I18n.t('js.button_list_view') }}</span> <span class="hidden-for-sighted">{{ text.label }}</span>
</button> </button>

@ -35,11 +35,13 @@ function wpListViewButton() {
restrict: 'E', restrict: 'E',
templateUrl: '/components/wp-buttons/wp-list-view-button/wp-list-view-button.directive.html', templateUrl: '/components/wp-buttons/wp-list-view-button/wp-list-view-button.directive.html',
scope: {},
controller: WorkPackageListViewButtonController controller: WorkPackageListViewButtonController
}; };
} }
function WorkPackageListViewButtonController($scope, $state) { function WorkPackageListViewButtonController($scope, $state, inplaceEditAll) {
$scope.isActive = function () { $scope.isActive = function () {
return $state.is('work-packages.list'); return $state.is('work-packages.list');
}; };
@ -51,4 +53,15 @@ function WorkPackageListViewButtonController($scope, $state) {
}); });
}; };
$scope.isDisabled = function () {
return inplaceEditAll.state;
};
$scope.text = {
get label() {
var activate = !$scope.isActive() ? I18n.t('js.label_activate') + ' ' : '';
return activate + I18n.t('js.button_list_view');
}
};
} }

Loading…
Cancel
Save