Skip to content

Commit

Permalink
甘特图增加删除事项功能
Browse files Browse the repository at this point in the history
  • Loading branch information
weichaoduo committed Jan 19, 2022
1 parent 30bb380 commit 0c60efa
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/view/twig/project/gantt.twig
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
<button onclick="$('#workSpace').trigger('moveDownCurrentTask.gantt');return false;" class="button textual icon requireWrite " title="向下移动"><span class="teamworkIcon">j</span></button>
<span class="ganttButtonSeparator requireWrite "></span>
<button onclick="$('#workSpace').trigger('deleteFocused.gantt');return false;" class="button textual icon delete requireWrite" title="删除事项"><span class="fa fa-trash-o fa-lg" style="color:#34495e;">&nbsp;</span></button>
<button onclick="$('#workSpace').trigger('deleteFocused.gantt');return false;" class="button textual icon requireWrite" title="隐藏事项"><span class="fa fa-ban fa-lg" style="color:#34495e;">&nbsp;</span></button>
<button onclick="$('#workSpace').trigger('hideFocused.gantt');return false;" class="button textual icon requireWrite" title="隐藏事项"><span class="fa fa-ban fa-lg" style="color:#34495e;">&nbsp;</span></button>
<button onclick="show_be_hidden_list();" class="button textual icon requireWrite" title="隐藏的事项列表"><span class="fa fa-eye fa-lg" style="color:#34495e;">&nbsp;</span></button>
<span class="ganttButtonSeparator"></span>
{% if (projectPermArr['ADMIN_GANTT'] is defined and projectPermArr['ADMIN_GANTT'] =='1') %} {% endif %}
Expand Down
2 changes: 1 addition & 1 deletion config.tpl.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Masterlab主配置文件
app_url: ''
version: '3.2.1'
version: '3.3'
error_reporting: 'E_ERROR'
xdebug: false
trace: false
Expand Down
2 changes: 1 addition & 1 deletion config.travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Masterlab主配置文件
app_url: ''
version: '3.2.1'
version: '3.3'
error_reporting: 'E_ERROR'
xdebug: false
trace: false
Expand Down
2 changes: 1 addition & 1 deletion config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Masterlab主配置文件
app_url: ''
version: '3.2.1'
version: '3.3'
error_reporting: 'E_ERROR'
xdebug: false
trace: false
Expand Down
22 changes: 21 additions & 1 deletion public/dev/js/project/gantt_ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -617,8 +617,28 @@ var Gantt = (function () {
});
};

Gantt.prototype.deleteTask = function(taskId, params ) {
Gantt.prototype.deleteTask = function(issue_id ) {
$.ajax({
type: 'post',
dataType: "json",
async: true,
url: root_url + "issue/main/delete",
data: { issue_id: issue_id },
success: function (resp) {
auth_check(resp);
if (resp.ret != '200') {
notify_error('删除失败:' + resp.msg);
return;
}
notify_success('操作成功');
},
error: function (res) {
notify_error("请求数据错误" + res);
}
});
};

Gantt.prototype.hideTask = function(taskId, params ) {
$.ajax({
type: 'post',
dataType: "json",
Expand Down
79 changes: 77 additions & 2 deletions public/dev/lib/jQueryGantt/ganttMaster.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,39 @@ GanttMaster.prototype.init = function (workSpace) {

//bindings
workSpace.bind("deleteFocused.gantt", function (e) {
//delete task or link?
swal({
title: "您确定删除该事项吗?",
text: "你将无法恢复它",
html: true,
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "确 定",
cancelButtonText: "取 消!",
closeOnConfirm: false,
closeOnCancel: false
},
function (isConfirm) {
if (isConfirm) {
swal.close();
var focusedSVGElement=self.gantt.element.find(".focused.focused.linkGroup");
if (focusedSVGElement.size()>0)
self.removeLink(focusedSVGElement.data("from"), focusedSVGElement.data("to"));
else
self.deleteCurrentTask();
} else {
swal.close();
}
});

}).bind("hideFocused.gantt", function (e) {
//delete task or link?
var focusedSVGElement=self.gantt.element.find(".focused.focused.linkGroup");
if (focusedSVGElement.size()>0)
self.removeLink(focusedSVGElement.data("from"), focusedSVGElement.data("to"));
else
self.deleteCurrentTask();
self.hideCurrentTask();
}).bind("showAddAboveCurrentTask.gantt", function () {
self.showAddAboveCurrentTask();
}).bind("showAddBelowCurrentTask.gantt", function () {
Expand Down Expand Up @@ -1212,7 +1239,7 @@ GanttMaster.prototype.deleteCurrentTask = function (taskId) {
var row = task.getRow();
if (task && (row > 0 || self.isMultiRoot || task.isNew()) ) {
if(!task.isNew() && task.name!=''){
window.$_gantAjax.deleteTask(task.id, {gant_hide:1});
window.$_gantAjax.deleteTask(task.id);
}

var par = task.getParent();
Expand Down Expand Up @@ -1243,6 +1270,54 @@ GanttMaster.prototype.deleteCurrentTask = function (taskId) {
};


GanttMaster.prototype.hideCurrentTask = function (taskId) {
//console.debug("hideCurrentTask",this.currentTask , this.isMultiRoot)
var self = this;

var task;
if (taskId)
task=self.getTask(taskId);
else
task=self.currentTask;

if (!task || !self.permissions.canDelete && !task.canDelete)
return;

var taskIsEmpty=task.name=="";

var row = task.getRow();
if (task && (row > 0 || self.isMultiRoot || task.isNew()) ) {
if(!task.isNew() && task.name!=''){
window.$_gantAjax.hideTask(task.id, {gant_hide:1});
}

var par = task.getParent();
self.beginTransaction();
task.deleteTask();
task = undefined;

//recompute depends string
self.updateDependsStrings();

//redraw
self.taskIsChanged();

//[expand]
if (par)
self.editor.refreshExpandStatus(par);


//focus next row
row = row > self.tasks.length - 1 ? self.tasks.length - 1 : row;
if (!taskIsEmpty && row >= 0) {
task = self.tasks[row];
task.rowElement.click();
task.rowElement.find("[name=name]").focus();
}
self.endTransaction();
}
};



GanttMaster.prototype.collapseAll = function () {
Expand Down
2 changes: 1 addition & 1 deletion resource/bt/config.bt.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Masterlab主配置文件
app_url: ''
version: '3.2.1'
version: '3.3'
error_reporting: 'E_ERROR'
xdebug: false
trace: false
Expand Down

0 comments on commit 0c60efa

Please sign in to comment.