move JS generation to Python; reset date/time when selecting 'finish' in state 'done'
This commit is contained in:
parent
b87dee5c35
commit
db4f7d15a9
3 changed files with 37 additions and 10 deletions
|
@ -56,6 +56,15 @@ function setIfIn(node, conditions) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setIf(node, cond, acts) {
|
||||||
|
if (node.value == cond) {
|
||||||
|
dojo.forEach(acts, function(act) {
|
||||||
|
target = dijit.byId(act[0]);
|
||||||
|
target.setValue(act[1]);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function destroyWidgets(node) {
|
function destroyWidgets(node) {
|
||||||
dojo.forEach(dojo.query('[widgetId]', node), function(n) {
|
dojo.forEach(dojo.query('[widgetId]', node), function(n) {
|
||||||
w = dijit.byNode(n);
|
w = dijit.byNode(n);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2015 Helmut Merz helmutm@cy55.de
|
# Copyright (c) 2016 Helmut Merz helmutm@cy55.de
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -606,6 +606,32 @@ class CreateWorkItemForm(ObjectForm, BaseTrackView):
|
||||||
def comment(self):
|
def comment(self):
|
||||||
return self.track.comment or u''
|
return self.track.comment or u''
|
||||||
|
|
||||||
|
def onChangeAction(self):
|
||||||
|
js = [self.actionJs['setDefault'],
|
||||||
|
self.actionJs['showIf'],
|
||||||
|
self.actionJs['setIfStart']]
|
||||||
|
if self.state in ('done',):
|
||||||
|
js.append(self.actionJs['setIfFinish'])
|
||||||
|
return ';\n'.join(js)
|
||||||
|
|
||||||
|
actionJs = dict(setDefault="defValue = this.form.default_date.value",
|
||||||
|
showIf="""
|
||||||
|
showIfIn(this, [['move', 'target_task'],
|
||||||
|
['delegate', 'target_party']])""",
|
||||||
|
setIfStart="""
|
||||||
|
setIf(this, 'start', [['start_date', defValue],
|
||||||
|
['start_time', defValue],
|
||||||
|
['end_time', null],
|
||||||
|
['duration', ''],
|
||||||
|
['effort', '']])""",
|
||||||
|
setIfFinish="""
|
||||||
|
setIf(this, 'finish', [['start_date', defValue],
|
||||||
|
['start_time', defValue],
|
||||||
|
['end_time', defValue],
|
||||||
|
['duration', ''],
|
||||||
|
['effort', '']])""",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class CreateWorkItem(EditObject, BaseTrackView):
|
class CreateWorkItem(EditObject, BaseTrackView):
|
||||||
|
|
||||||
|
|
|
@ -120,15 +120,7 @@
|
||||||
<div>
|
<div>
|
||||||
<label i18n:translate="" for="action">Action</label>
|
<label i18n:translate="" for="action">Action</label>
|
||||||
<select name="workitem.action" id="action"
|
<select name="workitem.action" id="action"
|
||||||
onChange="showIfIn(this, [['move', 'target_task'],
|
tal:attributes="onChange view/onChangeAction">
|
||||||
['delegate', 'target_party']]);
|
|
||||||
setIfIn(this, [['start', 'start_date',
|
|
||||||
this.form.default_date.value],
|
|
||||||
['start', 'start_time',
|
|
||||||
this.form.default_date.value],
|
|
||||||
['start', 'end_time', null],
|
|
||||||
['start', 'duration', ''],
|
|
||||||
['start', 'effort', '']])">
|
|
||||||
<option tal:repeat="action view/actions"
|
<option tal:repeat="action view/actions"
|
||||||
tal:attributes="value action/name;
|
tal:attributes="value action/name;
|
||||||
selected action/selected"
|
selected action/selected"
|
||||||
|
|
Loading…
Add table
Reference in a new issue