Merge pull request #103 from finnlabs/feature/14005_show_costs_attributes_in_overview_tab

[Feature] 14005 show costs attributes in overview tab
pull/6827/head
ulferts 10 years ago
commit 4c40123de1
  1. 22
      app/assets/javascripts/angular/openproject-costs-app.js
  2. 40
      app/assets/javascripts/angular/work_packages/directives/cost-object-directive.js
  3. 45
      app/assets/javascripts/angular/work_packages/directives/spent-hours-directive.js
  4. 2
      app/assets/javascripts/angular/work_packages/directives/summarized-cost-entries-directive.js
  5. 23
      app/assets/stylesheets/costs/_summarized_cost_entries.css.sass
  6. 22
      app/assets/stylesheets/costs/costs.css.sass
  7. 5
      app/assets/templates/work_packages/cost_object.html
  8. 5
      app/assets/templates/work_packages/spent_hours.html
  9. 2
      app/assets/templates/work_packages/summarized_cost_entries.html
  10. 2
      app/views/hooks/costs/_view_work_package_overview_attributes.html.erb
  11. 22
      config/initializers/non_digest_assets.rb
  12. 4
      config/locales/js-de.yml
  13. 4
      config/locales/js-en.yml
  14. 6
      lib/open_project/costs/engine.rb
  15. 2
      lib/open_project/costs/hooks/work_packages_overview_attributes.rb

@ -31,8 +31,26 @@ var openprojectCostsApp = angular.module('openproject');
openprojectCostsApp.run(['HookService', function(HookService) {
HookService.register('workPackageOverviewAttributes', function(params) {
var isEmpty = params.workPackage.embedded.summarizedCostEntries.length == 0;
var directive;
return ((params.type == "spentUnits" && !isEmpty) ? "summarized-cost-entries" : undefined);
switch (params.type) {
case "spentUnits":
if (params.workPackage.embedded.summarizedCostEntries.length > 0) {
directive = "summarized-cost-entries";
}
break;
case "costObject":
if (params.workPackage.embedded.costObject) {
directive = "cost-object";
}
break;
case "spentHoursLinked":
if (params.workPackage.props.spentHours) {
directive = "spent-hours";
}
break;
}
return directive;
});
}]);

@ -0,0 +1,40 @@
//-- 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('costObject', [function() {
return {
restrict: 'E',
templateUrl: '/assets/work_packages/cost_object.html',
link: function(scope, element, attributes) {
scope.costObject = scope.workPackage.embedded.costObject;
scope.linkToCostObject = '/cost_objects/' + scope.costObject.props.id;
}
};
}]);

@ -0,0 +1,45 @@
//-- 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('spentHours', ['I18n', 'PathHelper', function(I18n, PathHelper) {
return {
restrict: 'E',
templateUrl: '/assets/work_packages/spent_hours.html',
link: function(scope, element, attributes) {
scope.spentHours = scope.workPackage.props.spentHours;
scope.spentHoursUnit = I18n.t('js.label_hours');
scope.linkToSpentHours = PathHelper.timeEntriesPath(null, scope.workPackage.props.id);
if (scope.spentHours == 1) {
scope.spentHoursUnit = I18n.t('js.label_hour');
}
}
};
}]);

@ -31,7 +31,7 @@ angular.module('openproject.workPackages.directives')
.directive('summarizedCostEntries', ['PathHelper', function(PathHelper) {
return {
restrict: 'E',
templateUrl: '/templates/work_packages/summarized_cost_entries.html',
templateUrl: '/assets/work_packages/summarized_cost_entries.html',
link: function(scope, element, attributes) {
if (scope.workPackage.embedded.summarizedCostEntries) {
scope.costTypes = scope.workPackage.embedded.summarizedCostEntries;

@ -0,0 +1,23 @@
/*-- copyright
* OpenProject Costs Plugin
*
* Copyright (C) 2009 - 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.
*
* 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.
*
*/
.costs.costTypes
.separator
margin-left: -0.2em

@ -1,25 +1,11 @@
/*-- copyright
* OpenProject Backlogs Plugin
* OpenProject Costs Plugin
*
* Copyright (C)2013 the OpenProject Foundation (OPF)
* Copyright (C)2011 Stephan Eckardt, Tim Felgentreff, Marnen Laibow-Koser, Sandro Munda
* Copyright (C)2010-2011 friflaj
* Copyright (C)2010 Maxime Guilbot, Andrew Vit, Joakim Kolsjö, ibussieres, Daniel Passos, Jason Vasquez, jpic, Emiliano Heyns
* Copyright (C)2009-2010 Mark Maglana
* Copyright (C)2009 Joe Heck, Nate Lowrie
*
* 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 Backlogs is a derivative work based on ChiliProject Backlogs.
* The copyright follows:
* Copyright (C) 2010-2011 - Emiliano Heyns, Mark Maglana, friflaj
* Copyright (C) 2011 - Jens Ulferts, Gregor Schmidt - Finn GmbH - Berlin, Germany
* Copyright (C) 2009 - 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -30,7 +16,7 @@
* 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.
*/
@import costs/costs_legacy
@import costs/summarized_cost_entries

@ -0,0 +1,5 @@
<span class="costs costObject" ng-if="costObject">
<a ng-href="{{ linkToCostObject }}" title="{{ costObject.props.subject }}">
{{ costObject.props.subject }}
</a>
</span>

@ -0,0 +1,5 @@
<span class="costs spentHours" ng-if="spentHours">
<a ng-href="{{ linkToSpentHours }}" title="{{ spentHours }} {{ spentHoursUnit }}">
{{ spentHours }} {{ spentHoursUnit }}
</a>
</span>

@ -7,6 +7,6 @@
<span ng-switch-default>{{ costType.props.unitPlural }}</span>
</span>
</a>
<span ng-if="!$last">-</span>
<span class="separator" ng-if="!$last">,</span>
</span>
</span>

@ -20,4 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
<%= javascript_include_tag 'angular/openproject-costs-app.js' %>
<%= javascript_include_tag 'angular/work_packages/directives/summarized-cost-entries-directive.js' %>
<%= javascript_include_tag 'angular/work_packages/directives/cost-object-directive.js' %>
<%= javascript_include_tag 'angular/work_packages/directives/spent-hours-directive.js' %>
<%= stylesheet_link_tag 'costs/costs.css' %>

@ -0,0 +1,22 @@
#-- copyright
# OpenProject Costs Plugin
#
# Copyright (C) 2009 - 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.
#
# 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.
#++
NonStupidDigestAssets.whitelist += [
/work_packages\/.*/
]

@ -38,6 +38,8 @@ de:
work_packages:
properties:
costObject: "Budget"
spentHours: "Aufgewendete Zeit"
spentHoursLinked: "Aufgewendete Zeit"
overallCosts: "Gesamtkosten"
spentUnits: "Gebuchte Einheiten"
label_hour: "Stunde"
label_hours: "Stunden"

@ -38,6 +38,8 @@ en:
work_packages:
properties:
costObject: "Budget"
spentHours: "Spent time"
spentHoursLinked: "Spent time"
overallCosts: "Overall costs"
spentUnits: "Spent units"
label_hour: "hour"
label_hours: "hours"

@ -152,9 +152,13 @@ module OpenProject::Costs
end
assets %w(angular/work_packages/directives/summarized-cost-entries-directive.js
angular/work_packages/directives/cost-object-directive.js
angular/openproject-costs-app.js
costs/costs.css
costs/costs.js)
costs/costs.js
work_packages/cost_object.html
work_packages/spent_hours.html
work_packages/summarized_cost_entries.html)
initializer "costs.register_hooks" do
require 'open_project/costs/hooks'

@ -29,7 +29,7 @@ module OpenProject::Costs::Hooks
attributes.reject!{ |attribute| attribute == :spentTime }
attributes << :costObject
attributes << :spentHours if user_allowed_to?(project, :view_time_entries, :view_own_time_entries)
attributes << :spentHoursLinked if user_allowed_to?(project, :view_time_entries, :view_own_time_entries)
attributes << :overallCosts
attributes << :spentUnits if user_allowed_to?(project, :view_cost_entries, :view_own_cost_entries)

Loading…
Cancel
Save