From 4a69a3beb2601d4f2bb31e1817d3e282c345aafe Mon Sep 17 00:00:00 2001 From: Gaetan Delannay Date: Wed, 31 Oct 2012 21:17:31 +0100 Subject: [PATCH] [gen] For Strings with validator=String.URL, an HTML link is rendered in view layouts; added a 'real' 'state' field to any Appy class, allowing to use it in search screens for example; added 2 hook methods: getIcons and getSubTitles, allowing to add, in lists of objects (Refs or queries), icons besides the title and anything below it; optimized query.pt: for every new query, 1 server request is done (previously, one standard request + one ajax request were done); removed columns 'actions' (Refs, query): action icons are not included in the column containing the title (we avoid having empty columns whhen no action is available). --- gen/__init__.py | 3 ++ gen/generator.py | 2 - gen/mixins/ToolMixin.py | 5 ++ gen/mixins/__init__.py | 26 +++++---- gen/po.py | 2 - gen/ui/appy.css | 9 ++-- gen/ui/appy.js | 20 +++++++ gen/ui/arrowDown.png | Bin 232 -> 234 bytes gen/ui/arrowUp.png | Bin 232 -> 234 bytes gen/ui/delete.png | Bin 239 -> 231 bytes gen/ui/edit.gif | Bin 476 -> 470 bytes gen/ui/import.pt | 4 +- gen/ui/navigate.pt | 6 +++ gen/ui/page.pt | 6 ++- gen/ui/query.pt | 9 +--- gen/ui/result.pt | 113 ++++++++++++++++----------------------- gen/ui/toggleDetails.png | Bin 0 -> 250 bytes gen/ui/unlink.png | Bin 239 -> 231 bytes gen/ui/widgets/ref.pt | 58 ++++++++++---------- gen/ui/widgets/string.pt | 10 +++- 20 files changed, 142 insertions(+), 131 deletions(-) create mode 100644 gen/ui/toggleDetails.png diff --git a/gen/__init__.py b/gen/__init__.py index ef0071d..a887d93 100644 --- a/gen/__init__.py +++ b/gen/__init__.py @@ -1157,6 +1157,7 @@ class String(Type): # field of format CAPTCHA by page, because the captcha challenge is # stored in the session at some global key. self.format = format + self.isUrl = validator == String.URL # When format is XHTML, the list of styles that the user will be able to # select in the styles dropdown is defined hereafter. self.styles = styles @@ -1225,6 +1226,8 @@ class String(Type): return {'view': 'l-f', 'edit': 'lrv-f'} def getValue(self, obj): + # Cheat if this field represents p_obj's state + if self.name == 'state': return obj.State() value = Type.getValue(self, obj) if not value: if self.isMultiValued(): return emptyTuple diff --git a/gen/generator.py b/gen/generator.py index 0fd6baf..86e2346 100644 --- a/gen/generator.py +++ b/gen/generator.py @@ -404,7 +404,6 @@ class ZopeGenerator(Generator): msg('modified_field', '', msg.MODIFIED_FIELD), msg('previous_value', '', msg.PREVIOUS_VALUE), msg('phase', '', msg.PHASE), - msg('root_type', '', msg.ROOT_TYPE), msg('workflow_comment', '', msg.WORKFLOW_COMMENT), msg('choose_a_value', '', msg.CHOOSE_A_VALUE), msg('choose_a_doc', '', msg.CHOOSE_A_DOC), @@ -412,7 +411,6 @@ class ZopeGenerator(Generator): msg('max_ref_violated', '', msg.MAX_REF_VIOLATED), msg('no_ref', '', msg.REF_NO), msg('add_ref', '', msg.REF_ADD), - msg('ref_actions', '', msg.REF_ACTIONS), msg('action_ok', '', msg.ACTION_OK), msg('action_ko', '', msg.ACTION_KO), msg('move_up', '', msg.REF_MOVE_UP), diff --git a/gen/mixins/ToolMixin.py b/gen/mixins/ToolMixin.py index 0cc4efb..a028336 100644 --- a/gen/mixins/ToolMixin.py +++ b/gen/mixins/ToolMixin.py @@ -545,6 +545,11 @@ class ToolMixin(BaseMixin): appyType = self.getAppyType(name, className=className) if appyType: return appyType.isSortable(usage=usage) + def subTitleIsUsed(self, className): + '''Does class named p_className define a method "getSubTitle"?''' + klass = self.getAppyClass(className) + return hasattr(klass, 'getSubTitle') + def _searchValueIsEmpty(self, key): '''Returns True if request value in key p_key can be considered as empty.''' diff --git a/gen/mixins/__init__.py b/gen/mixins/__init__.py index 11eb33f..79c36b1 100644 --- a/gen/mixins/__init__.py +++ b/gen/mixins/__init__.py @@ -687,17 +687,11 @@ class BaseMixin: '''Gets the Appy types named p_fieldNames.''' res = [] for name in fieldNames: - if name == 'state': - # We do not return a appyType if the attribute is not a *real* - # attribute, but the workfow state. - res.append({'name': name, 'labelId': 'workflow_state', - 'filterable': False}) + appyType = self.getAppyType(name, asDict) + if appyType: res.append(appyType) else: - appyType = self.getAppyType(name, asDict) - if appyType: res.append(appyType) - else: - self.log('Field "%s", used as shownInfo in a Ref, ' \ - 'was not found.' % name, type='warning') + self.log('Field "%s", used as shownInfo in a Ref, ' \ + 'was not found.' % name, type='warning') return res def getAppyStates(self, phase, currentOnly=False): @@ -820,6 +814,18 @@ class BaseMixin: else: return res + def getIcons(self): + '''Gets the icons that can be shown besides the title of an object.''' + appyObj = self.appy() + if hasattr(appyObj, 'getIcons'): return appyObj.getIcons() + return '' + + def getSubTitle(self): + '''Gets the content that must appear below the title of an object.''' + appyObj = self.appy() + if hasattr(appyObj, 'getSubTitle'): return appyObj.getSubTitle() + return '' + def getPreviousPage(self, phase, page): '''Returns the page that precedes p_page which is in p_phase.''' try: diff --git a/gen/po.py b/gen/po.py index a108de2..4073fbe 100644 --- a/gen/po.py +++ b/gen/po.py @@ -40,7 +40,6 @@ class PoMessage: POD_ASKACTION = 'Trigger related action' REF_NO = 'No object.' REF_ADD = 'Add a new one' - REF_ACTIONS = 'Actions' REF_MOVE_UP = 'Move up' REF_MOVE_DOWN = 'Move down' REF_INVALID_INDEX = 'No move occurred: please specify a valid number.' @@ -69,7 +68,6 @@ class PoMessage: MODIFIED_FIELD = 'Modified field' PREVIOUS_VALUE = 'Previous value' PHASE = 'phase' - ROOT_TYPE = 'type' CHOOSE_A_VALUE = ' - ' CHOOSE_A_DOC = '[ Documents ]' MIN_REF_VIOLATED = 'You must choose more elements here.' diff --git a/gen/ui/appy.css b/gen/ui/appy.css index 1bcce9b..df31790 100644 --- a/gen/ui/appy.css +++ b/gen/ui/appy.css @@ -92,11 +92,12 @@ img { border: 0; vertical-align: middle} .list { border: 1px solid grey; margin-bottom: 3px;} .list td, .list th { border: 1px solid grey; padding-left: 5px; padding-right: 5px; padding-top: 3px;} -.list th { background-color: #d7dee4; font-style: italic; font-weight: normal;} +.list th { background-color: #d7dee4; font-style: italic; font-weight: normal; + text-align: left } .grid th { font-style: italic; font-weight: normal; - border-bottom: 2px solid grey; padding: 2px 2px;} -.grid td { padding-right: 5px; } -.cellGap { padding-right: 0.4em; } + border-bottom: 2px solid grey; padding: 2px 2px } +.grid td { padding-right: 5px } +.cellGap { padding-right: 0.4em } .cellDashed { border: 1px dashed grey !important } .noStyle { border: 0 !important; padding: 0 !important; margin: 0 !important; } .noStyle td { border:0 !important; padding:0 !important; margin:0 !important; } diff --git a/gen/ui/appy.js b/gen/ui/appy.js index 0dc007d..a579491 100644 --- a/gen/ui/appy.js +++ b/gen/ui/appy.js @@ -200,6 +200,26 @@ function toggleCheckbox(visibleCheckbox, hiddenBoolean) { else hidden.value = 'False'; } +// Function that sets a value for showing/hiding sub-titles. +function setSubTitles(value) { + createCookie('showSubTitles', value); + // Get the sub-titles + var subTitles = document.getElementsByName('subTitle'); + if (subTitles.length == 0) return; + for (var i=0; i < subTitles.length; i++) { + if (value == 'true') subTitles[i].style.display = 'block'; + else subTitles[i].style.display = 'none'; + } +} + +// Function that toggles the value for showing/hiding sub-titles. +function toggleSubTitles() { + var value = readCookie('showSubTitles'); + var newValue = 'true'; + if (value == 'true') newValue = 'false'; + setSubTitles(newValue); +} + // Functions used for master/slave relationships between widgets function getSlaveInfo(slave, infoType) { // Returns the appropriate info about slavery, depending on p_infoType. diff --git a/gen/ui/arrowDown.png b/gen/ui/arrowDown.png index dbfc3c5c31fa645e29f8cf1ba204ef6aa2f4a61f..262e0a1b359a7504f1015566d7a297c718de865d 100644 GIT binary patch delta 130 zcmaFC_=-`nGr-TCmrII^fq{Y7)59eQL<6w^6El$9a8`EJL`6~FS=$+OqYeeMzqkE* zjAf#;1=k%ed47JrhI#Rs6I*pGRXklBLpZJ{Cmi68kaUrdu#i=fkeI e%HhUXW`@LXOdBWircDPL%i!ti=d#Wzp$P!r0wo;) delta 128 zcmaFG_<~WfGr-TCmrII^fq{Y7)59eQNOJ=*9}_c>Y~kl)o2V$t+q|7YH|kJ8`+M7I zMtT#SEx2xSi*pKVNEBpGpV+EnuH@Y~kl)o2V$t+rFJaH|kJ8`}>5d zWTlDD7F;*E#W{s7iw=0FPHfdNSMqdm4B@z*oZ!IDn+a diff --git a/gen/ui/delete.png b/gen/ui/delete.png index f577d4c0948e9bc28b09b5e98dff6af53ced2d93..a0bed4e249b6ef0cff41d53c168553e0350f775c 100644 GIT binary patch delta 91 zcmaFQ_?&Tq8E@-$hLtKRUlJ0|2nDlEbhhN=lIQ185lLaFnAoagrs(P77{YNqIpF}S vgtQt%=Mn}5<4cSl9Yzk335FYV#26U1oMXA5{5`Rb0SG)@{an^LB{Ts5FJ>HD delta 99 zcmaFP_?~fs8Snh<3@cSsz9b}k{WJUJL}yD*RvA78D<#2$J14g4*lBvYIEHXsPfl=P z&Ee7F;aS5QEFmE=nW^EA2fKpeDTdU>qX#x6ltwTx+|6V);n~63!T - + + onClick="toggleCheckboxes()" style="cursor:pointer"> + +Icon for hiding/showing details below the title + + + diff --git a/gen/ui/page.pt b/gen/ui/page.pt index fe6ed92..475277b 100644 --- a/gen/ui/page.pt +++ b/gen/ui/page.pt @@ -206,8 +206,10 @@ Title - + - Arrows for moving objects up or down - Edit + Arrows for moving objects up or down +
+ + +
diff --git a/gen/ui/query.pt b/gen/ui/query.pt index 5517435..032e3ac 100644 --- a/gen/ui/query.pt +++ b/gen/ui/query.pt @@ -3,15 +3,8 @@ -
- Query result -
- - + diff --git a/gen/ui/result.pt b/gen/ui/result.pt index 4e48db3..f1ec24e 100644 --- a/gen/ui/result.pt +++ b/gen/ui/result.pt @@ -1,31 +1,30 @@ - +
- Display here POD templates if required. The title of the search.

- + ()  —  + - Object type, shown if instances of several types are shown -

- Actions - Results - Title +
- Workflow state -
Any other field - - - Column "Actions" -
- -
+ - + Actions: edit, delete +
+ + +
Column "Object type", shown if instances of several types are shown - - - - Edit the element - - Delete the element - - -
- - - - -
-
@@ -154,4 +131,4 @@ tal:content="python: _('search_new')"> - +
diff --git a/gen/ui/toggleDetails.png b/gen/ui/toggleDetails.png new file mode 100644 index 0000000000000000000000000000000000000000..d111dfb02e6b8aa7c5eea51b8e93fa7dbfc1f691 GIT binary patch literal 250 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!93?!50ihlx9jKx9jP7LeL$-D$|I0Jk_Tt&G+ zisDUfZg@WrtfC~yFPOpM*^M-i@+5C}7lsa2Sr3r%0*}aI1_o|n5N2eUHAey{$X?>< z>&kwIOP=4%(4yx5JD`wkiEBiObAE1aYF-J0b5UwyNotBhd1gt5LP$ocg1e`0!21-{ zJfK1oPZ!4!j_b(@4$OQ!Iy^m0JWV`0Ogw!&OgudTifn-g85B;lp7>OdnV4{*fLUl! d595nljI(Q5wtJmk+z-^x;OXk;vd$@?2>^xjLE``b literal 0 HcmV?d00001 diff --git a/gen/ui/unlink.png b/gen/ui/unlink.png index 039d611cd723ff2537863fe8a0c075dfc294a7df..b748e42ece68a91dbd446420c7b08a82b540bd42 100644 GIT binary patch delta 90 zcmaFQ_?&Tq8E@Nmh9CJ1|L59vE#C2CqO%o;JU^!f%gI`yiLE+jik>cxAsp9}6ArLS uNUJe)E@4nGzQpL!VdM~*V7Ng?jDcaxIhG5`-xKQ?fWXt$&t;ucLK6VxOCJOP delta 98 zcmaFP_?~fs8E^Y`h9CJ1|L5Ayy|HHZL}x1wc20Sotws9RCbsI>X?nUihHzX@PH?Mldkk&15y<*}>Yv00f?{elF{r5}E)9 C&LOq{ diff --git a/gen/ui/widgets/ref.pt b/gen/ui/widgets/ref.pt index abc030b..706ad6d 100644 --- a/gen/ui/widgets/ref.pt +++ b/gen/ui/widgets/ref.pt @@ -8,6 +8,7 @@ allows to reach the correct page where the forward reference is defined. If we are on a forward reference, the "nav" parameter is added to the URL for allowing to navigate from one object to the next/previous on ui/view. +
- - Move up - - Move down - - - + + + +
@@ -125,7 +122,8 @@ atMostOneRef python: (appyType['multiplicity'][1] == 1) and (len(objs)<=1); addConfirmMsg python: appyType['addConfirm'] and _('%s_addConfirm' % appyType['labelId']) or ''; navBaseCall python: 'askRefField(\'%s\',\'%s\',\'%s\',\'%s\',**v**)' % (ajaxHookId, contextObj.absolute_url(), fieldName, innerRef); - changeOrder python: contextObj.callField(fieldName, 'changeOrderEnabled', contextObj)" + changeOrder python: contextObj.callField(fieldName, 'changeOrderEnabled', contextObj); + showSubTitles python: request.get('showSubTitles', 'true') == 'true'" tal:attributes="id ajaxHookId"> This macro displays the Reference widget on a "view" page. @@ -181,21 +179,25 @@ + + + - - +
+
+ +
- - - + @@ -203,12 +205,6 @@ - Actions - - - - -
diff --git a/gen/ui/widgets/string.pt b/gen/ui/widgets/string.pt index 1544719..970946a 100644 --- a/gen/ui/widgets/string.pt +++ b/gen/ui/widgets/string.pt @@ -1,13 +1,19 @@ View macro for a String. + tal:define="fmt widget/format; isUrl widget/isUrl">
- + A password ******** + A URL + + Any other value +
Text