improve multiple add dialog, populate parent's depends on with child tasks (#13142)
This commit is contained in:
parent
89795c3f69
commit
4417cb0006
@ -69,6 +69,7 @@ class Task(NestedSet):
|
|||||||
self.reschedule_dependent_tasks()
|
self.reschedule_dependent_tasks()
|
||||||
self.update_project()
|
self.update_project()
|
||||||
self.unassign_todo()
|
self.unassign_todo()
|
||||||
|
self.populate_depends_on()
|
||||||
|
|
||||||
def unassign_todo(self):
|
def unassign_todo(self):
|
||||||
if self.status == "Closed" or self.status == "Cancelled":
|
if self.status == "Closed" or self.status == "Cancelled":
|
||||||
@ -137,6 +138,16 @@ class Task(NestedSet):
|
|||||||
if project_user:
|
if project_user:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def populate_depends_on(self):
|
||||||
|
if self.parent_task:
|
||||||
|
parent = frappe.get_doc('Task', self.parent_task)
|
||||||
|
parent.append("depends_on", {
|
||||||
|
"doctype": "Task Depends On",
|
||||||
|
"task": self.name,
|
||||||
|
"subject": self.subject
|
||||||
|
})
|
||||||
|
parent.save()
|
||||||
|
|
||||||
def on_trash(self):
|
def on_trash(self):
|
||||||
if check_if_child_exists(self.name):
|
if check_if_child_exists(self.name):
|
||||||
throw(_("Child Task exists for this Task. You can not delete this Task."))
|
throw(_("Child Task exists for this Task. You can not delete this Task."))
|
||||||
@ -216,12 +227,12 @@ def add_node():
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def add_multiple_tasks(data, parent):
|
def add_multiple_tasks(data, parent):
|
||||||
data = json.loads(data)['tasks']
|
data = json.loads(data)
|
||||||
tasks = data.split('\n')
|
new_doc = {'doctype': 'Task', 'parent_task': parent if parent!="All Tasks" else ""}
|
||||||
new_doc = {'doctype': 'Task', 'parent_task': parent}
|
new_doc['project'] = frappe.db.get_value('Task', {"name": parent}, 'project') or ""
|
||||||
new_doc['project'] = frappe.db.get_value('Task', {"name": parent}, 'project')
|
|
||||||
|
|
||||||
for d in tasks:
|
for d in data:
|
||||||
new_doc['subject'] = d
|
if not d.get("subject"): continue
|
||||||
|
new_doc['subject'] = d.get("subject")
|
||||||
new_task = frappe.get_doc(new_doc)
|
new_task = frappe.get_doc(new_doc)
|
||||||
new_task.insert()
|
new_task.insert()
|
||||||
|
@ -44,23 +44,39 @@ frappe.treeview_settings['Task'] = {
|
|||||||
return node.expandable;
|
return node.expandable;
|
||||||
},
|
},
|
||||||
click: function(node) {
|
click: function(node) {
|
||||||
var d = new frappe.ui.Dialog({
|
this.data = [];
|
||||||
'fields': [
|
const dialog = new frappe.ui.Dialog({
|
||||||
{'fieldname': 'tasks', 'label': 'Tasks', 'fieldtype': 'Text'},
|
title: __("Add Multiple Tasks"),
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
fieldname: "multiple_tasks", fieldtype: "Table",
|
||||||
|
in_place_edit: true, data: this.data,
|
||||||
|
get_data: () => {
|
||||||
|
return this.data;
|
||||||
|
},
|
||||||
|
fields: [{
|
||||||
|
fieldtype:'Data',
|
||||||
|
fieldname:"subject",
|
||||||
|
in_list_view: 1,
|
||||||
|
reqd: 1,
|
||||||
|
label: __("Subject")
|
||||||
|
}]
|
||||||
|
},
|
||||||
],
|
],
|
||||||
primary_action: function() {
|
primary_action: function() {
|
||||||
d.hide();
|
dialog.hide();
|
||||||
return frappe.call({
|
return frappe.call({
|
||||||
method: "erpnext.projects.doctype.task.task.add_multiple_tasks",
|
method: "erpnext.projects.doctype.task.task.add_multiple_tasks",
|
||||||
args: {
|
args: {
|
||||||
data: d.get_values(),
|
data: dialog.get_values()["multiple_tasks"],
|
||||||
parent: node.data.value
|
parent: node.data.value
|
||||||
},
|
},
|
||||||
callback: function() { }
|
callback: function() { }
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
|
primary_action_label: __('Create')
|
||||||
});
|
});
|
||||||
d.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user