The 'me' value is currently automatically normalized to the current user, making it impossible to store queries that reference the current user whenever accessing the query as before.pull/5901/head
parent
c02b1514db
commit
fdfb41b327
@ -1,212 +0,0 @@ |
||||
// -- copyright
|
||||
// OpenProject is a project management system.
|
||||
// Copyright (C) 2012-2015 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.helpers') |
||||
.factory('PathHelper', PathHelper); |
||||
|
||||
function PathHelper() { |
||||
var PathHelper, |
||||
appBasePath = window.appBasePath ? window.appBasePath : ''; |
||||
|
||||
return PathHelper = { |
||||
staticBase: appBasePath, |
||||
|
||||
apiV2: appBasePath + '/api/v2', |
||||
apiV3: appBasePath + '/api/v3', |
||||
|
||||
activityPath: function() { |
||||
return PathHelper.staticBase + '/activity'; |
||||
}, |
||||
boardPath: function(projectIdentifier, boardIdentifier) { |
||||
return PathHelper.projectBoardsPath(projectIdentifier) + '/' + boardIdentifier; |
||||
}, |
||||
keyboardShortcutsHelpPath: function() { |
||||
return PathHelper.staticBase + '/help/keyboard_shortcuts'; |
||||
}, |
||||
messagePath: function(messageIdentifier) { |
||||
return PathHelper.staticBase + '/topics/' + messageIdentifier; |
||||
}, |
||||
myPagePath: function() { |
||||
return PathHelper.staticBase + '/my/page'; |
||||
}, |
||||
projectsPath: function() { |
||||
return PathHelper.staticBase + '/projects'; |
||||
}, |
||||
projectPath: function(projectIdentifier) { |
||||
return PathHelper.projectsPath() + '/' + projectIdentifier; |
||||
}, |
||||
projectActivityPath: function(projectIdentifier) { |
||||
return PathHelper.projectPath(projectIdentifier) + '/activity'; |
||||
}, |
||||
projectBoardsPath: function(projectIdentifier) { |
||||
return PathHelper.projectPath(projectIdentifier) + '/boards'; |
||||
}, |
||||
projectCalendarPath: function(projectId) { |
||||
return PathHelper.projectPath(projectId) + '/work_packages/calendar'; |
||||
}, |
||||
projectNewsPath: function(projectId) { |
||||
return PathHelper.projectPath(projectId) + '/news'; |
||||
}, |
||||
projectTimelinesPath: function(projectId) { |
||||
return PathHelper.projectPath(projectId) + '/timelines'; |
||||
}, |
||||
projectTimeEntriesPath: function(projectIdentifier) { |
||||
return PathHelper.projectPath(projectIdentifier) + '/time_entries'; |
||||
}, |
||||
projectWikiPath: function(projectId) { |
||||
return PathHelper.projectPath(projectId) + '/wiki'; |
||||
}, |
||||
projectWorkPackagePath: function(projectId, wpId) { |
||||
return PathHelper.projectWorkPackagesPath(projectId) + '/' + wpId; |
||||
}, |
||||
projectWorkPackagesPath: function(projectId) { |
||||
return PathHelper.projectPath(projectId) + '/work_packages'; |
||||
}, |
||||
projectWorkPackageNewPath: function(projectId) { |
||||
return PathHelper.projectWorkPackagesPath(projectId) + '/new'; |
||||
}, |
||||
queryPath: function(queryIdentifier) { |
||||
return PathHelper.staticBase + '/queries/' + queryIdentifier; |
||||
}, |
||||
timeEntriesPath: function(workPackageId) { |
||||
var suffix = '/time_entries'; |
||||
|
||||
if (workPackageId) { |
||||
return PathHelper.workPackagePath(workPackageId) + suffix; |
||||
} else { |
||||
return PathHelper.staticBase + suffix; // time entries root path
|
||||
} |
||||
}, |
||||
timeEntryPath: function(timeEntryIdentifier) { |
||||
return PathHelper.staticBase + '/time_entries/' + timeEntryIdentifier; |
||||
}, |
||||
timeEntryEditPath: function(timeEntryIdentifier) { |
||||
return PathHelper.timeEntryPath(timeEntryIdentifier) + '/edit'; |
||||
}, |
||||
usersPath: function() { |
||||
return PathHelper.staticBase + '/users'; |
||||
}, |
||||
userPath: function(id) { |
||||
return PathHelper.usersPath() + '/' + id; |
||||
}, |
||||
versionsPath: function() { |
||||
return PathHelper.staticBase + '/versions'; |
||||
}, |
||||
versionPath: function(versionId) { |
||||
return PathHelper.versionsPath() + '/' + versionId; |
||||
}, |
||||
workPackagesPath: function() { |
||||
return PathHelper.staticBase + '/work_packages'; |
||||
}, |
||||
workPackagePath: function(id) { |
||||
return PathHelper.staticBase + '/work_packages/' + id; |
||||
}, |
||||
workPackageCopyPath: function(workPackageId) { |
||||
return PathHelper.workPackagePath(workPackageId) + '/copy'; |
||||
}, |
||||
workPackageDetailsCopyPath: function(projectIdentifier, workPackageId) { |
||||
return PathHelper.projectWorkPackagesPath(projectIdentifier) + '/details/' + workPackageId + '/copy'; |
||||
}, |
||||
workPackagesBulkDeletePath: function() { |
||||
return PathHelper.workPackagesPath() + '/bulk'; |
||||
}, |
||||
workPackagesBulkEditPath: function(workPackageIds) { |
||||
var query = _.reduce(workPackageIds, function(idsString, id) { |
||||
idsString += 'id[]=' + id + '&'; |
||||
return idsString; |
||||
}, '').slice(0, -1); |
||||
|
||||
return PathHelper.workPackagesBulkDeletePath + '/edit?' + query; |
||||
}, |
||||
workPackageJsonAutoCompletePath: function(projectId) { |
||||
var path = PathHelper.workPackagesPath() + '/auto_complete.json'; |
||||
if (projectId) { |
||||
path += '?project_id=' + projectId |
||||
} |
||||
|
||||
return path; |
||||
}, |
||||
|
||||
// API V2
|
||||
apiV2ProjectsPath: function() { |
||||
return PathHelper.apiV2 + '/projects'; |
||||
}, |
||||
|
||||
// API V3
|
||||
apiConfigurationPath: function() { |
||||
return PathHelper.apiV3 + '/configuration'; |
||||
}, |
||||
apiQueryStarPath: function(queryId) { |
||||
return PathHelper.apiV3QueryPath(queryId) + '/star'; |
||||
}, |
||||
apiQueryUnstarPath: function(queryId) { |
||||
return PathHelper.apiV3QueryPath(queryId) + '/unstar'; |
||||
}, |
||||
apiV3QueryPath: function(queryId) { |
||||
return PathHelper.apiV3 + '/queries/' + queryId; |
||||
}, |
||||
apiV3WorkPackagePath: function(workPackageId) { |
||||
return PathHelper.apiV3 + '/work_packages/' + workPackageId; |
||||
}, |
||||
apiV3WorkPackagesPath: function(workPackageId) { |
||||
return PathHelper.apiV3 + '/work_packages'; |
||||
}, |
||||
apiV3WorkPackageFormPath: function(projectIdentifier) { |
||||
return PathHelper.apiV3WorkPackagesPath() + '/form'; |
||||
}, |
||||
apiV3ProjectPath: function(projectIdentifier) { |
||||
return PathHelper.apiV3 + '/projects/' + projectIdentifier; |
||||
}, |
||||
apiV3AvailableProjectsPath: function() { |
||||
return PathHelper.apiV3WorkPackagesPath() + '/available_projects'; |
||||
}, |
||||
apiv3ProjectWorkPackagesPath: function(projectIdentifier) { |
||||
return PathHelper.apiV3ProjectPath(projectIdentifier) + '/work_packages'; |
||||
}, |
||||
apiV3ProjectCategoriesPath: function(projectIdentifier) { |
||||
return PathHelper.apiV3ProjectPath(projectIdentifier) + '/categories'; |
||||
}, |
||||
apiV3TypePath: function(typeId) { |
||||
return PathHelper.apiV3 + '/types/' + typeId; |
||||
}, |
||||
apiV3UserPath: function(userId) { |
||||
return PathHelper.apiV3 + '/users/' + userId; |
||||
}, |
||||
apiStatusesPath: function() { |
||||
return PathHelper.apiV3 + '/statuses'; |
||||
}, |
||||
apiProjectWorkPackageTypesPath: function(projectIdentifier) { |
||||
return PathHelper.apiV3ProjectPath(projectIdentifier) + '/types'; |
||||
}, |
||||
apiWorkPackageTypesPath: function() { |
||||
return PathHelper.apiV3 + '/types'; |
||||
}, |
||||
|
||||
}; |
||||
} |
@ -0,0 +1,201 @@ |
||||
// -- copyright
|
||||
// OpenProject is a project management system.
|
||||
// Copyright (C) 2012-2015 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.
|
||||
// ++
|
||||
|
||||
export class PathHelperService { |
||||
public readonly appBasePath:string; |
||||
|
||||
constructor(public $window:ng.IWindowService) { |
||||
this.appBasePath = $window.appBasePath ? $window.appBasePath : ''; |
||||
} |
||||
|
||||
public get staticBase() { |
||||
return this.appBasePath; |
||||
} |
||||
|
||||
public get apiV2() { |
||||
return this.appBasePath + '/api/v2'; |
||||
} |
||||
|
||||
public get apiV3() { |
||||
return this.appBasePath + '/api/v3'; |
||||
} |
||||
|
||||
public boardPath(projectIdentifier:string, boardIdentifier:string) { |
||||
return this.projectBoardsPath(projectIdentifier) + '/' + boardIdentifier; |
||||
} |
||||
|
||||
public keyboardShortcutsHelpPath() { |
||||
return this.staticBase + '/help/keyboard_shortcuts'; |
||||
} |
||||
|
||||
public myPagePath() { |
||||
return this.staticBase + '/my/page'; |
||||
} |
||||
|
||||
public projectsPath() { |
||||
return this.staticBase + '/projects'; |
||||
} |
||||
|
||||
public projectPath(projectIdentifier:string) { |
||||
return this.projectsPath() + '/' + projectIdentifier; |
||||
} |
||||
|
||||
public projectActivityPath(projectIdentifier:string) { |
||||
return this.projectPath(projectIdentifier) + '/activity'; |
||||
} |
||||
|
||||
public projectBoardsPath(projectIdentifier:string) { |
||||
return this.projectPath(projectIdentifier) + '/boards'; |
||||
} |
||||
|
||||
public projectCalendarPath(projectId:string) { |
||||
return this.projectPath(projectId) + '/work_packages/calendar'; |
||||
} |
||||
|
||||
public projectNewsPath(projectId:string) { |
||||
return this.projectPath(projectId) + '/news'; |
||||
} |
||||
|
||||
public projectTimelinesPath(projectId:string) { |
||||
return this.projectPath(projectId) + '/timelines'; |
||||
} |
||||
|
||||
public projectTimeEntriesPath(projectIdentifier:string) { |
||||
return this.projectPath(projectIdentifier) + '/time_entries'; |
||||
} |
||||
|
||||
public projectWikiPath(projectId:string) { |
||||
return this.projectPath(projectId) + '/wiki'; |
||||
} |
||||
|
||||
public projectWorkPackagePath(projectId:string, wpId:string|number) { |
||||
return this.projectWorkPackagesPath(projectId) + '/' + wpId; |
||||
} |
||||
|
||||
public projectWorkPackagesPath(projectId:string) { |
||||
return this.projectPath(projectId) + '/work_packages'; |
||||
} |
||||
|
||||
public projectWorkPackageNewPath(projectId:string) { |
||||
return this.projectWorkPackagesPath(projectId) + '/new'; |
||||
} |
||||
|
||||
public timeEntriesPath(workPackageId:string|number) { |
||||
var suffix = '/time_entries'; |
||||
|
||||
if (workPackageId) { |
||||
return this.workPackagePath(workPackageId) + suffix; |
||||
} else { |
||||
return this.staticBase + suffix; // time entries root path
|
||||
} |
||||
} |
||||
|
||||
public timeEntryPath(timeEntryIdentifier:string) { |
||||
return this.staticBase + '/time_entries/' + timeEntryIdentifier; |
||||
} |
||||
|
||||
public usersPath() { |
||||
return this.staticBase + '/users'; |
||||
} |
||||
|
||||
public userPath(id:string|number) { |
||||
return this.usersPath() + '/' + id; |
||||
} |
||||
|
||||
public versionsPath() { |
||||
return this.staticBase + '/versions'; |
||||
} |
||||
|
||||
public workPackagesPath() { |
||||
return this.staticBase + '/work_packages'; |
||||
} |
||||
|
||||
public workPackagePath(id:string|number) { |
||||
return this.staticBase + '/work_packages/' + id; |
||||
} |
||||
|
||||
public workPackageCopyPath(workPackageId:string|number) { |
||||
return this.workPackagePath(workPackageId) + '/copy'; |
||||
} |
||||
|
||||
public workPackageDetailsCopyPath(projectIdentifier:string, workPackageId:string|number) { |
||||
return this.projectWorkPackagesPath(projectIdentifier) + '/details/' + workPackageId + '/copy'; |
||||
} |
||||
|
||||
public workPackagesBulkDeletePath() { |
||||
return this.workPackagesPath() + '/bulk'; |
||||
} |
||||
|
||||
public workPackageJsonAutoCompletePath(projectId:string) { |
||||
var path = this.workPackagesPath() + '/auto_complete.json'; |
||||
if (projectId) { |
||||
path += '?project_id=' + projectId |
||||
} |
||||
|
||||
return path; |
||||
} |
||||
|
||||
// API V2
|
||||
public apiV2ProjectsPath() { |
||||
return this.apiV2 + '/projects'; |
||||
} |
||||
|
||||
// API V3
|
||||
public apiConfigurationPath() { |
||||
return this.apiV3 + '/configuration'; |
||||
} |
||||
|
||||
public apiV3WorkPackagePath(workPackageId:string|number) { |
||||
return this.apiV3 + '/work_packages/' + workPackageId; |
||||
} |
||||
|
||||
public apiV3ProjectPath(projectIdentifier:string) { |
||||
return this.apiV3 + '/projects/' + projectIdentifier; |
||||
} |
||||
|
||||
public apiV3ProjectCategoriesPath(projectIdentifier:string) { |
||||
return this.apiV3ProjectPath(projectIdentifier) + '/categories'; |
||||
} |
||||
|
||||
public apiV3UserPath(userId:string|number) { |
||||
return this.apiV3 + '/users/' + userId; |
||||
} |
||||
|
||||
public apiV3UserMePath() { |
||||
return this.apiV3UserPath('me'); |
||||
} |
||||
|
||||
public apiV3StatusesPath() { |
||||
return this.apiV3 + '/statuses'; |
||||
} |
||||
} |
||||
|
||||
angular |
||||
.module('openproject.helpers') |
||||
.service('PathHelper', PathHelperService); |
||||
|
@ -0,0 +1,107 @@ |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# 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-2017 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. |
||||
#++ |
||||
|
||||
require 'spec_helper' |
||||
|
||||
describe 'filter me value', js: true do |
||||
let(:project) { FactoryGirl.create :project, is_public: true } |
||||
let(:role) { FactoryGirl.create :existing_role, permissions: [:view_work_packages] } |
||||
let(:admin) { FactoryGirl.create :admin } |
||||
let(:user) { FactoryGirl.create :user } |
||||
let(:wp_admin) { FactoryGirl.create :work_package, project: project, assigned_to: admin } |
||||
let(:wp_user) { FactoryGirl.create :work_package, project: project, assigned_to: user } |
||||
|
||||
let(:wp_table) { ::Pages::WorkPackagesTable.new(project) } |
||||
let(:filters) { ::Components::WorkPackages::Filters.new } |
||||
|
||||
before do |
||||
login_as admin |
||||
project.add_member! admin, role |
||||
project.add_member! user, role |
||||
end |
||||
|
||||
context 'as anonymous', with_settings: { login_required?: false } do |
||||
let(:assignee_query) do |
||||
query = FactoryGirl.create(:query, |
||||
name: 'Assignee Query', |
||||
project: project, |
||||
user: user) |
||||
|
||||
query.add_filter('assigned_to_id', '=', ['me']) |
||||
query.save!(validate: false) |
||||
|
||||
query |
||||
end |
||||
|
||||
|
||||
it 'shows an error visiting a query with a me value' do |
||||
wp_table.visit_query assignee_query |
||||
wp_table.expect_notification(type: :error, |
||||
message: I18n.t('js.work_packages.faulty_query.description')) |
||||
end |
||||
end |
||||
|
||||
context 'logged in' do |
||||
before do |
||||
wp_admin |
||||
wp_user |
||||
|
||||
login_as(admin) |
||||
end |
||||
|
||||
it 'shows the one work package filtering for myself' do |
||||
wp_table.visit! |
||||
wp_table.expect_work_package_listed(wp_admin, wp_user) |
||||
|
||||
# Add and save query with me filter |
||||
filters.open |
||||
filters.remove_filter 'status' |
||||
filters.add_filter_by('Assignee', 'is', 'me') |
||||
|
||||
wp_table.expect_work_package_not_listed(wp_user) |
||||
wp_table.expect_work_package_listed(wp_admin) |
||||
|
||||
wp_table.save_as('Me query') |
||||
loading_indicator_saveguard |
||||
|
||||
# Expect correct while saving |
||||
wp_table.expect_title 'Me query' |
||||
query = Query.last |
||||
expect(query.filters.first.values).to eq ['me'] |
||||
filters.expect_filter_by('Assignee', 'is', 'me') |
||||
|
||||
# Revisit query |
||||
wp_table.visit_query query |
||||
wp_table.expect_work_package_not_listed(wp_user) |
||||
wp_table.expect_work_package_listed(wp_admin) |
||||
|
||||
filters.open |
||||
filters.expect_filter_by('Assignee', 'is', 'me') |
||||
end |
||||
end |
||||
end |
Loading…
Reference in new issue