Signed-off-by: Florian Kraft <f.kraft@finn.de>pull/3434/head
parent
22015141d3
commit
0e3dc2c14c
@ -1,37 +1,11 @@ |
||||
<div id="detail-panel-watchers"> |
||||
<ul class="watchers-list" ng-if="watchers.length"> |
||||
<li ng-repeat="watcher in watchers"> |
||||
<user-field focus="$index == focusElementIndex" user="watcher"></user-field> |
||||
<accessible-by-keyboard execute="deleteWatcher(watcher)" ng-if="watcher.links.removeWatcher" |
||||
link-class="detail-panel-watchers-delete-watcher-link"> |
||||
<icon-wrapper icon-name="close" |
||||
icon-title="{{I18n.t('js.button_delete_watcher')}}" |
||||
class="detail-panel-watchers-delete-watcher-icon"></icon-wrapper> |
||||
</accessible-by-keyboard> |
||||
</li> |
||||
</ul> |
||||
<div id="detail-panel-watchers"> |
||||
|
||||
<div id="detail-panel-watchers-add-watcher" ng-if="workPackage.link('addWatcher') && availableWatchers.length"> |
||||
<h3 ng-bind="I18n.t('js.button_add_watcher')"/> |
||||
<fieldset> |
||||
<legend ng-bind="I18n.t('js.button_add_watcher')" class="hidden-for-sighted"/> |
||||
<div id="watchers_selected_list" class="hidden-for-sighted">{{watcherListString()}}</div> |
||||
<ui-select |
||||
multiple |
||||
title="{{ I18n.t('js.button_add_watcher') }}" |
||||
aria-labelledby="watchers_selected_list" |
||||
ng-model="watcher.selected" |
||||
theme="select2"> |
||||
<ui-select-match |
||||
placeholder="{{ I18n.t('js.label_select_watcher') }}"> |
||||
{{ $item.props.name }} |
||||
</ui-select-match> |
||||
<ui-select-choices |
||||
repeat="item in availableWatchers | filter: $select.search"> |
||||
<div ng-bind-html="item.props.name | highlight: $select.search"></div> |
||||
</ui-select-choices> |
||||
</ui-select> |
||||
</fieldset> |
||||
</div> |
||||
|
||||
</div> |
||||
<ul class="watchers-list" ng-if="watchers.length"> |
||||
<li ng-repeat="watcher in watchers"> |
||||
<a data-ng-href="{{watcher._links.self.href}}">{{watcher._links.self.title}}</a> |
||||
</li> |
||||
<li data-ng-show="adding"> |
||||
</li> |
||||
</ul> |
||||
<a data-ng-click="adding = true" data-ng-hide="adding">Add watcher</a> |
||||
</div> |
||||
|
@ -0,0 +1,74 @@ |
||||
//-- 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.
|
||||
//++
|
||||
|
||||
|
||||
module.exports = function($http, $q) { |
||||
'use strict'; |
||||
|
||||
var getWatchers = function(path) { |
||||
return function() { |
||||
var watchers = $q.defer(); |
||||
$http.get(path).success(function(data) { |
||||
watchers.resolve(data._embedded.elements); |
||||
}).error(function(err) { |
||||
watchers.reject(err); |
||||
}); |
||||
return watchers.promise; |
||||
}; |
||||
}; |
||||
|
||||
var load = function(workPackage) { |
||||
var path = workPackage.links.watchers.url(); |
||||
return getWatchers(path)(); |
||||
}, |
||||
available = function(workPackage) { |
||||
var path = workPackage.links.availableWatchers.url(); |
||||
return getWatchers(path)(); |
||||
}, |
||||
all = function(workPackage) { |
||||
var watchers = $q.defer(); |
||||
$q.all([load(workPackage), available(workPackage)]).then(function(allWatchers) { |
||||
var watching = allWatchers[0], |
||||
available = _.filter(allWatchers[1], function(user) { |
||||
return _.findIndex(allWatchers[0], function(matchedUser) { |
||||
return matchedUser.id !== user.id; |
||||
}) > -1; |
||||
}) |
||||
watchers.resolve({ watching: watching, available: available }); |
||||
}, function(err) { |
||||
watchers.reject(err); |
||||
}); |
||||
return watchers.promise; |
||||
}; |
||||
|
||||
return { |
||||
load: load, |
||||
available: available, |
||||
all: all |
||||
}; |
||||
}; |
Loading…
Reference in new issue