set date/time fields correctly when selecting 'start' action
This commit is contained in:
		
							parent
							
								
									b34b5705e0
								
							
						
					
					
						commit
						4c13744a0c
					
				
					 3 changed files with 32 additions and 1 deletions
				
			
		| 
						 | 
					@ -47,6 +47,15 @@ function showIfIn(node, conditions) {
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function setIfIn(node, conditions) {
 | 
				
			||||||
 | 
					    dojo.forEach(conditions, function(cond) {
 | 
				
			||||||
 | 
					        if (node.value == cond[0]) {
 | 
				
			||||||
 | 
					            target = dojo.byId(cond[1]);
 | 
				
			||||||
 | 
					            target.value = cond[2];
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    })
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -476,6 +476,16 @@ class CreateWorkItemForm(ObjectForm, BaseTrackView):
 | 
				
			||||||
            return getTimeStamp()
 | 
					            return getTimeStamp()
 | 
				
			||||||
        return None
 | 
					        return None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Lazy
 | 
				
			||||||
 | 
					    def defaultDate(self):
 | 
				
			||||||
 | 
					        return format.formatDate(date.today(), 'date', 'medium',
 | 
				
			||||||
 | 
					                                 self.languageInfo.language)
 | 
				
			||||||
 | 
					        #return time.strftime('%Y-%m-%d', time.localtime(getTimeStamp()))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Lazy
 | 
				
			||||||
 | 
					    def defaultTime(self):
 | 
				
			||||||
 | 
					        return time.strftime('%H:%M', time.localtime(getTimeStamp()))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Lazy
 | 
					    @Lazy
 | 
				
			||||||
    def date(self):
 | 
					    def date(self):
 | 
				
			||||||
        ts = self.track.start or self.defaultTimeStamp
 | 
					        ts = self.track.start or self.defaultTimeStamp
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -120,12 +120,21 @@
 | 
				
			||||||
        <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'],
 | 
					                onChange="showIfIn(this, [['move', 'target_task'],
 | 
				
			||||||
                                          ['delegate', 'target_party']])">
 | 
					                                          ['delegate', 'target_party']]);
 | 
				
			||||||
 | 
					                          setIfIn(this, [['start', 'start_date', 
 | 
				
			||||||
 | 
					                                                 this.form.default_date.value],
 | 
				
			||||||
 | 
					                                         ['start', 'start_time', 
 | 
				
			||||||
 | 
					                                                 this.form.default_time.value],
 | 
				
			||||||
 | 
					                                         ['start', 'end_time', '']])">
 | 
				
			||||||
          <option tal:repeat="action view/actions"
 | 
					          <option tal:repeat="action view/actions"
 | 
				
			||||||
                  tal:attributes="value action/name"
 | 
					                  tal:attributes="value action/name"
 | 
				
			||||||
                  tal:content="action/title"
 | 
					                  tal:content="action/title"
 | 
				
			||||||
                  i18n:translate="" />
 | 
					                  i18n:translate="" />
 | 
				
			||||||
        </select>
 | 
					        </select>
 | 
				
			||||||
 | 
					        <input type="hidden" name="default_date" id="default_date"
 | 
				
			||||||
 | 
					               tal:attributes="value view/defaultDate" />
 | 
				
			||||||
 | 
					        <input type="hidden" name="default_time" id="default_time"
 | 
				
			||||||
 | 
					               tal:attributes="value view/defaultTime" />
 | 
				
			||||||
        <span id="target_party" style="display: none"> 
 | 
					        <span id="target_party" style="display: none"> 
 | 
				
			||||||
          <label i18n:translate="delegate_to_party" for="input_party"
 | 
					          <label i18n:translate="delegate_to_party" for="input_party"
 | 
				
			||||||
                 style="display: inline">to</label>
 | 
					                 style="display: inline">to</label>
 | 
				
			||||||
| 
						 | 
					@ -212,12 +221,15 @@
 | 
				
			||||||
        <label i18n:translate="" for="start-end-input">Start - End</label>
 | 
					        <label i18n:translate="" for="start-end-input">Start - End</label>
 | 
				
			||||||
        <div id="start-end-input">
 | 
					        <div id="start-end-input">
 | 
				
			||||||
          <input type="text" name="start_date" style="width: 8em"
 | 
					          <input type="text" name="start_date" style="width: 8em"
 | 
				
			||||||
 | 
					                 id="start_date"
 | 
				
			||||||
                 dojoType="dijit.form.DateTextBox"
 | 
					                 dojoType="dijit.form.DateTextBox"
 | 
				
			||||||
                 tal:attributes="value view/date" />
 | 
					                 tal:attributes="value view/date" />
 | 
				
			||||||
          <input type="text" name="start_time" style="width: 6em"
 | 
					          <input type="text" name="start_time" style="width: 6em"
 | 
				
			||||||
 | 
					                 id="start_time"
 | 
				
			||||||
                 dojoType="dijit.form.TimeTextBox"
 | 
					                 dojoType="dijit.form.TimeTextBox"
 | 
				
			||||||
                 tal:attributes="value view/startTime" /> -
 | 
					                 tal:attributes="value view/startTime" /> -
 | 
				
			||||||
          <input type="text" name="end_time" style="width: 6em"
 | 
					          <input type="text" name="end_time" style="width: 6em"
 | 
				
			||||||
 | 
					                 id="end_time"
 | 
				
			||||||
                 dojoType="dijit.form.TimeTextBox"
 | 
					                 dojoType="dijit.form.TimeTextBox"
 | 
				
			||||||
                 tal:attributes="value view/endTime" /></div>
 | 
					                 tal:attributes="value view/endTime" /></div>
 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue