Merge pull request #243 from finnlabs/feature/attribute_groups

Implement attribute groups constraint + remove frontend
pull/6827/head
Oliver Günther 8 years ago committed by GitHub
commit 927aaf1299
  1. 35
      .rubocop.yml
  2. 45
      frontend/app/openproject-backlogs-app.js
  3. 32
      lib/open_project/backlogs/engine.rb
  4. 6
      package.json

@ -1,6 +1,7 @@
AllCops:
TargetRubyVersion: 2.2
Exclude:
- "*.gemspec"
- db/schema.rb
AccessorMethodName:
Enabled: false
@ -26,19 +27,10 @@ AsciiIdentifiers:
Attr:
Enabled: false
BlockNesting:
BlockLength:
Enabled: false
BlockDelimiters:
Enabled: true
EnforcedStyle: semantic
IgnoredMethods:
- default_scope
- lambda
- proc
- it
Blocks:
BlockNesting:
Enabled: false
CaseEquality:
@ -75,7 +67,7 @@ CyclomaticComplexity:
Delegate:
Enabled: false
DeprecatedHashMethods:
PreferredHashMethods:
Enabled: false
Documentation:
@ -133,7 +125,7 @@ LineEndConcatenation:
Enabled: false
LineLength:
Max: 100
Max: 130
MethodLength:
Enabled: false
@ -202,13 +194,20 @@ SignalException:
SpecialGlobalVars:
Enabled: false
# Forcing single quotes doesn't give any reasonable advantages. To the contrary:
# it forces you to change the quotes every time you want to add interpolation,
# newlines or other escape sequences (\n), or quotes (') to a string. Rubbish.
# Don't even think about performance. That never was a valid argument to begin with.
#
# For the record: using single quotes does NOT have any performance advantages.
# Even if it did, this would be a silly argument.
#
# Ideally we would just use double quotes everywhere but since that would result
# in innumerable rubocop offenses we will just disable this. Quote away.
StringLiterals:
EnforcedStyle: single_quotes
VariableInterpolation:
Enabled: false
TrailingComma:
VariableInterpolation:
Enabled: false
TrivialAccessors:

@ -1,45 +0,0 @@
//-- copyright
// OpenProject Backlogs Plugin
//
// Copyright (C)2013-2014 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
//
// 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.
//++
// main app
var openprojectBacklogsApp = angular.module('openproject');
openprojectBacklogsApp.run([ 'ConfigurationService',
'WorkPackagesOverviewService',
function(ConfigurationService, WorkPackagesOverviewService) {
if (ConfigurationService.isModuleEnabled('backlogs')) {
WorkPackagesOverviewService.addAttributesToGroup('estimatesAndTime', ['storyPoints', 'remainingTime']);
}
}]);

@ -140,7 +140,7 @@ module OpenProject::Backlogs
extend_api_response(:v3, :work_packages, :work_package) do
property :story_points,
render_nil: true,
if: -> (*) { backlogs_enabled? && type && type.story? }
if: ->(*) { backlogs_enabled? && type && type.passes_attribute_constraint?(:story_points) }
property :remaining_time,
exec_context: :decorator,
@ -149,28 +149,28 @@ module OpenProject::Backlogs
allow_nil: true)
},
render_nil: true,
if: -> (*) { represented.backlogs_enabled? }
if: ->(*) { represented.backlogs_enabled? }
end
extend_api_response(:v3, :work_packages, :work_package_payload) do
property :story_points,
render_nil: true,
if: -> (*) { backlogs_enabled? && type && type.story? }
if: ->(*) { backlogs_enabled? && type && type.passes_attribute_constraint?(:story_points) }
property :remaining_time,
exec_context: :decorator,
getter: -> (*) {
getter: ->(*) {
datetime_formatter.format_duration_from_hours(represented.remaining_hours,
allow_nil: true)
},
setter: -> (value, *) {
setter: ->(value, *) {
remaining = datetime_formatter.parse_duration_to_hours(value,
'remainingTime',
allow_nil: true)
represented.remaining_hours = remaining
},
render_nil: true,
if: -> (*) { represented.backlogs_enabled? }
if: ->(*) { represented.backlogs_enabled? }
end
extend_api_response(:v3, :work_packages, :schema, :work_package_schema) do
@ -179,7 +179,7 @@ module OpenProject::Backlogs
required: false,
show_if: -> (*) {
represented.project && represented.project.backlogs_enabled? &&
(!represented.type || represented.type.story?)
(!represented.type || represented.type.passes_attribute_constraint?(:story_points))
}
schema :remaining_time,
@ -250,5 +250,23 @@ module OpenProject::Backlogs
initializer 'backlogs.register_query_filter' do
Queries::Register.filter Query, OpenProject::Backlogs::WorkPackageFilter
end
config.to_prepare do
::Type.add_constraint :story_points, ->(type, project: nil) do
if project.present?
project.backlogs_enabled? && type.story?
else
# Allow globally configuring the attribute if story
type.story?
end
end
::Type.add_constraint :remaining_time, ->(_type, project: nil) do
project.nil? || project.backlogs_enabled?
end
::Type.add_default_mapping(:estimates_and_time, :story_points, :remaining_time)
end
end
end

@ -1,6 +0,0 @@
{
"name": "openproject-backlogs",
"version": "0.1.0",
"main": "frontend/app/openproject-backlogs-app.js",
"dependencies": {}
}
Loading…
Cancel
Save