improvements of column-based sorting
This commit is contained in:
		
							parent
							
								
									7113369fca
								
							
						
					
					
						commit
						3bbda09f84
					
				
					 6 changed files with 27 additions and 5 deletions
				
			
		|  | @ -92,6 +92,8 @@ class DialogAction(Action): | |||
|             urlParams['fixed_type'] = 'yes' | ||||
|         if self.viewTitle: | ||||
|             urlParams['view_title'] = self.viewTitle | ||||
|         for k, v in self.page.sortInfo.items(): | ||||
|             urlParams['sortinfo_' + k] = v['fparam'] | ||||
|         urlParams.update(self.addParams) | ||||
|         if self.target is not None: | ||||
|             url = self.page.getUrlForTarget(self.target) | ||||
|  |  | |||
|  | @ -145,7 +145,8 @@ class SortableMixin(object): | |||
|                 else: | ||||
|                     fn = v | ||||
|                     dir = 'asc' | ||||
|                 result[tableName] = dict(colName=fn, ascending=(dir=='asc')) | ||||
|                 result[tableName] = dict( | ||||
|                     colName=fn, ascending=(dir=='asc'), fparam=v) | ||||
|         return result | ||||
| 
 | ||||
|     def isSortableColumn(self, tableName, colName): | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| # | ||||
| #  Copyright (c) 2014 Helmut Merz helmutm@cy55.de | ||||
| #  Copyright (c) 2015 Helmut Merz helmutm@cy55.de | ||||
| # | ||||
| #  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 | ||||
|  | @ -46,6 +46,15 @@ class Field(BaseField): | |||
|         return self.getValue(row) | ||||
| 
 | ||||
| 
 | ||||
| class StringField(Field): | ||||
| 
 | ||||
|     def getSelectValue(self, row): | ||||
|         return self.getValue(row).strip() | ||||
| 
 | ||||
|     def getSortValue(self, row): | ||||
|         return self.getValue(row).strip() | ||||
| 
 | ||||
| 
 | ||||
| class TextField(Field): | ||||
| 
 | ||||
|     format = 'text/restructured' | ||||
|  |  | |||
|  | @ -22,6 +22,7 @@ View class(es) for work items. | |||
| 
 | ||||
| from datetime import date | ||||
| import time | ||||
| from urllib import urlencode | ||||
| from zope import component | ||||
| from zope.app.security.interfaces import IAuthentication, PrincipalLookupError | ||||
| from zope.app.pagetemplate import ViewPageTemplateFile | ||||
|  | @ -657,6 +658,12 @@ class CreateWorkItem(EditObject, BaseTrackView): | |||
|         #notify(ObjectModifiedEvent(obj)) | ||||
|         url = self.view.virtualTargetUrl | ||||
|         #url = self.request.URL | ||||
|         # append sortinfo parameters: | ||||
|         urlParams = {} | ||||
|         for k, v in self.view.sortInfo.items(): | ||||
|             urlParams['sortinfo_' + k] = v['fparam'] | ||||
|         if urlParams: | ||||
|             url = '%s?%s' % (url, urlencode(urlParams)) | ||||
|         self.request.response.redirect(url) | ||||
|         return False | ||||
| 
 | ||||
|  |  | |||
|  | @ -37,7 +37,7 @@ from loops.common import adapted, baseObject | |||
| from loops.expert.browser.export import ResultsConceptCSVExport | ||||
| from loops.expert.browser.report import ReportConceptView | ||||
| from loops.expert.field import Field, TargetField, DateField, StateField, \ | ||||
|                             TextField, HtmlTextField, UrlField | ||||
|                             StringField, TextField, HtmlTextField, UrlField | ||||
| from loops.expert.field import SubReport, SubReportField | ||||
| from loops.expert.field import TrackDateField, TrackTimeField | ||||
| from loops.expert.field import WorkItemStateField | ||||
|  | @ -152,10 +152,10 @@ party = TargetField('userName', u'Party', | |||
|                 description=u'The party (usually a person) who did the work.', | ||||
|                 fieldType='selection', | ||||
|                 executionSteps=['query', 'sort', 'output']) | ||||
| workTitle = Field('title', u'Title', | ||||
| workTitle = StringField('title', u'Title', | ||||
|                 description=u'The short description of the work.', | ||||
|                 executionSteps=['sort', 'output']) | ||||
| workDescription = Field('description', u'Description', | ||||
| workDescription = StringField('description', u'Description', | ||||
|                 description=u'The long description of the work.', | ||||
|                 executionSteps=['output']) | ||||
| duration = DurationField('duration', u'Duration', | ||||
|  |  | |||
|  | @ -74,6 +74,9 @@ | |||
|       <input type="hidden" name="form.action" value="create_workitem" /> | ||||
|       <input type="hidden" name="id" | ||||
|              tal:attributes="value request/form/id|nothing" /> | ||||
|       <p tal:content="view/sortInfo/results/fparam|string:???" /> | ||||
|       <input type="hidden" name="sortinfo_results" | ||||
|              tal:attributes="value view/sortInfo/results/fparam|nothing" /> | ||||
|       <div class="heading" i18n:translate="">Add Work Item</div> | ||||
|       <div> | ||||
|         <tal:type condition="view/showTypes"> | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue