fix watcher selection

* path was wrong
* elements are now embedded. Adaptation in frontend required for that
* link to availableWatchers was always presented. Changing that need handling in frontend
pull/2310/head
Jens Ulferts 10 years ago
parent 08d56a24da
commit 356791492e
  1. 24
      doc/apiv3-documentation.apib
  2. 12
      frontend/app/work_packages/controllers/details-tab-watchers-controller.js
  3. 2
      lib/api/v3/utilities/path_helper.rb
  4. 2
      lib/api/v3/work_packages/work_package_representer.rb
  5. 2
      spec/lib/api/v3/utilities/path_helper_spec.rb
  6. 7
      spec/lib/api/v3/work_packages/work_package_representer_spec.rb

@ -1882,18 +1882,18 @@ Note that due to sharing this might be more than the versions *defined* by that
## Linked Properties:
| Link | Description | Type | Constraints | Supported operations | Condition |
| :------------: | --------------------------------------------------------- | ----------- | ----------- | -------------------- | -------------------------------- |
| self | This work package | WorkPackage | not null | READ | |
| author | The person that created the work package | User | not null | READ | |
| assignee | The person that is intended to work on the work package | User | | READ / WRITE | |
| availableWatchers | All users that can be added to the work package as watchers. | User | | READ | |
| category | The category of the work package | Category | | READ / WRITE | |
| priority | The priority of the work package | Priority | not null | READ / WRITE | |
| responsible | The person that is responsible for the overall outcome | User | | READ / WRITE | |
| status | The current status of the work package | Status | not null | READ / WRITE | |
| timeEntries | All time entries logged on the work package. Please note that this is a link to an HTML resource for now and as such, the link is subject to change. | N/A | | READ | **Permission** view time entries |
| version | The version associated to the work package | Version | | READ / WRITE | |
| Link | Description | Type | Constraints | Supported operations | Condition |
| :------------: | --------------------------------------------------------- | ----------- | ----------- | -------------------- | -------------------------------- |
| self | This work package | WorkPackage | not null | READ | |
| author | The person that created the work package | User | not null | READ | |
| assignee | The person that is intended to work on the work package | User | | READ / WRITE | |
| availableWatchers | All users that can be added to the work package as watchers. | User | | READ | **Permission** add work package watchers |
| category | The category of the work package | Category | | READ / WRITE | |
| priority | The priority of the work package | Priority | not null | READ / WRITE | |
| responsible | The person that is responsible for the overall outcome | User | | READ / WRITE | |
| status | The current status of the work package | Status | not null | READ / WRITE | |
| timeEntries | All time entries logged on the work package. Please note that this is a link to an HTML resource for now and as such, the link is subject to change. | N/A | | READ | **Permission** view time entries |
| version | The version associated to the work package | Version | | READ / WRITE | |
## Properties:

@ -67,13 +67,19 @@ module.exports = function($scope, $filter, $timeout, I18n, ADD_WATCHER_SELECT_IN
}
function fetchAvailableWatchers() {
if ($scope.workPackage.links.availableWatchers === undefined) {
$scope.availableWatchers = [];
return;
}
$scope.workPackage.links.availableWatchers
.fetch()
.then(function(data) {
// Temporarily filter out watchers already assigned to the work package on the client-side
$scope.availableWatchers = getFilteredCollection(data.embedded.availableWatchers, $scope.watchers);
// TODO do filtering on the API side and replace the update of the available watchers with the code provided in the following line
// $scope.availableWatchers = data.embedded.availableWatchers;
$scope.availableWatchers = getFilteredCollection(data.embedded.elements, $scope.watchers);
// TODO do filtering on the API side and replace the update of the
// available watchers with the code provided in the following line
// $scope.availableWatchers = data.embedded.elements;
});
}

@ -55,7 +55,7 @@ module API
end
def self.available_watchers(work_package_id)
"#{work_package(work_package_id)}/watchers"
"#{work_package(work_package_id)}/available_watchers"
end
def self.categories(project_id)

@ -137,7 +137,7 @@ module API
{
href: api_v3_paths.available_watchers(represented.id),
title: 'Available Watchers'
}
} if current_user_allowed_to(:add_work_package_watchers)
end
link :watchChanges do

@ -78,7 +78,7 @@ describe ::API::V3::Utilities::PathHelper do
it_behaves_like 'api v3 path'
it { is_expected.to match(/^\/api\/v3\/work_packages\/42\/watchers/) }
it { is_expected.to match(/^\/api\/v3\/work_packages\/42\/available_watchers/) }
end
describe '#categories' do

@ -457,6 +457,13 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do
let(:permission) { :manage_subtasks }
end
end
describe 'availableWatchers' do
it_behaves_like 'action link' do
let(:action) { 'availableWatchers' }
let(:permission) { :add_work_package_watchers }
end
end
end
describe '_embedded' do

Loading…
Cancel
Save