Fixture/wp position column (#251)

* add position column again as it's used all over the place

reverting https://github.com/finnlabs/openproject-backlogs/pull/235

See also:

https://community.openproject.com/projects/openproject/work_packages/24462/activity

* include position in schema and render it for wps

* fixed ruby version

* fixed call to ci setup

* updated .travis.yml to reflect latest core version

[ci skip]
pull/6827/head
Markus Kahl 8 years ago committed by Oliver Günther
parent 234e2fae4c
commit 7855b3d630
  1. 64
      .travis.yml
  2. 42
      lib/open_project/backlogs/engine.rb
  3. 9
      lib/open_project/backlogs/patches/query_patch.rb

@ -1,12 +1,12 @@
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
# Copyright (C) 2012-2017 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) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
@ -33,7 +33,7 @@
language: ruby
rvm:
- 2.2.5
- 2.4.1
sudo: false
@ -41,10 +41,6 @@ cache:
bundler: true
directories:
- frontend/node_modules
- frontend/bower_components
bundler_args: --without development production docker
branches:
only:
@ -56,7 +52,6 @@ env:
global:
- CI=true
- RAILS_ENV=test
- COVERAGE=true
matrix:
- "TEST_SUITE=plugins:specs DB=mysql GROUP_SIZE=1 GROUP=1"
@ -65,14 +60,15 @@ env:
- "TEST_SUITE=npm"
- "TEST_SUITE=spec_legacy DB=mysql"
- "TEST_SUITE=cucumber DB=mysql GROUP_SIZE=2 GROUP=1"
- "TEST_SUITE=cucumber DB=mysql GROUP_SIZE=2 GROUP=2"
- "TEST_SUITE=specs DB=mysql GROUP_SIZE=3 GROUP=1"
- "TEST_SUITE=specs DB=mysql GROUP_SIZE=3 GROUP=2"
- "TEST_SUITE=specs DB=mysql GROUP_SIZE=3 GROUP=3"
- "TEST_SUITE=features DB=mysql GROUP_SIZE=3 GROUP=1"
- "TEST_SUITE=features DB=mysql GROUP_SIZE=3 GROUP=2"
- "TEST_SUITE=features DB=mysql GROUP_SIZE=3 GROUP=3"
- "TEST_SUITE=cucumber DB=mysql GROUP_SIZE=1 GROUP=1"
- "TEST_SUITE=specs DB=mysql GROUP_SIZE=4 GROUP=1"
- "TEST_SUITE=specs DB=mysql GROUP_SIZE=4 GROUP=2"
- "TEST_SUITE=specs DB=mysql GROUP_SIZE=4 GROUP=3"
- "TEST_SUITE=specs DB=mysql GROUP_SIZE=4 GROUP=4"
- "TEST_SUITE=features DB=mysql GROUP_SIZE=4 GROUP=1"
- "TEST_SUITE=features DB=mysql GROUP_SIZE=4 GROUP=2"
- "TEST_SUITE=features DB=mysql GROUP_SIZE=4 GROUP=3"
- "TEST_SUITE=features DB=mysql GROUP_SIZE=4 GROUP=4"
before_install:
# Custom plugin instructions follow.
@ -90,32 +86,36 @@ before_install:
- git checkout openproject/$TRAVIS_BRANCH
# End of custom plugin instructions.
- "rvm @default,@global do gem uninstall bundler -a -x"
- gem install bundler -v 1.12.5
- echo `bundle -v`
- "echo `firefox -v`"
- "export DISPLAY=:99.0"
- "/sbin/start-stop-daemon --start -v --pidfile ./tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1920x1080x16"
- "echo `xdpyinfo -display :99 | grep 'dimensions' | awk '{ print $2 }'`"
# Install Node LTS Boron (6.9.1)
- nvm install 6.9.1
# We need npm 4.0 for a bugfix in cross-platform shrinkwrap
# https://github.com/npm/npm/issues/14042
- npm install npm@4.0
- travis_retry npm install
# We need phantomjs 2.0 to get tests passing
- mkdir travis-phantomjs
- wget https://s3.amazonaws.com/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2 -O $PWD/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2
- tar -xvf $PWD/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2 -C $PWD/travis-phantomjs
- export PATH=$PWD/travis-phantomjs:$PATH
- "nvm install 6.9.1"
bundler_args: --binstubs --without development production docker
before_script:
- sh script/ci_setup.sh $DB
- sh script/ci_setup.sh $TEST_SUITE $DB
script:
- sh script/ci_runner.sh
notifications:
email: false
slack:
on_success: change
on_failure: always
on_pull_requests: false
rooms:
# CE
- secure: "mQqyZRjOix72MAAcjIanPOCfzMlQOqMhYOEd+6SNCcK7nb9ku0rPtFYWtifvp3+ajA5YKVJZ/W2qRn+Flw99zg8SfhPBV89SALXapUnjuZW0rcPexP0vrQW/AR6176DG3+WQOM8BFOYmN1yuGsz7YZK3xZo7yPp8XHKwzWoEYS6BOEUyfyE5T8dGJGqIKwpGEnnpBJf+CVsXeX56xg6wL+9CPVIEDb7IcrPoYQ5K6Kh9gq+7Ube7I7lbsSpdm1TAS4si7G9A6IaJ4WD1QvnUDrajGz2IM/bkP0zs50kGSrbagm707QMC8P4aLzJ64aUOfziyeYA1BSiDl5dZCUc3/dJtjMkUoRlmErwe6x8N5mwn6iVQ5LtWQeJIiy+wrBvjnghkl2/B7z3iZvEsDl6Uip6Dtv7ccmSskkh0ulsEykxWdAsRddpSaEYHv5pqex9aVgIMljM8o3DFTQclhVyGM0nrryDiMjhkCR5spighp/uR7nHEULlmJMGilyjqy6iB3/S6O1CXY110jpgYEAqhxkY9VA1hYYVLsoKV90uUGlnJcQRqQPoP3q1OqUGlRT5Y2ydM2FTBvsBGB+bhMQgZhZORqlkfIYzWDoUs4v6vM9v16XsP6TeXzNd0BPCZ+WamtOZBpwvSXZl85lqIEFONZ12uIr1R/sPsv6bQndN6gLk="
# EE
- secure: "P6co7i4H73ZBjH/zRt5a+OuZp+x0aDUOorXRKO3RmCfgR2cu02+MB0nHkXrbKsfzFMBLjEEi3nqVUBhC2vxW+vpPrYuhlxp3it7hVwGhTgghjRjI1/0ybAUZjxYgeTt+QhUJsKEuE3tlwPq/YQ5hqhcO/AtEpORn9W11oi0NGaCmSzcKKo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4w1zngjqOLjk+LftqWwT42D47RKW3SZfVEVm8Vw+JGfh/uJUNAsPsu+Mybw8k0aDmLjPTlRZD+dYvQ2EPizgc2+cf+0GVoaGzKZF+cJ8I0ut8kO13M9ZmjiHU0se4="
addons:
firefox: "45.0esr"
postgresql: "9.3"
postgresql: "9.3"

@ -138,6 +138,10 @@ module OpenProject::Backlogs
patch_with_namespace :DemoData, :ProjectSeeder
extend_api_response(:v3, :work_packages, :work_package) do
property :position,
render_nil: true,
if: ->(*) { backlogs_enabled? && type && type.passes_attribute_constraint?(:position) }
property :story_points,
render_nil: true,
if: ->(*) { backlogs_enabled? && type && type.passes_attribute_constraint?(:story_points) }
@ -153,6 +157,10 @@ module OpenProject::Backlogs
end
extend_api_response(:v3, :work_packages, :work_package_payload) do
property :position,
render_nil: true,
if: ->(*) { backlogs_enabled? && type && type.passes_attribute_constraint?(:position) }
property :story_points,
render_nil: true,
if: ->(*) { backlogs_enabled? && type && type.passes_attribute_constraint?(:story_points) }
@ -174,6 +182,15 @@ module OpenProject::Backlogs
end
extend_api_response(:v3, :work_packages, :schema, :work_package_schema) do
schema :position,
type: 'Integer',
required: false,
writable: false,
show_if: -> (*) {
represented.project && represented.project.backlogs_enabled? &&
(!represented.type || represented.type.passes_attribute_constraint?(:position))
}
schema :story_points,
type: 'Integer',
required: false,
@ -190,6 +207,14 @@ module OpenProject::Backlogs
end
extend_api_response(:v3, :work_packages, :schema, :work_package_sums_schema) do
schema :position,
type: 'Integer',
required: false,
writable: false,
show_if: -> (*) {
::Setting.work_package_list_summable_columns.include?('position')
}
schema :story_points,
type: 'Integer',
required: false,
@ -208,6 +233,12 @@ module OpenProject::Backlogs
end
extend_api_response(:v3, :work_packages, :work_package_sums) do
property :position,
render_nil: true,
if: -> (*) {
::Setting.work_package_list_summable_columns.include?('position')
}
property :story_points,
render_nil: true,
if: -> (*) {
@ -253,8 +284,16 @@ module OpenProject::Backlogs
end
config.to_prepare do
::Type.add_constraint :story_points, ->(type, project: nil) do
::Type.add_constraint :position, ->(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 :story_points, ->(type, project: nil) do
if project.present?
project.backlogs_enabled? && type.story?
else
@ -268,6 +307,7 @@ module OpenProject::Backlogs
end
::Type.add_default_mapping(:estimates_and_time, :story_points, :remaining_time)
::Type.add_default_mapping(:other, :position)
Queries::Register.filter Query, OpenProject::Backlogs::WorkPackageFilter
end

@ -44,7 +44,14 @@ module OpenProject::Backlogs::Patches::QueryPatch
add_available_column(QueryColumn.new(:remaining_hours,
sortable: "#{WorkPackage.table_name}.remaining_hours",
summable: true))
add_available_column(
QueryColumn.new(
:position,
default_order: 'asc',
# Sort by position only, always show work_packages without a position at the end
sortable: "CASE WHEN #{WorkPackage.table_name}.position IS NULL THEN 1 ELSE 0 END ASC, #{WorkPackage.table_name}.position"
)
)
end
end
end

Loading…
Cancel
Save