Merge pull request #1556 from opf/feature/api-create-user-show
Feature/api create user showpull/1562/head
commit
e9bd084ae2
@ -0,0 +1,43 @@ |
||||
//-- copyright
|
||||
// OpenProject is a project management system.
|
||||
// Copyright (C) 2012-2014 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.workPackages.tabs') |
||||
|
||||
.directive('userField', [function() { |
||||
return { |
||||
restrict: 'E', |
||||
replace: true, |
||||
templateUrl: '/templates/work_packages/tabs/_user_field.html', |
||||
scope: { user: '=' }, |
||||
link: function(scope) { |
||||
if (scope.user.props && (scope.user.props.firstName || scope.user.props.lastName)) { |
||||
scope.userName = scope.user.props.firstName + ' ' + scope.user.props.lastName; |
||||
} |
||||
} |
||||
}; |
||||
}]); |
@ -0,0 +1,30 @@ |
||||
module API |
||||
module V3 |
||||
module Users |
||||
class UsersAPI < Grape::API |
||||
|
||||
resources :users do |
||||
|
||||
params do |
||||
requires :id, desc: 'User\'s id' |
||||
end |
||||
namespace ':id' do |
||||
|
||||
before do |
||||
@user = User.find(params[:id]) |
||||
model = ::API::V3::Users::UserModel.new(@user) |
||||
@representer = ::API::V3::Users::UserRepresenter.new(model) |
||||
end |
||||
|
||||
get do |
||||
@representer.to_json |
||||
end |
||||
|
||||
end |
||||
|
||||
end |
||||
|
||||
end |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,109 @@ |
||||
<div class="detail-panel-description"> |
||||
|
||||
<h3>Description</h3> |
||||
<div class="detail-panel-description-content"> |
||||
{{ workPackage.props.description }} |
||||
</div> |
||||
</div> |
||||
|
||||
<div class="panel-toggler" ng-click="toggleStates.hideFullDescription = !toggleStates.hideFullDescription"> |
||||
<fieldset> |
||||
<legend align="center"> |
||||
<span ng-if="!toggleStates.hideFullDescription"> |
||||
<i class="icon-arrow-right5-2"></i> |
||||
Hide full description |
||||
</span> |
||||
<span ng-if="toggleStates.hideFullDescription"> |
||||
<i class="icon-arrow-right5-3"></i> |
||||
Show full description |
||||
</span> |
||||
</legend> |
||||
</fieldset> |
||||
</div> |
||||
|
||||
<div class="detail-panel-attributes" slide-toggle collapsed="toggleStates.hideFullDescription"> |
||||
<ul> |
||||
<li><label>Status</label>{{ workPackage.props.status }}</li> |
||||
<li><label>Priortiy</label>{{ workPackage.props.priority }}</li> |
||||
<li><label>Date</label>{{ workPackage.props.startDate }} - {{ workPackage.props.dueDate }}</li> |
||||
<li> |
||||
<label>Responsible</label> |
||||
<img class="avatar" ng-src="{{ responsible.props.avatar }}" ng-show="{{ !!responsible }}" /> |
||||
<span class="user" ng-show="{{ !!responsible }}"> |
||||
<a ng-href="{{ userPath(responsible.props.id) }}"> |
||||
{{ responsible.props.firstName }} {{ responsible.props.lastName }} |
||||
aaa |
||||
</a> |
||||
</span> |
||||
<span class="user" ng-hide="{{ !!responsible }}"> - </span> |
||||
<!-- <span class="role">{{ responsible.props.role }}</span> --> |
||||
</li> |
||||
<li> |
||||
<label>Assignee</label> |
||||
<img class="avatar" ng-src="{{ assignee.props.avatar }}" ng-show="{{ !!assignee }}" /> |
||||
<span class="user" ng-show="{{ !!assignee }}"> |
||||
<a ng-href="{{ userPath(assignee.props.id) }}"> |
||||
{{ assignee.props.firstName }} {{ assignee.props.lastName }} |
||||
</a> |
||||
</span> |
||||
<span class="user" ng-hide="{{ !!assignee }}"> - </span> |
||||
<!-- <span class="role">{{ assignee.props.roles }}</span> --> |
||||
</li> |
||||
<li><label>% Done</label>{{ workPackage.props.percentageDone }} %</li> |
||||
</ul> |
||||
</div> |
||||
|
||||
<div class="panel-toggler" ng-click="toggleStates.hideAllAttributes = !toggleStates.hideAllAttributes"> |
||||
<fieldset> |
||||
<legend align="center"> |
||||
<span ng-if="!toggleStates.hideAllAttributes"> |
||||
<i class="icon-arrow-right5-2"></i> |
||||
Hide all attributes |
||||
</span> |
||||
<span ng-if="toggleStates.hideAllAttributes"> |
||||
<i class="icon-arrow-right5-3"></i> |
||||
Show all attributes |
||||
</span> |
||||
</legend> |
||||
</fieldset> |
||||
</div> |
||||
|
||||
<div class="detail-panel-latest-activity" slide-toggle collapsed="toggleStates.hideAllAttributes"> |
||||
<h3>Latest activity</h3> |
||||
<ul> |
||||
<li> |
||||
<div class="comments-number"><a href="#1">#1</a> |
||||
<div class="comments-icons"><i class="icon-quote"></i><i class="icon-edit"></i></div> |
||||
</div> |
||||
<img class="avatar" src="images/avatar_logout.png" /> |
||||
<span class="user"><a href="#">Christoph Zierz</a></span> |
||||
<span class="date">commented on 06/05/2014 16:42 Uhr</span> |
||||
<span class="comment">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. |
||||
Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis . .. |
||||
</span> |
||||
</li> |
||||
<li> |
||||
<div class="comments-number"><a href="#1">#2</a> |
||||
<div class="comments-icons"><i class="icon-quote"></i><i class="icon-edit"></i></div> |
||||
</div> |
||||
<img class="avatar" src="images/avatar_logout.png" /> |
||||
<span class="user"><a href="#">Niels Lindenthal</a></span> |
||||
<span class="date">commented on 08/05/2014 16:42 Uhr</span> |
||||
<span class="comment"> |
||||
<ul> |
||||
<li>Status changed from scheduled to closed</li> |
||||
<li>Assignee deleted (Michael Frister)</li> |
||||
<li>% done changed from 0 to 100</li> |
||||
</ul> |
||||
</span> |
||||
</li> |
||||
</ul> |
||||
</div> |
||||
|
||||
<div class="comments-form"> |
||||
<h3>Add your comments here</h3> |
||||
<form> |
||||
<textarea placeholder="Add comments here" rows="4"></textarea> |
||||
</form> |
||||
<button class="button">Add comment</button> |
||||
</div> |
@ -0,0 +1,11 @@ |
||||
<p> |
||||
<span ng-if="userName"> |
||||
<img class="avatar" |
||||
ng-if="user.props.avatar" |
||||
ng-src="{{user.props.avatar}}" /> |
||||
<span class="user"><a href ng-bind="userName"/></span> |
||||
<span class="role" ng-if="user.props.role" ng-bind="user.props.role"/> |
||||
</span> |
||||
<span ng-if="!userName"> - </span> |
||||
</p> |
||||
|
@ -0,0 +1,58 @@ |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2014 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. |
||||
#++ |
||||
|
||||
require 'spec_helper' |
||||
|
||||
describe ::API::V3::Users::UserRepresenter do |
||||
let(:user) { FactoryGirl.create(:user) } |
||||
let(:model) { ::API::V3::Users::UserModel.new(user) } |
||||
let(:representer) { described_class.new(model) } |
||||
|
||||
context 'generation' do |
||||
subject(:generated) { representer.to_json } |
||||
|
||||
it { should include_json('User'.to_json).at_path('_type') } |
||||
|
||||
describe 'user' do |
||||
it { should have_json_path('id') } |
||||
it { should have_json_path('login') } |
||||
it { should have_json_path('firstName') } |
||||
it { should have_json_path('lastName') } |
||||
it { should have_json_path('mail') } |
||||
it { should have_json_path('avatar') } |
||||
it { should have_json_path('createdAt') } |
||||
it { should have_json_path('updatedAt') } |
||||
end |
||||
|
||||
describe '_links' do |
||||
it 'should link to self' do |
||||
expect(subject).to have_json_path('_links/self/href') |
||||
end |
||||
end |
||||
end |
||||
end |
Loading…
Reference in new issue