forked from exoplatform/task
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TA-58 Develop a custom workflow capability
- Loading branch information
Nguyen The Tuyen
committed
Aug 6, 2015
1 parent
2d84dd1
commit f72f904
Showing
14 changed files
with
977 additions
and
462 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
...agement/src/main/java/org/exoplatform/task/management/assets/javascripts/taskBoardView.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
define('taskBoardView', ['jquery', 'taskManagementApp', 'SHARED/edit_inline_js'], | ||
function($, taApp, editinline) { | ||
|
||
var boardView = {}; | ||
boardView.init = function() { | ||
taApp.onReady(function($) { | ||
boardView.initDomEventListener(); | ||
boardView.initEditInline(); | ||
}); | ||
}; | ||
|
||
boardView.initDomEventListener = function() { | ||
var ui = taApp.getUI(); | ||
var $centerPanelContent = ui.$centerPanelContent; | ||
var $centerPanel = ui.$centerPanel; | ||
$centerPanel.off('click', '[data-statusid] .actionRemoveStatus').on('click', '[data-statusid] .actionRemoveStatus', function(e) { | ||
if ($centerPanel.find('[data-statusid]').length < 2) { | ||
alert('There are only one status. It can not be deleted'); | ||
return; | ||
} | ||
var $status = $(e.target).closest('[data-statusid]'); | ||
var status = $status.data('statusid'); | ||
if (status > 0) { | ||
$centerPanelContent.jzAjax('TaskController.removeStatus()', { | ||
data: {statusId: status}, | ||
method: 'POST', | ||
success: function(response) { | ||
$centerPanelContent.html(response); | ||
} | ||
}); | ||
} else { | ||
$centerPanel.find('.col.col-new').hide(); | ||
} | ||
}); | ||
|
||
$centerPanel.off('click', '.actionAddStatus').on('click', '.actionAddStatus', function(e) { | ||
$centerPanel.find('.col.col-new').show(); | ||
$centerPanel.find('[name="statusName"]').focus(); | ||
}); | ||
$centerPanel.off('submit', '.formCreateNewStatus').on('submit', '.formCreateNewStatus', function(e) { | ||
var $form = $(e.target).closest('form'); | ||
var statusName = $form.find('[name="statusName"]').val(); | ||
var projectId = $form.closest('[data-projectid]').data('projectid'); | ||
if (projectId == undefined || projectId <= 0) { | ||
alert('Can not create status for undefined project'); | ||
return; | ||
} | ||
if (statusName == undefined || statusName == '') { | ||
alert('status name is required'); | ||
return false; | ||
} else { | ||
$centerPanelContent.jzAjax('TaskController.createStatus()', { | ||
data: { | ||
name: statusName, | ||
projectId: projectId | ||
}, | ||
method: 'POST', | ||
success: function(response) { | ||
$centerPanelContent.html(response); | ||
} | ||
}); | ||
} | ||
return false; | ||
}); | ||
}; | ||
|
||
boardView.initEditInline = function() { | ||
var ui = taApp.getUI(); | ||
var $centerPanelContent = ui.$centerPanelContent; | ||
var saveStatusFunction = function(params) { | ||
var d = new $.Deferred; | ||
var data = { | ||
id: params.pk, | ||
name: params.value | ||
}; | ||
$centerPanelContent.jzAjax('StatusController.updateStatus()',{ | ||
data: data, | ||
method: 'POST', | ||
success: function(response) { | ||
d.resolve(); | ||
}, | ||
error: function(jqXHR, textStatus, errorThrown ) { | ||
d.reject('update failure: ' + jqXHR.responseText); | ||
} | ||
}); | ||
return d.promise(); | ||
}; | ||
var options = { | ||
url: saveStatusFunction, | ||
toggle: 'dblclick', | ||
mode: 'inline', | ||
showbuttons: false, | ||
onblur: 'submit', | ||
emptyclass: 'muted', | ||
highlight: false, | ||
inputclass: 'blackLarge', | ||
clear: false | ||
}; | ||
$centerPanelContent.find('.taskBoardView .editable').each(function() { | ||
var $this = $(this); | ||
$this.editable(options); | ||
$this.on('shown', function(e, editable) { | ||
$this.parent().removeClass('inactive').addClass('active'); | ||
}).on('hidden', function(e, editable) { | ||
$this.parent().removeClass('active').addClass('inactive'); | ||
}); | ||
}); | ||
}; | ||
|
||
return boardView; | ||
}); |
138 changes: 138 additions & 0 deletions
138
...gement/src/main/java/org/exoplatform/task/management/assets/javascripts/taskManagement.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
define('taskManagementApp', ['jquery', 'SHARED/juzu-ajax'], | ||
function($) { | ||
|
||
var taApp = {}; | ||
|
||
var isDomReadyExcuted = false; | ||
$(document).ready(function($) { | ||
isDomReadyExcuted = true; | ||
}); | ||
|
||
taApp.onReady = function(callback) { | ||
if (isDomReadyExcuted) { | ||
callback(); | ||
} else { | ||
$(document).ready(callback); | ||
} | ||
}; | ||
|
||
var taskUI = false; | ||
taApp.getUI = function() { | ||
if (!taskUI) { | ||
var $taskManagement = $('#taskManagement'); | ||
var $leftPanel = $('#taskManagement > .leftPanel'); | ||
var $centerPanel = $('#taskManagement > .centerPanel'); | ||
var $rightPanel = $('#taskManagement > .rightPanel'); | ||
var $rightPanelContent = $rightPanel.find('.rightPanelContent'); | ||
var $centerPanelContent = $centerPanel.find('.centerPanelContent'); | ||
|
||
taskUI = { | ||
'$taskManagement' : $taskManagement, | ||
'$leftPanel' : $leftPanel, | ||
'$centerPanel' : $centerPanel, | ||
'$rightPanel' : $rightPanel, | ||
'$rightPanelContent' : $rightPanelContent, | ||
'$centerPanelContent' : $centerPanelContent | ||
}; | ||
} | ||
return taskUI; | ||
} | ||
|
||
taApp.showDialog = function(controllerURL, data) { | ||
var $modalPlace = $('.modalPlace'); | ||
$modalPlace.jzLoad(controllerURL, data, function() { | ||
var $dialog = $modalPlace.children().first(); | ||
$dialog.modal({'backdrop': false}); | ||
}); | ||
} | ||
|
||
taApp.showOneTimePopover = function($popover) { | ||
if ($popover.data('content')) { | ||
$popover.popover('show'); | ||
$(document).one('click', function() { | ||
$popover.popover('hide'); | ||
$popover.popover('destroy'); | ||
}); | ||
} | ||
} | ||
|
||
taApp.showRightPanel = function($centerPanel, $rightPanel) { | ||
$centerPanel.removeClass('span9').addClass('span5'); | ||
$rightPanel.show(); | ||
$rightPanel.find('[data-toggle="tooltip"]').tooltip(); | ||
$rightPanel.find('*[rel="tooltip"]').tooltip({ | ||
placement: 'top' | ||
}); | ||
}; | ||
|
||
taApp.hideRightPanel = function($centerPanel, $rightPanel, $rightPanelContent) { | ||
$rightPanelContent.html(''); | ||
$rightPanel.hide(); | ||
$centerPanel.removeClass('span5').addClass('span9'); | ||
}; | ||
|
||
taApp.reloadTaskList = function(projectId, filter, callback) { | ||
var $centerPanelContent = taApp.getUI().$centerPanelContent; | ||
if ($.isFunction(filter)) { | ||
filter = ''; | ||
callback = filter; | ||
} | ||
if (typeof filter !== 'string') { | ||
filter = ''; | ||
} | ||
var data = {projectId: projectId, filter: filter}; | ||
$centerPanelContent.jzLoad('TaskController.listTasks()', data, function() { | ||
if (callback) { | ||
callback(); | ||
} | ||
}); | ||
} | ||
|
||
taApp.reloadProjectTree = function(id) { | ||
var $leftPanel = taApp.getUI().$leftPanel; | ||
var $listProject = $leftPanel.find('ul.list-projects.projectTree'); | ||
$listProject.jzLoad('ProjectController.projectTree()', function() { | ||
if (id) { | ||
$listProject.find('a.project-name[data-id="' + id+ '"]').click(); | ||
} else { | ||
if ($listProject.find('a.project-name').length > 0) { | ||
$listProject.find('.project-name').first().click(); | ||
} else { | ||
$leftPanel.find('.project-name[data-id="0"]').first().click(); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
taApp.setTaskComplete = function(taskId, isCompleted) { | ||
var ui = taApp.getUI(); | ||
var $taskItem = ui.$centerPanel.find('.taskItem[data-taskid="' + taskId + '"]'); | ||
var $next = $taskItem.next('.taskItem').first(); | ||
if ($next.length == 0) { | ||
$next.prev('.taskItem').first(); | ||
} | ||
|
||
var data = {taskId: taskId, completed: isCompleted}; | ||
// | ||
$taskItem.jzAjax('TaskController.updateCompleted()', { | ||
data: data, | ||
success: function(message) { | ||
if (isCompleted) { | ||
$taskItem.fadeOut(500, function() { | ||
$taskItem.remove(); | ||
}); | ||
if ($next.length == 0) { | ||
ui.$leftPanel.find('.active .project-name').click(); | ||
} else { | ||
$next.click(); | ||
} | ||
} | ||
}, | ||
error : function(jqXHR, textStatus, errorThrown) { | ||
console.error && console.error('update failure: ' + jqXHR.responseText); | ||
} | ||
}); | ||
} | ||
|
||
return taApp; | ||
}); |
Oops, something went wrong.