Move view button controller code to the directive

pull/3941/head
Alex Dik 9 years ago
parent 3a8fea571d
commit ed2b0a4006
  1. 24
      frontend/app/components/routes/controllers/work-packages-list.controller.js
  2. 20
      frontend/app/components/wp-buttons/view-button/view-button.directive.js
  3. 4
      frontend/app/work_packages/controllers/work-packages-controller.js

@ -274,6 +274,8 @@ function WorkPackagesListController($scope, $rootScope, $state, $stateParams, $l
return selected || $scope.rows.first().object.id;
}
$scope.nextAvailableWorkPackage = nextAvailableWorkPackage;
$scope.openLatestTab = function() {
var promise = $state.go(latestTab.getStateName(), {
workPackageId: nextAvailableWorkPackage(),
@ -309,28 +311,6 @@ function WorkPackagesListController($scope, $rootScope, $state, $stateParams, $l
}
};
$scope.showWorkPackageShowView = function() {
if (EditableFieldsState.editAll.state && $state.params.type) {
$state.go('work-packages.new', $state.params);
} else {
var id = $state.params.workPackageId
|| $scope.preselectedWorkPackageId || nextAvailableWorkPackage(),
// Have to use $location.search() here as $state.params
// isn't filled unless the url is queried for by the
// browser. This seems to be caused by #maintainUrlQueryState
// where we set the search via $location.search.
queryProps = $location.search()['query_props'];
$state.go('work-packages.show.activity', {
projectPath: $scope.projectIdentifier || '',
workPackageId: id,
'query_props': queryProps
});
}
};
$scope.getFilterCount = function() {
if ($scope.query) {
var filters = $scope.query.filters;

@ -39,6 +39,24 @@ function wpViewButton() {
};
}
function WorkPackageViewButtonController() {
function WorkPackageViewButtonController($scope, $state, EditableFieldsState) {
$scope.isShowViewActive = function() {
return $state.includes('work-packages.show');
};
$scope.showWorkPackageShowView = function() {
if (EditableFieldsState.editAll.state && $state.params.type) {
$state.go('work-packages.new', $state.params);
} else {
var id = $state.params.workPackageId || $scope.preselectedWorkPackageId ||
$scope.nextAvailableWorkPackage(), queryProps = $location.search()['query_props'];
$state.go('work-packages.show.activity', {
projectPath: $scope.projectIdentifier || '',
workPackageId: id,
'query_props': queryProps
});
}
};
}

@ -50,10 +50,6 @@ module.exports = function($scope, $state, $stateParams, QueryService, PathHelper
return $state.is('work-packages.list');
};
$scope.isShowViewActive = function() {
return $state.includes('work-packages.show');
};
$scope.getToggleActionLabel = function(active) {
return (active) ? I18n.t('js.label_deactivate') : I18n.t('js.label_activate');
};

Loading…
Cancel
Save