new fields: priority, activity
This commit is contained in:
		
							parent
							
								
									2c112703a3
								
							
						
					
					
						commit
						beff6ef2dd
					
				
					 3 changed files with 71 additions and 14 deletions
				
			
		|  | @ -524,7 +524,10 @@ class CreateWorkItemForm(ObjectForm, BaseTrackView): | |||
|         return [dict(name=util.getUidForObject(p), title=p.title) | ||||
|                     for p in persons] | ||||
| 
 | ||||
|     taskTypes = ['task', 'event', 'agendaitem'] | ||||
|     @Lazy | ||||
|     def taskTypes(self): | ||||
|         return (self.globalOptions('organize.work.task_types') or | ||||
|                 ['task', 'event', 'agendaitem']) | ||||
| 
 | ||||
|     @Lazy | ||||
|     def followUpTask(self): | ||||
|  | @ -544,6 +547,16 @@ class CreateWorkItemForm(ObjectForm, BaseTrackView): | |||
|         return [dict(name=util.getUidForObject(t), title=t.title) | ||||
|                     for t in tasks] | ||||
| 
 | ||||
|     @Lazy | ||||
|     def priorities(self): | ||||
|         prio = self.conceptManager.get('organize.work.priorities') | ||||
|         return prio and adapted(prio).dataAsRecords or [] | ||||
| 
 | ||||
|     @Lazy | ||||
|     def activities(self): | ||||
|         act = self.conceptManager.get('organize.work.activities') | ||||
|         return act and adapted(act).dataAsRecords or [] | ||||
| 
 | ||||
|     @Lazy | ||||
|     def duration(self): | ||||
|         if self.state == 'running': | ||||
|  | @ -610,6 +623,8 @@ class CreateWorkItem(EditObject, BaseTrackView): | |||
|             result['deadline'] = parseDateTime('T'.join((deadline, deadlineTime))) | ||||
|         else: | ||||
|             result['deadline'] = None | ||||
|         result['priority'] = form.get('priority') | ||||
|         result['activity'] = form.get('activity') | ||||
|         startDate = form.get('start_date', '').strip() | ||||
|         endDate = form.get('end_date', '').strip() or startDate | ||||
|         startTime = form.get('start_time', '').strip().replace('T', '') or '00:00:00' | ||||
|  |  | |||
|  | @ -150,7 +150,6 @@ | |||
|                       view.getUidForObject(view.followUpTask)" /> | ||||
|         </span> | ||||
|       </div> | ||||
|       <div> | ||||
|       <div id="deadline" | ||||
|            tal:condition="python:'deadline' in workItemType.fields"> | ||||
|         <label i18n:translate="" for="deadline-input">Deadline</label> | ||||
|  | @ -163,6 +162,36 @@ | |||
|                  tal:condition="view/deadlineWithTime" | ||||
|                  tal:attributes="value view/deadlineTime" /> | ||||
|         </div> | ||||
|         <div id="priority-activity" | ||||
|              tal:condition="python:'priority' in workItemType.fields or | ||||
|                                    'activity' in workItemType.fields"> | ||||
|           <table style="width: auto"> | ||||
|             <tr> | ||||
|               <td tal:condition="python:'priority' in workItemType.fields"> | ||||
|                 <label i18n:translate="" for="priority">Priority</label></td> | ||||
|               <td tal:condition="python:'activity' in workItemType.fields"> | ||||
|                 <label i18n:translate="" for="activity">Activity</label></td> | ||||
|             </tr> | ||||
|             <tr> | ||||
|               <td tal:condition="python:'priority' in workItemType.fields"> | ||||
|                 <select name="priority" id="priority" | ||||
|                         tal:define="value view/track/data/priority|nothing"> | ||||
|                   <option tal:repeat="prio view/priorities" | ||||
|                           tal:attributes="value prio/name; | ||||
|                                           selected python:prio['name'] == value" | ||||
|                           tal:content="prio/title" /> | ||||
|                 </select> | ||||
|               </td> | ||||
|               <td tal:condition="python:'activity' in workItemType.fields"> | ||||
|                 <select name="activity" id="activity" | ||||
|                         tal:define="value view/track/data/activity|nothing"> | ||||
|                   <option tal:repeat="act view/activities" | ||||
|                           tal:attributes="value act/name; | ||||
|                                           selected python:act['name'] == value" | ||||
|                           tal:content="act/title" /> | ||||
|                 </select> | ||||
|               </td> | ||||
|           </table> | ||||
|         </div> | ||||
|         <div id="start-end" | ||||
|              tal:condition="python:'start-end' in workItemType.fields"> | ||||
|  |  | |||
							
								
								
									
										13
									
								
								table.py
									
										
									
									
									
								
							
							
						
						
									
										13
									
								
								table.py
									
										
									
									
									
								
							|  | @ -93,6 +93,19 @@ class DataTable(AdapterBase): | |||
|         self.context._data = OOBTree(data) | ||||
|     data = property(getData, setData) | ||||
| 
 | ||||
|     @property | ||||
|     def dataAsRecords(self): | ||||
|         result = [] | ||||
|         for k, v in sorted(self.data.items()): | ||||
|             item = {} | ||||
|             for idx, c in enumerate(self.columns): | ||||
|                 if idx == 0: | ||||
|                     item[c] = k | ||||
|                 else: | ||||
|                     item[c] = v[idx-1] | ||||
|             result.append(item) | ||||
|         return result | ||||
| 
 | ||||
| 
 | ||||
| TypeInterfaceSourceList.typeInterfaces += (IDataTable,) | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue