[gen] Pod fields can now be configured with several templates.
This commit is contained in:
parent
889289407f
commit
ecc3a8c39b
10 changed files with 175 additions and 122 deletions
|
@ -296,12 +296,6 @@ class FieldDescriptor:
|
|||
label = '%s_%s_addConfirm' % (self.classDescr.name, self.fieldName)
|
||||
self.i18n(label, po.CONFIRM, nice=False)
|
||||
|
||||
def walkPod(self):
|
||||
# Add i18n-specific messages
|
||||
if self.appyType.askAction:
|
||||
label = '%s_%s_askaction' % (self.classDescr.name, self.fieldName)
|
||||
self.i18n(label, po.POD_ASKACTION, nice=False)
|
||||
|
||||
def walkList(self):
|
||||
# Add i18n-specific messages
|
||||
for name, field in self.appyType.fields:
|
||||
|
@ -361,8 +355,6 @@ class FieldDescriptor:
|
|||
elif self.appyType.type == 'Action': self.walkAction()
|
||||
# Manage things which are specific to Ref types
|
||||
elif self.appyType.type == 'Ref': self.walkRef()
|
||||
# Manage things which are specific to Pod types
|
||||
elif self.appyType.type == 'Pod': self.walkPod()
|
||||
# Manage things which are specific to List types
|
||||
elif self.appyType.type == 'List': self.walkList()
|
||||
# Manage things which are specific to Calendar types
|
||||
|
|
|
@ -120,12 +120,10 @@ class ToolMixin(BaseMixin):
|
|||
# An error has occurred, and p_res contains the error message
|
||||
obj.say(res)
|
||||
return self.goto(rq.get('HTTP_REFERER'))
|
||||
# res contains a FileWrapper instance.
|
||||
response = rq.RESPONSE
|
||||
response.setHeader('Content-Type', res.mimeType)
|
||||
response.setHeader('Content-Disposition',
|
||||
'inline;filename="%s"' % res.name)
|
||||
return res.content
|
||||
# res contains a FileInfo instance.
|
||||
res.writeResponse(rq.RESPONSE)
|
||||
# (Try to) delete the temp file on disk.
|
||||
res.removeFile()
|
||||
|
||||
def getAppName(self):
|
||||
'''Returns the name of the application.'''
|
||||
|
|
|
@ -689,6 +689,7 @@ class BaseMixin:
|
|||
'''Returns the database value of field named p_name for p_self.'''
|
||||
if layoutType == 'search': return # No object in search screens.
|
||||
field = self.getAppyType(name)
|
||||
if field.type == 'Pod': return
|
||||
if '*' not in name: return field.getValue(self)
|
||||
# The field is an inner field from a List.
|
||||
listName, name, i = name.split('*')
|
||||
|
|
|
@ -23,7 +23,6 @@ fallbacks = {'en': 'en-us en-ca',
|
|||
|
||||
# Default values for i18n labels whose ids are not fixed.
|
||||
CONFIG = "Configuration panel for product '%s'"
|
||||
POD_ASKACTION = 'Trigger related action'
|
||||
EMAIL_SUBJECT = '${siteTitle} - Action \\"${transitionName}\\" has been ' \
|
||||
'performed on element entitled \\"${objectTitle}\\".'
|
||||
EMAIL_BODY = 'You can consult this element at ${objectUrl}.'
|
||||
|
|
|
@ -156,3 +156,5 @@ td.search { padding-top: 8px }
|
|||
.homeTable th { padding-top: 5px; font-size: 105% }
|
||||
.first { margin-top: 0px }
|
||||
.error { margin: 5px }
|
||||
.podName { font-size: 90%; padding-left: 3px }
|
||||
.podTable { margin-left: 15px }
|
||||
|
|
|
@ -521,20 +521,16 @@ function toggleCookie(cookieId) {
|
|||
}
|
||||
|
||||
// Function that allows to generate a document from a pod template.
|
||||
function generatePodDocument(contextUid, fieldName, podFormat, queryData,
|
||||
function generatePodDocument(uid, fieldName, template, podFormat, queryData,
|
||||
customParams) {
|
||||
var theForm = document.getElementById("podTemplateForm");
|
||||
theForm.objectUid.value = contextUid;
|
||||
theForm.objectUid.value = uid;
|
||||
theForm.fieldName.value = fieldName;
|
||||
theForm.template.value = template;
|
||||
theForm.podFormat.value = podFormat;
|
||||
theForm.askAction.value = "False";
|
||||
theForm.queryData.value = queryData;
|
||||
if (customParams) { theForm.customParams.value = customParams; }
|
||||
else { theForm.customParams.value = ''; }
|
||||
var askActionWidget = document.getElementById(contextUid + '_' + fieldName + '_cb');
|
||||
if (askActionWidget && askActionWidget.checked) {
|
||||
theForm.askAction.value = "True";
|
||||
}
|
||||
theForm.submit();
|
||||
}
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ class ToolWrapper(AbstractWrapper):
|
|||
# PXs for graphical elements shown on every page
|
||||
# --------------------------------------------------------------------------
|
||||
# Global elements included in every page.
|
||||
pxPagePrologue = Px('''<x>
|
||||
pxPagePrologue = Px('''
|
||||
<!-- Include type-specific CSS and JS. -->
|
||||
<x if="cssJs">
|
||||
<link for="cssFile in cssJs['css']" rel="stylesheet" type="text/css"
|
||||
|
@ -133,12 +133,11 @@ class ToolWrapper(AbstractWrapper):
|
|||
action=":ztool.absolute_url() + '/generateDocument'">
|
||||
<input type="hidden" name="objectUid"/>
|
||||
<input type="hidden" name="fieldName"/>
|
||||
<input type="hidden" name="template"/>
|
||||
<input type="hidden" name="podFormat"/>
|
||||
<input type="hidden" name="askAction"/>
|
||||
<input type="hidden" name="queryData"/>
|
||||
<input type="hidden" name="customParams"/>
|
||||
</form>
|
||||
</x>''')
|
||||
</form>''')
|
||||
|
||||
pxPageBottom = Px('''
|
||||
<script var="info=zobj.getSlavesRequestInfo(page)"
|
||||
|
|
|
@ -797,14 +797,12 @@ class AbstractWrapper(object):
|
|||
zopeObj.reindex()
|
||||
return appyObj
|
||||
|
||||
def freeze(self, fieldName, doAction=False):
|
||||
def freeze(self, fieldName):
|
||||
'''This method freezes a POD document. TODO: allow to freeze Computed
|
||||
fields.'''
|
||||
rq = self.request
|
||||
field = self.o.getAppyType(fieldName)
|
||||
if field.type != 'Pod': raise 'Cannot freeze non-Pod field.'
|
||||
# Perform the related action if required.
|
||||
if doAction: self.request.set('askAction', True)
|
||||
# Set the freeze format
|
||||
rq.set('podFormat', field.freezeFormat)
|
||||
# Generate the document.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue