[gen] Added the posssibility to create a custom widget that displays an icon for generating a doc from a pod field, but with an additional param allowing to customize the pod context.
This commit is contained in:
parent
e83f0f3815
commit
086f93e845
|
@ -1 +1 @@
|
|||
0.8.3
|
||||
0.8.4
|
||||
|
|
|
@ -2435,8 +2435,17 @@ class Pod(Type):
|
|||
sortBy=sortKey, sortOrder=sortOrder, filterKey=filterKey,
|
||||
filterValue=filterValue, maxResults='NO_LIMIT')
|
||||
podContext['objects'] = [o.appy() for o in objs['objects']]
|
||||
# Add the field-specific context if present.
|
||||
if specificContext:
|
||||
podContext.update(specificContext)
|
||||
# If a custom param comes from the request, add it to the context. A
|
||||
# custom param must have format "name:value". Custom params override any
|
||||
# other value in the request, including values from the field-specific
|
||||
# context.
|
||||
customParams = rq.get('customParams', None)
|
||||
if customParams:
|
||||
paramsDict = eval(customParams)
|
||||
podContext.update(paramsDict)
|
||||
# Define a potential global styles mapping
|
||||
if callable(self.stylesMapping):
|
||||
stylesMapping = self.callMethod(obj, self.stylesMapping)
|
||||
|
|
|
@ -460,13 +460,16 @@ function toggleCookie(cookieId) {
|
|||
}
|
||||
|
||||
// Function that allows to generate a document from a pod template.
|
||||
function generatePodDocument(contextUid, fieldName, podFormat, queryData) {
|
||||
function generatePodDocument(contextUid, fieldName, podFormat, queryData,
|
||||
customParams) {
|
||||
var theForm = document.getElementById("podTemplateForm");
|
||||
theForm.objectUid.value = contextUid;
|
||||
theForm.fieldName.value = fieldName;
|
||||
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";
|
||||
|
|
BIN
gen/ui/doc.png
BIN
gen/ui/doc.png
Binary file not shown.
Before Width: | Height: | Size: 829 B After Width: | Height: | Size: 832 B |
BIN
gen/ui/odt.png
BIN
gen/ui/odt.png
Binary file not shown.
Before Width: | Height: | Size: 791 B After Width: | Height: | Size: 774 B |
|
@ -45,6 +45,7 @@
|
|||
<input type="hidden" name="podFormat"/>
|
||||
<input type="hidden" name="askAction"/>
|
||||
<input type="hidden" name="queryData"/>
|
||||
<input type="hidden" name="customParams"/>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -309,7 +309,7 @@ class Renderer:
|
|||
if not content and not at:
|
||||
raise PodError(DOC_NOT_SPECIFIED)
|
||||
# Convert Zope files into Appy wrappers.
|
||||
if content.__class__.__name__ == 'File':
|
||||
if content.__class__.__name__ in ('File', 'Image'):
|
||||
content = FileWrapper(content)
|
||||
# Guess document format
|
||||
if isinstance(content, FileWrapper):
|
||||
|
|
Loading…
Reference in a new issue