Merge branch 'hotfix/checkbox-toggle-label' into feature/ng-wp-context-menu

Conflicts:
	public/templates/work_packages/work_packages_table.html
pull/1263/head
Till Breuer 11 years ago
commit a582134c48
  1. 57
      app/assets/javascripts/angular/directives/work_packages/work-package-row-directive.js
  2. 7
      app/assets/javascripts/angular/directives/work_packages/work-packages-table-directive.js
  3. 18
      app/assets/javascripts/angular/services/work-packages-table-service.js
  4. 14
      public/templates/work_packages/work_packages_table.html

@ -0,0 +1,57 @@
//-- copyright
// OpenProject is a project management system.
// Copyright (C) 2012-2014 the OpenProject Foundation (OPF)
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License version 3.
//
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
// Copyright (C) 2006-2013 Jean-Philippe Lang
// Copyright (C) 2010-2013 the ChiliProject Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// See doc/COPYRIGHT.rdoc for more details.
//++
angular.module('openproject.workPackages.directives')
.directive('workPackageRow', ['I18n', 'WorkPackagesTableService', function(I18n, WorkPackagesTableService){
function setCheckboxTitle(scope) {
var checkboxTitleLocale = I18n.t('js.description_select_work_package');
scope.checkboxTitle = checkboxTitleLocale + '#' + scope.workPackage.id;
}
var parentWorkPackageLabel = I18n.t('js.description_subwork_package') + ' ' + I18n.t('js.label_work_package') + ' ';
function setHiddenWorkPackageLabel(scope) {
scope.parentWorkPackageHiddenText = parentWorkPackageLabel + '"' + scope.row.parent.object.subject + '"';
}
return {
restrict: 'A',
link: function(scope) {
scope.workPackage = scope.row.object;
setCheckboxTitle(scope);
if (scope.workPackage.parent_id) setHiddenWorkPackageLabel(scope);
scope.$watch('row.checked', function(checked, formerState) {
if (checked !== formerState) {
WorkPackagesTableService.setAllRowsChecked(scope.rows, scope.row, checked);
}
});
}
};
}]);

@ -28,7 +28,7 @@
angular.module('openproject.workPackages.directives')
.directive('workPackagesTable', ['I18n', function(I18n){
.directive('workPackagesTable', ['I18n', 'WorkPackagesTableService', function(I18n, WorkPackagesTableService){
return {
restrict: 'E',
replace: true,
@ -50,6 +50,7 @@ angular.module('openproject.workPackages.directives')
},
link: function(scope, element, attributes) {
scope.I18n = I18n;
scope.workPackagesTableData = WorkPackagesTableService.getWorkPackagesTableData();
var topMenuHeight = document.getElementById('top-menu').getHeight() || 0;
scope.adaptVerticalPosition = function(event) {
@ -60,6 +61,10 @@ angular.module('openproject.workPackages.directives')
scope.grouped = scope.groupByColumn !== undefined;
scope.groupExpanded = {};
scope.$watch('workPackagesTableData.allRowsChecked', function(checked) {
scope.toggleRowsLabel = checked ? I18n.t('js.button_uncheck_all') : I18n.t('js.button_check_all');
});
scope.setCheckedStateForAllRows = function(state) {
angular.forEach(scope.rows, function(row) {
row.checked = state;

@ -28,7 +28,10 @@
angular.module('openproject.workPackages.services')
.service('WorkPackagesTableService', [function() {
.service('WorkPackagesTableService', ['$filter', function($filter) {
var workPackagesTableData = {
allRowsChecked: false
};
var bulkLinks = {};
var WorkPackagesTableService = {
@ -37,7 +40,20 @@ angular.module('openproject.workPackages.services')
},
getBulkLinks: function() {
return bulkLinks;
},
getWorkPackagesTableData: function() {
return workPackagesTableData;
},
setAllRowsChecked: function(rows, currentRow, currentState) {
rows = rows.filter(function(row) {
return row !== currentRow;
});
workPackagesTableData.allRowsChecked = $filter('allRowsChecked')(rows) && currentState;
},
allRowsChecked: function() {
return workPackagesTableData.allRowsChecked;
}
};
return WorkPackagesTableService;

@ -3,11 +3,11 @@
<tr>
<th class="checkbox hide-when-print">
<a href="#"
alt="{{(rows | allRowsChecked) && I18n.t('js.button_uncheck_all') || I18n.t('js.button_check_all')}}"
alt="{{toggleRowsLabel}}"
class="no-decoration-on-hover"
ng-click="setCheckedStateForAllRows(!(rows | allRowsChecked))"
title="{{(rows | allRowsChecked) && I18n.t('js.button_uncheck_all') || I18n.t('js.button_check_all')}}">
<icon-wrapper icon-title="I18n.t('js.button_check_all') + '/' + I18n.t('js.button_uncheck_all')"
title="{{toggleRowsLabel}}">
<icon-wrapper icon-title="{{toggleRowsLabel}}"
icon-name="yes"></icon-wrapper>
</a>
</th>
@ -80,7 +80,8 @@
<!-- Work package rows -->
<tr id="work-package-{{ row.object.id }}"
<tr work-package-row
id="work-package-{{ row.object.id }}"
has-context-menu
process-event="adaptVerticalPosition"
ng-class="[
@ -97,14 +98,13 @@
<td class="checkbox hide-when-print">
<accessible-checkbox name="ids[]"
checkbox-id="work_package{{row.object.id}}"
checkbox-title="{{I18n.t('js.description_select_work_package')}}#{{row.object.id}}"
checkbox-value="row.object.id"
checkbox-title="{{checkboxTitle}}"
model="row.checked"/>
</td>
<td class="id">
<span ng-if="row.object.parent_id" class="hidden-for-sighted">
{{I18n.t('js.description_subwork_package')}} {{I18n.t('js.label_work_package')}} #{{row.parent.object.name}}
<span ng-if="workPackage.parent_id" class="hidden-for-sighted" ng-bind="parentWorkPackageHiddenText">
</span>
<a ng-href="/work_packages/{{row.object.id}}">{{row.object.id}}</a>
</td>

Loading…
Cancel
Save