Commit dacb363f authored by Peter Harrison's avatar Peter Harrison

Assignment of tasks to users - UI changes.

parent 2754b553
/**
* GRAVITY WORKFLOW AUTOMATION
* (C) Copyright 2015 Orcon Limited
* (C) Copyright 2016 Peter Harrison
*
* This file is part of Gravity Workflow Automation.
*
......@@ -859,6 +860,46 @@ public class CardController {
}
return cardTask;
}
@PreAuthorize("hasPermission(#boardId, 'BOARD', 'WRITE,ADMIN')")
@RequestMapping(value = "/{cardId}/tasks/{taskId}/take", method=RequestMethod.GET)
public @ResponseBody CardTask takeTask(@PathVariable String boardId,
@PathVariable String phaseId,
@PathVariable String cardId,
@PathVariable String taskId) throws Exception {
ObjectContentManager ocm = ocmFactory.getOcm();
CardTask cardTask;
try {
cardTask = cardTools.getCardTask(boardId, phaseId, cardId, taskId, ocm);
if(cardTask==null){
cardTask = createTask( boardId, phaseId, cardId, taskId, true, ocm);
return cardTask;
}
if(cardTask.getComplete() || !StringUtils.isEmpty(cardTask.getUser())){
return cardTask;
}
cardTask.setUser(listTools.getCurrentUser());
ocm.update(cardTask);
Card card = new Card();
card.setPath(cardTask.getPath());
storeCardEvent(URI.HISTORY_URI,"Assigning Task " + cardTask.getDetail() + " to " + cardTask.getUser(),
card.getBoard(), card.getPhase(), cardId, "info", "assign-" + cardTask.getTaskid(), ocm);
ocm.save();
} finally {
ocm.logout();
}
return cardTask;
}
@PreAuthorize("hasPermission(#boardId, 'BOARD', 'WRITE,ADMIN')")
@RequestMapping(value = "/{cardId}/tasks/{taskId}/revert", method=RequestMethod.GET)
public @ResponseBody CardTask revertTask(@PathVariable String boardId,
......@@ -876,10 +917,6 @@ public class CardController {
throw new ResourceNotFoundException();
}
if(!cardTask.getComplete()){
return cardTask;
}
cardTask.setComplete(false);
cardTask.setOccuredTime(null);
cardTask.setUser(null);
......
......@@ -357,10 +357,18 @@ div.validation-message.validation-message-invalid {
background: #8c8;
}
.row.card-task.task-take:hover {
background: #f2ff26;
}
.row.card-task.task-complete {
background: #ada;
}
.row.card-task.task-take {
background: #f8ff89;
}
.row.card-task.task-incomplete {
padding: 6px 12px;
}
......@@ -377,6 +385,11 @@ div.validation-message.validation-message-invalid {
color: black;
}
.task-take .card-task-name {
font-weight: bold;
color: black;
}
.card-task .card-task-toggle {
border: none;
background-color: transparent;
......@@ -396,11 +409,15 @@ div.validation-message.validation-message-invalid {
opacity: 0.8;
}
.card-task.task-take .card-task-toggle {
background: url('../../images/glyphicons_136_cogwheel.png') no-repeat center center;
opacity: 0.8;
}
.card-task.task-incomplete .card-task-toggle {
background: url('../../images/glyphicons_197_remove.png') no-repeat center center;
}
.card-task-details {
font-size: 9pt;
line-height: 11pt;
......@@ -412,7 +429,7 @@ div.validation-message.validation-message-invalid {
}
.card-task.task-incomplete .card-task-details {
display: none;
opacity: 1.0;
}
......
......@@ -2,7 +2,6 @@
<html>
<head>
<!-- STYLE SHEETS -->
<link href="http://use.typekit.com/k/saa3wbx-d.css?3bb2a6e53c9684ffdc9a9bfe1b5b2a6216bc43f667eade1f8c67b88a89fc1532774479e9777421c424ed97e8e14d0fb546f13194b30807eeda3296c10f544bb7db153146d52c54b3a5cb454d4a95ae02d61ba37044a79b04b084080315204291e7bd2afa40b6fb5a0c7954a3980643774aa97cc57573715ef96e11e691c895e406181ff7e11de555a7e7ec0a6d0e080ff680715601d604daf2035a1ac10303d3799bb39b39e705a27ea465b2dd491c91ad743951e1" rel="stylesheet">
<link rel="stylesheet" href="css/core/main.css"/>
<link rel="stylesheet" href="css/core/splash.css"/>
<link rel="stylesheet" href="css/core/board.css"/>
......
......@@ -92,6 +92,21 @@
If you are a manager frustrated with the glacial speed at which your
business processes can adapt to changing conditions you could benefit
from Gravity Workflow Automation.</p>
<md-content>
<md-list>
<md-subheader class="md-no-sticky">Subheading</md-subheader>
<md-list-item class="md-3-line" ng-repeat="card in cards">
<div class="md-list-item-text" layout="column">
<h3>{{ card }}</h3>
</div>
</md-list-item>
</md-list>
</md-content>
</div>
</div> <!-- /container -->
......@@ -99,7 +114,8 @@
</div>
<script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> -->
<script src="scripts/lib/jquery-1.11.1.min.js" type="text/javascript"></script>
<script src="js/bootstrap.min.js"></script>
<script src="scripts/core/gravityApp.js"></script>
......
......@@ -143,42 +143,59 @@ var card = {
$block.append('<h2>Tasks</h2>');
jQuery.each(data, function(i,t) {
var state = t.complete?"complete":"incomplete";
var state = "incomplete";
if( t.complete ) state = "complete"
else if( t.user != "" && t.user!=null ) state = "take";
$block.append('<div class="row card-task task-' + state + '" data-state="' + state + '">' +
'<button name="card-task-toggle" class="card-task-toggle" data-taskid="' + t.id + '"/>' +
'<div class="card-task-name">' + t.detail + '</div>' +
'<div class="card-task-details"></div>' +
'</div>');
if (state == "complete")
if (state == "complete") {
$block.find('div.row.card-task').last().find('div.card-task-details').html('Completed by <strong>' + (t.user && t.user != null? t.user:"system") + '</strong> on ' + convertDateToString(t.occuredTime));
} else if (state == "take") {
$block.find('div.row.card-task').last().find('div.card-task-details').html('Assigned to <strong>' + t.user + '</strong>');
}
$('button[name="card-task-toggle"]').last().bind("click", function(e) {
var $parent = $(this).parent(),
state = $parent.data('state'),
newstate = state == "complete"?"incomplete":"complete",
$details = $parent.find('div.card-task-details');
method = '';
if(state=='take') method='complete'
else if(state=='incomplete') method='take'
else if(state=='complete') method='revert';
if (state != newstate) {
$parent.removeClass('error');
$details = $parent.find('div.card-task-details');
$parent.removeClass('error');
jQuery.ajax({
url: ajaxUrl + card.carddata.path + '/tasks/' + $(this).data('taskid') + '/' + method,
success: function(data) {
var newstate = "incomplete";
if( data.complete ) newstate = "complete"
else if( data.user != "" && data.user!=null ) newstate = "take";
if (newstate == "complete")
$parent.find('div.card-task-details').html('Completed by <strong>' + data.user + '</strong> on ' + convertDateToString(data.occuredTime));
else if (newstate == "take")
$parent.find('div.card-task-details').html('Assigned to <strong>' + data.user + '</strong>')
else if (newstate == "incomplete")
$parent.find('div.card-task-details').html('')
$parent.removeClass('task-' + state);
$parent.addClass('task-' + newstate);
$parent.data('state', newstate);
},
error: function() {
$parent.addClass('error');
}
});
jQuery.ajax({
url: ajaxUrl + card.carddata.path + '/tasks/' + $(this).data('taskid') + '/' + (newstate == "complete"?"complete":"revert"),
success: function(data) {
if (newstate == "complete")
$parent.find('div.card-task-details').html('Completed by <strong>' + (data.user && data.user != null? data.user:"system") + '</strong> on ' + convertDateToString(data.occuredTime));
else
$details.html('');
$parent.removeClass('task-' + state);
$parent.addClass('task-' + newstate);
$parent.data('state', newstate);
},
error: function() {
$parent.addClass('error');
}
});
}
});
});
},
......
......@@ -18,16 +18,20 @@ app.controller('boardCtrl', function($scope, $http) {
}
$scope.phases = phases;
$scope.phase = phases[0].name;
$scope.phasid = phases[0].id;
$scope.phaseid = phases[0].id;
$scope.views = response.views;
$scope.filters = response.filters;
});
$scope.getCards();
});
}
$scope.setPhase = function(key,phase) {
$scope.phase = phase.name;
$scope.phaseid = key;
$scope.phaseid = key;
$scope.getCards();
}
$scope.setFilter = function(key,filter) {
......@@ -50,5 +54,13 @@ app.controller('boardCtrl', function($scope, $http) {
}
}
$scope.getCards = function() {
url = "/gravity/spring/board/" + $scope.boardid + "/phases/" + $scope.phaseid + "/cards";
$http.get(url).success(function (response) {
$scope.cards = response;
});
}
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment