Merge pull request #2219 from 0xF013/feature/17013-status-editable
commit
fb8ffee2cb
@ -0,0 +1,127 @@ |
||||
//-- 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.
|
||||
//++
|
||||
|
||||
module.exports = function($sce, AutoCompleteHelper, TextileService) { |
||||
|
||||
function enableAutoCompletion(element) { |
||||
var textarea = element.find('.ined-input-wrapper input, .ined-input-wrapper textarea'); |
||||
AutoCompleteHelper.enableTextareaAutoCompletion(textarea); |
||||
} |
||||
|
||||
function disablePreview($scope) { |
||||
$scope.isPreview = false; |
||||
} |
||||
|
||||
function setOptions($scope) { |
||||
$scope.options = $scope |
||||
.entity.form.embedded.schema |
||||
.props[$scope.attribute]._links.allowedValues; |
||||
if (!$scope.options.length) { |
||||
$scope.isEditable = false; |
||||
} |
||||
} |
||||
|
||||
var hooks = { |
||||
_fallback: { |
||||
submit: function($scope, data) { |
||||
data[$scope.attribute] = $scope.dataObject.value; |
||||
}, |
||||
setWriteValue: function($scope) { |
||||
$scope.dataObject = { |
||||
value: $scope.entity.props[$scope.attribute] |
||||
}; |
||||
}, |
||||
setReadValue: function($scope) { |
||||
$scope.readValue = $scope.entity.props[$scope.attribute]; |
||||
} |
||||
}, |
||||
|
||||
text: { |
||||
link: function(scope, element) { |
||||
enableAutoCompletion(element); |
||||
} |
||||
}, |
||||
|
||||
'wiki_textarea': { |
||||
link: function(scope, element) { |
||||
enableAutoCompletion(element); |
||||
var textarea = element.find('.ined-input-wrapper textarea'), |
||||
lines = textarea.val().split('\n'); |
||||
textarea.attr('rows', lines.length + 1); |
||||
}, |
||||
startEditing: disablePreview, |
||||
activate: function($scope) { |
||||
disablePreview($scope); |
||||
$scope.togglePreview = function() { |
||||
$scope.isPreview = !$scope.isPreview; |
||||
$scope.error = null; |
||||
if (!$scope.isPreview) { |
||||
return; |
||||
} |
||||
$scope.isBusy = true; |
||||
TextileService |
||||
.renderWithWorkPackageContext($scope.entity.props.id, $scope.dataObject.value) |
||||
.then(function(r) { |
||||
$scope.onFinally(); |
||||
$scope.previewHtml = $sce.trustAsHtml(r.data); |
||||
}, function(e) { |
||||
$scope.onFinally(); |
||||
$scope.onFail(e); |
||||
}); |
||||
}; |
||||
}, |
||||
onFail: disablePreview, |
||||
setReadValue: function($scope) { |
||||
if ($scope.attribute == 'rawDescription') { |
||||
$scope.readValue = $sce.trustAsHtml($scope.entity.props.description); |
||||
} else { |
||||
$scope.readValue = $scope.entity.props[$scope.attribute]; |
||||
} |
||||
} |
||||
}, |
||||
|
||||
select: { |
||||
activate: setOptions, |
||||
startEditing: setOptions, |
||||
submit: function($scope, data) { |
||||
data._links = { }; |
||||
data._links[$scope.attribute] = { href: $scope.dataObject.value }; |
||||
}, |
||||
setWriteValue: function($scope) { |
||||
$scope.dataObject = { |
||||
value: $scope.entity.form.embedded.payload.links[$scope.attribute].href |
||||
}; |
||||
} |
||||
} |
||||
}; |
||||
|
||||
this.dispatchHook = function($scope, action, data) { |
||||
var actionFunction = hooks[$scope.type][action] || hooks._fallback[action] || angular.noop; |
||||
return actionFunction($scope, data); |
||||
}; |
||||
}; |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,219 @@ |
||||
{ |
||||
"_type": "Form", |
||||
"_links": { |
||||
"self": { |
||||
"href": "/api/v3/work_packages/819/form" |
||||
}, |
||||
"validate": { |
||||
"href": "/api/v3/work_packages/819/form", |
||||
"method": "post" |
||||
}, |
||||
"previewMarkup": { |
||||
"href": "/api/v3/render/textile?/api/v3/work_packages/819", |
||||
"method": "post" |
||||
}, |
||||
"commit": { |
||||
"href": "/api/v3/work_packages/819", |
||||
"method": "patch" |
||||
} |
||||
}, |
||||
"_embedded": { |
||||
"payload": { |
||||
"_type": "WorkPackage", |
||||
"_links": { |
||||
"status": { |
||||
"href": "/api/v3/statuses/2" |
||||
} |
||||
}, |
||||
"lockVersion": 119, |
||||
"subject": "66666", |
||||
"rawDescription": "#820\n2", |
||||
"parentId": 54, |
||||
"projectId": 1, |
||||
"startDate": "2014-10-23T00:00:00+00:00", |
||||
"dueDate": "2014-12-27T00:00:00+00:00", |
||||
"versionId": null, |
||||
"createdAt": "2014-11-05T15:56:53Z", |
||||
"updatedAt": "2014-11-21T08:48:57Z" |
||||
}, |
||||
"schema": { |
||||
"_type": { |
||||
"type": "MetaType", |
||||
"required": true, |
||||
"writable": false |
||||
}, |
||||
"lockVersion": { |
||||
"type": "Integer", |
||||
"required": true, |
||||
"writable": false |
||||
}, |
||||
"subject": { |
||||
"type": "String" |
||||
}, |
||||
"status": { |
||||
"_links": { |
||||
"allowedValues": [ |
||||
{ |
||||
"href": "/api/v3/statuses/1", |
||||
"title": "new" |
||||
}, |
||||
{ |
||||
"href": "/api/v3/statuses/2", |
||||
"title": "specified" |
||||
}, |
||||
{ |
||||
"href": "/api/v3/statuses/3", |
||||
"title": "confirmed" |
||||
}, |
||||
{ |
||||
"href": "/api/v3/statuses/6", |
||||
"title": "in progress" |
||||
}, |
||||
{ |
||||
"href": "/api/v3/statuses/7", |
||||
"title": "tested" |
||||
}, |
||||
{ |
||||
"href": "/api/v3/statuses/8", |
||||
"title": "on hold" |
||||
}, |
||||
{ |
||||
"href": "/api/v3/statuses/9", |
||||
"title": "rejected" |
||||
}, |
||||
{ |
||||
"href": "/api/v3/statuses/10", |
||||
"title": "closed" |
||||
} |
||||
] |
||||
}, |
||||
"type": "Status", |
||||
"_embedded": { |
||||
"allowedValues": [ |
||||
{ |
||||
"_type": "Status", |
||||
"_links": { |
||||
"self": { |
||||
"href": "/api/v3/statuses/1", |
||||
"title": "new" |
||||
} |
||||
}, |
||||
"id": 1, |
||||
"name": "new", |
||||
"isClosed": false, |
||||
"isDefault": true, |
||||
"defaultDoneRatio": null, |
||||
"position": 1 |
||||
}, |
||||
{ |
||||
"_type": "Status", |
||||
"_links": { |
||||
"self": { |
||||
"href": "/api/v3/statuses/2", |
||||
"title": "specified" |
||||
} |
||||
}, |
||||
"id": 2, |
||||
"name": "specified", |
||||
"isClosed": false, |
||||
"isDefault": false, |
||||
"defaultDoneRatio": null, |
||||
"position": 2 |
||||
}, |
||||
{ |
||||
"_type": "Status", |
||||
"_links": { |
||||
"self": { |
||||
"href": "/api/v3/statuses/3", |
||||
"title": "confirmed" |
||||
} |
||||
}, |
||||
"id": 3, |
||||
"name": "confirmed", |
||||
"isClosed": false, |
||||
"isDefault": false, |
||||
"defaultDoneRatio": null, |
||||
"position": 3 |
||||
}, |
||||
{ |
||||
"_type": "Status", |
||||
"_links": { |
||||
"self": { |
||||
"href": "/api/v3/statuses/6", |
||||
"title": "in progress" |
||||
} |
||||
}, |
||||
"id": 6, |
||||
"name": "in progress", |
||||
"isClosed": false, |
||||
"isDefault": false, |
||||
"defaultDoneRatio": null, |
||||
"position": 6 |
||||
}, |
||||
{ |
||||
"_type": "Status", |
||||
"_links": { |
||||
"self": { |
||||
"href": "/api/v3/statuses/7", |
||||
"title": "tested" |
||||
} |
||||
}, |
||||
"id": 7, |
||||
"name": "tested", |
||||
"isClosed": false, |
||||
"isDefault": false, |
||||
"defaultDoneRatio": null, |
||||
"position": 7 |
||||
}, |
||||
{ |
||||
"_type": "Status", |
||||
"_links": { |
||||
"self": { |
||||
"href": "/api/v3/statuses/8", |
||||
"title": "on hold" |
||||
} |
||||
}, |
||||
"id": 8, |
||||
"name": "on hold", |
||||
"isClosed": false, |
||||
"isDefault": false, |
||||
"defaultDoneRatio": null, |
||||
"position": 8 |
||||
}, |
||||
{ |
||||
"_type": "Status", |
||||
"_links": { |
||||
"self": { |
||||
"href": "/api/v3/statuses/9", |
||||
"title": "rejected" |
||||
} |
||||
}, |
||||
"id": 9, |
||||
"name": "rejected", |
||||
"isClosed": true, |
||||
"isDefault": false, |
||||
"defaultDoneRatio": null, |
||||
"position": 9 |
||||
}, |
||||
{ |
||||
"_type": "Status", |
||||
"_links": { |
||||
"self": { |
||||
"href": "/api/v3/statuses/10", |
||||
"title": "closed" |
||||
} |
||||
}, |
||||
"id": 10, |
||||
"name": "closed", |
||||
"isClosed": true, |
||||
"isDefault": false, |
||||
"defaultDoneRatio": null, |
||||
"position": 10 |
||||
} |
||||
] |
||||
} |
||||
} |
||||
}, |
||||
"validationErrors": {} |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -1,2 +1,2 @@ |
||||
<p><a href="/work_packages/54" class="issue work_package status-4 priority-2 parent" |
||||
title="harum temporibus sit sit autem atque optio vitaelasd22ss2 (to be scheduled)">#54</a></p> |
||||
<p><a href="/work_packages/820" class="issue work_package status-4 priority-2 parent" |
||||
title="harum temporibus sit sit autem atque optio vitaelasd22ss2 (to be scheduled)">#820</a></p> |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,219 @@ |
||||
{ |
||||
"_type": "Form", |
||||
"_links": { |
||||
"self": { |
||||
"href": "/api/v3/work_packages/820/form" |
||||
}, |
||||
"validate": { |
||||
"href": "/api/v3/work_packages/820/form", |
||||
"method": "post" |
||||
}, |
||||
"previewMarkup": { |
||||
"href": "/api/v3/render/textile?/api/v3/work_packages/820", |
||||
"method": "post" |
||||
}, |
||||
"commit": { |
||||
"href": "/api/v3/work_packages/820", |
||||
"method": "patch" |
||||
} |
||||
}, |
||||
"_embedded": { |
||||
"payload": { |
||||
"_type": "WorkPackage", |
||||
"_links": { |
||||
"status": { |
||||
"href": "/api/v3/statuses/9" |
||||
} |
||||
}, |
||||
"lockVersion": 119, |
||||
"subject": "66666", |
||||
"rawDescription": "#54\n2", |
||||
"parentId": 54, |
||||
"projectId": 1, |
||||
"startDate": "2014-10-23T00:00:00+00:00", |
||||
"dueDate": "2014-12-27T00:00:00+00:00", |
||||
"versionId": null, |
||||
"createdAt": "2014-11-05T15:56:53Z", |
||||
"updatedAt": "2014-11-21T08:48:57Z" |
||||
}, |
||||
"schema": { |
||||
"_type": { |
||||
"type": "MetaType", |
||||
"required": true, |
||||
"writable": false |
||||
}, |
||||
"lockVersion": { |
||||
"type": "Integer", |
||||
"required": true, |
||||
"writable": false |
||||
}, |
||||
"subject": { |
||||
"type": "String" |
||||
}, |
||||
"status": { |
||||
"_links": { |
||||
"allowedValues": [ |
||||
{ |
||||
"href": "/api/v3/statuses/1", |
||||
"title": "new" |
||||
}, |
||||
{ |
||||
"href": "/api/v3/statuses/2", |
||||
"title": "specified" |
||||
}, |
||||
{ |
||||
"href": "/api/v3/statuses/3", |
||||
"title": "confirmed" |
||||
}, |
||||
{ |
||||
"href": "/api/v3/statuses/6", |
||||
"title": "in progress" |
||||
}, |
||||
{ |
||||
"href": "/api/v3/statuses/7", |
||||
"title": "tested" |
||||
}, |
||||
{ |
||||
"href": "/api/v3/statuses/8", |
||||
"title": "on hold" |
||||
}, |
||||
{ |
||||
"href": "/api/v3/statuses/9", |
||||
"title": "rejected" |
||||
}, |
||||
{ |
||||
"href": "/api/v3/statuses/10", |
||||
"title": "closed" |
||||
} |
||||
] |
||||
}, |
||||
"type": "Status", |
||||
"_embedded": { |
||||
"allowedValues": [ |
||||
{ |
||||
"_type": "Status", |
||||
"_links": { |
||||
"self": { |
||||
"href": "/api/v3/statuses/1", |
||||
"title": "new" |
||||
} |
||||
}, |
||||
"id": 1, |
||||
"name": "new", |
||||
"isClosed": false, |
||||
"isDefault": true, |
||||
"defaultDoneRatio": null, |
||||
"position": 1 |
||||
}, |
||||
{ |
||||
"_type": "Status", |
||||
"_links": { |
||||
"self": { |
||||
"href": "/api/v3/statuses/2", |
||||
"title": "specified" |
||||
} |
||||
}, |
||||
"id": 2, |
||||
"name": "specified", |
||||
"isClosed": false, |
||||
"isDefault": false, |
||||
"defaultDoneRatio": null, |
||||
"position": 2 |
||||
}, |
||||
{ |
||||
"_type": "Status", |
||||
"_links": { |
||||
"self": { |
||||
"href": "/api/v3/statuses/3", |
||||
"title": "confirmed" |
||||
} |
||||
}, |
||||
"id": 3, |
||||
"name": "confirmed", |
||||
"isClosed": false, |
||||
"isDefault": false, |
||||
"defaultDoneRatio": null, |
||||
"position": 3 |
||||
}, |
||||
{ |
||||
"_type": "Status", |
||||
"_links": { |
||||
"self": { |
||||
"href": "/api/v3/statuses/6", |
||||
"title": "in progress" |
||||
} |
||||
}, |
||||
"id": 6, |
||||
"name": "in progress", |
||||
"isClosed": false, |
||||
"isDefault": false, |
||||
"defaultDoneRatio": null, |
||||
"position": 6 |
||||
}, |
||||
{ |
||||
"_type": "Status", |
||||
"_links": { |
||||
"self": { |
||||
"href": "/api/v3/statuses/7", |
||||
"title": "tested" |
||||
} |
||||
}, |
||||
"id": 7, |
||||
"name": "tested", |
||||
"isClosed": false, |
||||
"isDefault": false, |
||||
"defaultDoneRatio": null, |
||||
"position": 7 |
||||
}, |
||||
{ |
||||
"_type": "Status", |
||||
"_links": { |
||||
"self": { |
||||
"href": "/api/v3/statuses/8", |
||||
"title": "on hold" |
||||
} |
||||
}, |
||||
"id": 8, |
||||
"name": "on hold", |
||||
"isClosed": false, |
||||
"isDefault": false, |
||||
"defaultDoneRatio": null, |
||||
"position": 8 |
||||
}, |
||||
{ |
||||
"_type": "Status", |
||||
"_links": { |
||||
"self": { |
||||
"href": "/api/v3/statuses/9", |
||||
"title": "rejected" |
||||
} |
||||
}, |
||||
"id": 9, |
||||
"name": "rejected", |
||||
"isClosed": true, |
||||
"isDefault": false, |
||||
"defaultDoneRatio": null, |
||||
"position": 9 |
||||
}, |
||||
{ |
||||
"_type": "Status", |
||||
"_links": { |
||||
"self": { |
||||
"href": "/api/v3/statuses/10", |
||||
"title": "closed" |
||||
} |
||||
}, |
||||
"id": 10, |
||||
"name": "closed", |
||||
"isClosed": true, |
||||
"isDefault": false, |
||||
"defaultDoneRatio": null, |
||||
"position": 10 |
||||
} |
||||
] |
||||
} |
||||
} |
||||
}, |
||||
"validationErrors": {} |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,219 @@ |
||||
{ |
||||
"_type": "Form", |
||||
"_links": { |
||||
"self": { |
||||
"href": "/api/v3/work_packages/821/form" |
||||
}, |
||||
"validate": { |
||||
"href": "/api/v3/work_packages/821/form", |
||||
"method": "post" |
||||
}, |
||||
"previewMarkup": { |
||||
"href": "/api/v3/render/textile?/api/v3/work_packages/821", |
||||
"method": "post" |
||||
}, |
||||
"commit": { |
||||
"href": "/api/v3/work_packages/821", |
||||
"method": "patch" |
||||
} |
||||
}, |
||||
"_embedded": { |
||||
"payload": { |
||||
"_type": "WorkPackage", |
||||
"_links": { |
||||
"status": { |
||||
"href": "/api/v3/statuses/9" |
||||
} |
||||
}, |
||||
"lockVersion": 119, |
||||
"subject": "66666", |
||||
"rawDescription": "#54\n2", |
||||
"parentId": 54, |
||||
"projectId": 1, |
||||
"startDate": "2014-10-23T00:00:00+00:00", |
||||
"dueDate": "2014-12-27T00:00:00+00:00", |
||||
"versionId": null, |
||||
"createdAt": "2014-11-05T15:56:53Z", |
||||
"updatedAt": "2014-11-21T08:48:57Z" |
||||
}, |
||||
"schema": { |
||||
"_type": { |
||||
"type": "MetaType", |
||||
"required": true, |
||||
"writable": false |
||||
}, |
||||
"lockVersion": { |
||||
"type": "Integer", |
||||
"required": true, |
||||
"writable": false |
||||
}, |
||||
"subject": { |
||||
"type": "String" |
||||
}, |
||||
"status": { |
||||
"_links": { |
||||
"allowedValues": [ |
||||
{ |
||||
"href": "/api/v3/statuses/1", |
||||
"title": "new" |
||||
}, |
||||
{ |
||||
"href": "/api/v3/statuses/2", |
||||
"title": "specified" |
||||
}, |
||||
{ |
||||
"href": "/api/v3/statuses/3", |
||||
"title": "confirmed" |
||||
}, |
||||
{ |
||||
"href": "/api/v3/statuses/6", |
||||
"title": "in progress" |
||||
}, |
||||
{ |
||||
"href": "/api/v3/statuses/7", |
||||
"title": "tested" |
||||
}, |
||||
{ |
||||
"href": "/api/v3/statuses/8", |
||||
"title": "on hold" |
||||
}, |
||||
{ |
||||
"href": "/api/v3/statuses/9", |
||||
"title": "rejected" |
||||
}, |
||||
{ |
||||
"href": "/api/v3/statuses/10", |
||||
"title": "closed" |
||||
} |
||||
] |
||||
}, |
||||
"type": "Status", |
||||
"_embedded": { |
||||
"allowedValues": [ |
||||
{ |
||||
"_type": "Status", |
||||
"_links": { |
||||
"self": { |
||||
"href": "/api/v3/statuses/1", |
||||
"title": "new" |
||||
} |
||||
}, |
||||
"id": 1, |
||||
"name": "new", |
||||
"isClosed": false, |
||||
"isDefault": true, |
||||
"defaultDoneRatio": null, |
||||
"position": 1 |
||||
}, |
||||
{ |
||||
"_type": "Status", |
||||
"_links": { |
||||
"self": { |
||||
"href": "/api/v3/statuses/2", |
||||
"title": "specified" |
||||
} |
||||
}, |
||||
"id": 2, |
||||
"name": "specified", |
||||
"isClosed": false, |
||||
"isDefault": false, |
||||
"defaultDoneRatio": null, |
||||
"position": 2 |
||||
}, |
||||
{ |
||||
"_type": "Status", |
||||
"_links": { |
||||
"self": { |
||||
"href": "/api/v3/statuses/3", |
||||
"title": "confirmed" |
||||
} |
||||
}, |
||||
"id": 3, |
||||
"name": "confirmed", |
||||
"isClosed": false, |
||||
"isDefault": false, |
||||
"defaultDoneRatio": null, |
||||
"position": 3 |
||||
}, |
||||
{ |
||||
"_type": "Status", |
||||
"_links": { |
||||
"self": { |
||||
"href": "/api/v3/statuses/6", |
||||
"title": "in progress" |
||||
} |
||||
}, |
||||
"id": 6, |
||||
"name": "in progress", |
||||
"isClosed": false, |
||||
"isDefault": false, |
||||
"defaultDoneRatio": null, |
||||
"position": 6 |
||||
}, |
||||
{ |
||||
"_type": "Status", |
||||
"_links": { |
||||
"self": { |
||||
"href": "/api/v3/statuses/7", |
||||
"title": "tested" |
||||
} |
||||
}, |
||||
"id": 7, |
||||
"name": "tested", |
||||
"isClosed": false, |
||||
"isDefault": false, |
||||
"defaultDoneRatio": null, |
||||
"position": 7 |
||||
}, |
||||
{ |
||||
"_type": "Status", |
||||
"_links": { |
||||
"self": { |
||||
"href": "/api/v3/statuses/8", |
||||
"title": "on hold" |
||||
} |
||||
}, |
||||
"id": 8, |
||||
"name": "on hold", |
||||
"isClosed": false, |
||||
"isDefault": false, |
||||
"defaultDoneRatio": null, |
||||
"position": 8 |
||||
}, |
||||
{ |
||||
"_type": "Status", |
||||
"_links": { |
||||
"self": { |
||||
"href": "/api/v3/statuses/9", |
||||
"title": "rejected" |
||||
} |
||||
}, |
||||
"id": 9, |
||||
"name": "rejected", |
||||
"isClosed": true, |
||||
"isDefault": false, |
||||
"defaultDoneRatio": null, |
||||
"position": 9 |
||||
}, |
||||
{ |
||||
"_type": "Status", |
||||
"_links": { |
||||
"self": { |
||||
"href": "/api/v3/statuses/10", |
||||
"title": "closed" |
||||
} |
||||
}, |
||||
"id": 10, |
||||
"name": "closed", |
||||
"isClosed": true, |
||||
"isDefault": false, |
||||
"defaultDoneRatio": null, |
||||
"position": 10 |
||||
} |
||||
] |
||||
} |
||||
} |
||||
}, |
||||
"validationErrors": {} |
||||
} |
||||
} |
Loading…
Reference in new issue