[gen] Allow to show transitions on 'view' and/or 'result' layout types.

This commit is contained in:
Gaetan Delannay 2013-03-18 13:13:29 +01:00
parent e0cef5eed5
commit da1f2699cd
7 changed files with 33 additions and 12 deletions

View file

@ -409,16 +409,16 @@ class Calendar(Type):
self.createEvent(obj, date, handleEventSpan=False)
def deleteEvent(self, obj, date, handleEventSpan=True):
'''Deletes an event. It actually deletes all events at rq['day'].
'''Deletes an event. It actually deletes all events at p_date.
If p_handleEventSpan is True, we will use rq["deleteNext"] to
delete successive events, too.'''
obj = obj.o # Ensure p_obj is not a wrapper.
rq = obj.REQUEST
if not self.getEventsAt(obj, date): return
daysDict = getattr(obj, self.name)[date.year()][date.month()]
# Remember events, in case we must delete similar ones for next days.
events = self.getEventsAt(obj, date)
del daysDict[date.day()]
rq = obj.REQUEST
if handleEventSpan and rq.has_key('deleteNext') and \
(rq['deleteNext'] == 'True'):
while True:

View file

@ -1476,6 +1476,19 @@ class BaseMixin:
return stateShow(self.getWorkflow(), self.appy())
return stateShow
def showTransitions(self, layoutType):
'''Must we show the buttons/icons for triggering transitions on
p_layoutType?'''
# Never show transitions on edit pages.
if layoutType == 'edit': return
# Use the default value if self's class does not specify it.
klass = self.getClass()
if not hasattr(klass, 'showTransitions'): return (layoutType=='view')
showValue = klass.showTransitions
# This value can be a single value or a tuple/list of values.
if isinstance(showValue, basestring): return layoutType == showValue
return layoutType in showValue
def _appy_listStates(self):
'''Lists the possible states for this object.'''
res = []

View file

@ -21,7 +21,7 @@ input[type=checkbox] { border: 0; background: none; cursor: pointer }
input[type=radio] { border: 0; background: none; cursor: pointer }
input[type=file] { border: 0px solid #d0d0d0;
background-color: #f8f8f8; cursor: pointer }
input[type=button] { border: 1px solid #d0d0d0;
input[type=button] { border: 1px solid #d0d0d0; margin: 0 3px;
background-color: #f8f8f8; cursor: pointer }
input[type=submit] { border: 1px solid #d0d0d0; background-color: #f8f8f8;
cursor: pointer }

View file

@ -353,14 +353,14 @@ function submitAppyForm(button) {
}
// Function used for triggering a workflow transition
function triggerTransition(transitionId, msg) {
var theForm = document.getElementById('triggerTransitionForm');
function triggerTransition(formId, transitionId, msg) {
var theForm = document.getElementById(formId);
theForm.workflow_action.value = transitionId;
if (!msg) {
theForm.submit();
}
else { // Ask the user to confirm.
askConfirm('form', 'triggerTransitionForm', msg, true);
askConfirm('form', formId, msg, true);
}
}

View file

@ -146,10 +146,10 @@
This macro displays an object's transitions(s). It is used by macro "header" below.
</tal:comment>
<metal:transitions define-macro="transitions"
tal:define="transitions contextObj/getAppyTransitions"
tal:define="transitions targetObj/getAppyTransitions"
tal:condition="transitions">
<form id="triggerTransitionForm" method="post"
tal:attributes="action python: contextObj.absolute_url() + '/do'">
<form tal:define="formId python: 'trigger_%s' % targetObj.UID()" method="post"
tal:attributes="id formId; action python: targetObj.absolute_url() + '/do'">
<input type="hidden" name="action" value="Trigger"/>
<input type="hidden" name="workflow_action"/>
<table>
@ -161,7 +161,7 @@
<tal:comment replace="nothing">Real button</tal:comment>
<input type="button" tal:condition="transition/may_trigger"
tal:attributes="value transition/title;
onClick python: 'triggerTransition(\'%s\',\'%s\')' % (transition['name'],transition['confirm']);"/>
onClick python: 'triggerTransition(\'%s\',\'%s\',\'%s\')' % (formId,transition['name'],transition['confirm'])"/>
<tal:comment replace="nothing">Fake button, explaining why the transition can't be triggered</tal:comment>
<div class="fakeButton" tal:condition="not: transition/may_trigger">
<acronym tal:content="transition/title"
@ -323,7 +323,8 @@
</tal:link>
</td>
<tal:comment replace="nothing">Workflow transitions</tal:comment>
<td tal:condition="not: isEdit">
<td tal:define="targetObj python: contextObj"
tal:condition="python: targetObj.showTransitions(layoutType)">
<metal:transitions use-macro="app/ui/page/macros/transitions"/>
</td>
</tr>

View file

@ -23,6 +23,12 @@
<table class="noStyle"
tal:define="isBack appyType/isBack">
<tr>
<tal:comment replace="nothing">Workflow transitions</tal:comment>
<td tal:condition="python: obj.showTransitions('result')">
<tal:def define="targetObj python: obj">
<metal:transitions use-macro="app/ui/page/macros/transitions"/>
</tal:def>
</td>
<tal:comment replace="nothing">Edit</tal:comment>
<td tal:condition="python: not appyType['noForm'] and obj.mayEdit() and appyType['delete']">
<a tal:define="navInfo python:'ref.%s.%s:%s.%d.%d' % (contextObj.UID(), fieldName, appyType['pageName'], repeat['obj'].number()+startNumber, totalNumber);"

View file

@ -59,7 +59,8 @@ HTML_ENTITIES = {
'ouml':'ö', 'divide':'÷', 'oslash':'ø', 'ugrave':'ù', 'uacute':'ú',
'ucirc':'û', 'uuml':'ü', 'yacute':'ý', 'thorn':'þ', 'yuml':'ÿ',
'euro':'', 'nbsp':' ', "rsquo":"'", "lsquo":"'", "ldquo":"'",
"rdquo":"'", 'ndash': ' ', 'oelig':'oe', 'quot': "'", 'mu': 'µ'}
"rdquo":"'", 'ndash': '', 'mdash': '', 'oelig':'oe', 'quot': "'",
'mu': 'µ'}
import htmlentitydefs
for k, v in htmlentitydefs.entitydefs.iteritems():
if not HTML_ENTITIES.has_key(k) and not XML_ENTITIES.has_key(k):