Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

Commit

Permalink
Merge branch 'moqui:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
aabiabdallah authored Apr 18, 2022
2 parents 1baf308 + 3e5ad8b commit b0a7de9
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 20 deletions.
20 changes: 15 additions & 5 deletions base-component/tools/screen/Tools/Entity/DataExport.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,23 @@ along with this software (see the LICENSE.md file). If not, see
} else if (context.output == "browser") {
// stream to ec.web.response
def response = ec.web.response
if (fileType == 'JSON') response.setContentType('application/json')
if (fileType == 'CSV') response.setContentType('text/csv')
else response.setContentType('text/xml')
response.setCharacterEncoding("UTF-8")
response.setHeader("Content-Disposition", "attachment; filename=\"EntityExport_${ec.l10n.format(ec.user.nowTimestamp, 'yyyyMMdd_HHmm')}.${fileType == 'JSON' ? 'json' : fileType == 'CSV' ? 'csv' : 'xml'}\";")
response.setHeader("Cache-Control", "no-cache, must-revalidate, private")
edw.writer(response.getWriter())
if (fileType == 'CSV' && entityNames instanceof List && entityNames.size() > 1) {
// if trying to export more than one entity as CSV, send a .zip file instead
response.setContentType('application/zip')
response.setHeader("Content-Disposition", "attachment; filename=\"EntityExport_${ec.l10n.format(ec.user.nowTimestamp, 'yyyyMMdd_HHmm')}.zip\";")
edw.zipDirectory('', response.getOutputStream())
} else {
if (fileType == 'JSON') response.setContentType('application/json')
else if (fileType == 'CSV') response.setContentType('text/csv')
else response.setContentType('text/xml')
response.setHeader("Content-Disposition", "attachment; filename=\"EntityExport_${ec.l10n.format(ec.user.nowTimestamp, 'yyyyMMdd_HHmm')}.${fileType == 'JSON' ? 'json' : fileType == 'CSV' ? 'csv' : 'xml'}\";")
edw.writer(response.getWriter())
}
noResponse = true
}
]]></script>
Expand Down
25 changes: 14 additions & 11 deletions base-component/tools/screen/Tools/Entity/DataSnapshot.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ along with this software (see the LICENSE.md file). If not, see
<transition name="exportSnapshot" begin-transaction="false">
<actions>
<script><![CDATA[
if (!entitiesToInclude) entitiesToInclude = null
if (entitiesToInclude != null && !(entitiesToInclude instanceof List)) entitiesToInclude = [entitiesToInclude]
if (!entitiesToSkip) entitiesToSkip = null
if (entitiesToSkip != null && !(entitiesToSkip instanceof List)) entitiesToSkip = [entitiesToSkip]
if ("CSV".equals(fileType)) filePerEntity = true
jobRunId = ec.service.job("ExportEntityDataSnapshot")
.parameters([fromDate:fromDate, thruDate:thruDate, baseFilename:baseFilename, fileType:fileType,
filePerEntity:filePerEntity, isoDateTime:isoDateTime, tableColumnNames:tableColumnNames,
entitiesToSkip:entitiesToSkip]).run()
entitiesToSkip:entitiesToSkip, entitiesToInclude:entitiesToInclude]).run()
]]></script>
<message>Started Export Entity Data Snapshot ${baseFilename} (Job ID ${jobRunId})</message>
</actions>
Expand Down Expand Up @@ -86,12 +88,15 @@ along with this software (see the LICENSE.md file). If not, see
<widgets>
<container-dialog id="ExportDialog" button-text="Export Snapshot">
<form-single name="ExportData" transition="exportSnapshot">
<!-- NOTE: add entities to exclude?, maybe ArtifactHit by default? -->
<field name="entitiesToSkip">
<default-field><drop-down allow-multiple="true" size="80">
<field name="entitiesToInclude"><default-field tooltip="Defaults to include all if none selected and one or more skip entities specified">
<drop-down allow-multiple="true" size="80">
<list-options list="ec.entity.getAllEntitiesInfo('fullEntityName', null, false, true)" key="${fullEntityName}"/>
</drop-down></default-field>
</field>
</drop-down>
</default-field></field>
<!-- NOTE: add sets of entities to exclude? maybe ArtifactHit by default? -->
<field name="entitiesToSkip"><default-field><drop-down allow-multiple="true" size="80">
<list-options list="ec.entity.getAllEntitiesInfo('fullEntityName', null, false, true)" key="${fullEntityName}"/>
</drop-down></default-field></field>
<field name="fromDate"><default-field><date-time minute-stepping="1"/></default-field></field>
<field name="thruDate"><default-field><date-time minute-stepping="1"/></default-field></field>
<field name="baseFilename"><default-field><text-line size="40" default-value="MoquiSnapshot-${ec.l10n.format(ec.user.nowTimestamp, 'yyyyMMdd-HHmm')}"/></default-field></field>
Expand All @@ -101,14 +106,12 @@ along with this software (see the LICENSE.md file). If not, see
<field name="filePerEntity"><default-field>
<radio no-current-selected-key="false"><option key="true"/><option key="false"/></radio>
</default-field></field>
<!-- these are only supported for CSV for now, hide until better supported (ie API only)
<field name="isoDateTime"><default-field>
<field name="isoDateTime"><default-field title="ISO Date Time" tooltip="CSV ONLY">
<radio no-current-selected-key="false"><option key="true"/><option key="false"/></radio>
</default-field></field>
<field name="tableColumnNames"><default-field>
<field name="tableColumnNames"><default-field tooltip="CSV ONLY, use table and column names instead of entity and field names">
<radio no-current-selected-key="false"><option key="true"/><option key="false"/></radio>
</default-field></field>
-->
<field name="submitButton"><default-field title="Export Snapshot"><submit/></default-field></field>
</form-single>
</container-dialog>
Expand All @@ -128,7 +131,7 @@ along with this software (see the LICENSE.md file). If not, see
<row-col sm="2"><label text="${ec.l10n.format(new java.sql.Timestamp(sfile.lastModified()), null)}"/></row-col>
<row-col sm="2"><label text="${ec.l10n.format((sfile.length())/(1024*1024), '#,##0.00')} MiB"/></row-col>
<row-col sm="1"><link url="downloadSnapshot" text="Download" parameter-map="[filename:sfile.name]"/></row-col>
<row-col sm="1"><link url="deleteSnapshot" text="Delete" parameter-map="[filename:sfile.name]"/></row-col>
<row-col sm="1"><link url="deleteSnapshot" text="Delete" parameter-map="[filename:sfile.name]" confirmation="Really delete ${sfile.name}?"/></row-col>
<row-col sm="1"><container-dialog id="ImportDialog" button-text="Import">
<form-single name="ImportForm" transition="importSnapshot">
<field name="zipFilename" from="sfile.name"><default-field><display/></default-field></field>
Expand Down
32 changes: 28 additions & 4 deletions template/screen-macro/DefaultScreenMacros.qvt.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -574,17 +574,41 @@ ${sri.renderIncludeScreen(.node["@location"], .node["@share-scope"]!)}
<#return>
</#if>
</#macro>

<#-- for visible-when do nothing, handled explicitly as child element -->
<#macro "visible-when"></#macro>

<#macro formSingleWidget fieldSubNode formSingleId colPrefix inFieldRow bigRow>
<#assign fieldSubParent = fieldSubNode?parent>
<#if fieldSubNode["ignored"]?has_content><#return></#if>
<#if ec.getResource().condition(fieldSubParent["@hide"]!, "")><#return></#if>
<#if fieldSubNode["hidden"]?has_content><#recurse fieldSubNode/><#return></#if>
<#assign containerStyle = ec.getResource().expandNoL10n(fieldSubNode["@container-style"]!, "")>
<#assign curFieldTitle><@fieldTitle fieldSubNode/></#assign>

<#assign visibleWhenNode = (fieldSubNode["visible-when"][0])!>
<#assign visibleAttrText = "">
<#if visibleWhenNode??>
<#assign visibleVal = "">
<#if visibleWhenNode["@from"]?has_content>
<#assign visibleVal = ec.getResource().expression(visibleWhenNode["@from"], "")!>
<#else>
<#assign visibleVal = ec.getResource().expand(visibleWhenNode["@value"]!, "")!>
</#if>
<#if visibleVal?has_content>
<#-- NOTE: FreeMarker is sometimes ridiculous, is_string returns true even if the type is ArrayList in one test case, so DO NOT TRUST is_string!!! -->
<#if visibleVal?is_string && !visibleVal?is_enumerable && visibleVal?contains(",")><#assign visibleVal = visibleVal?split(",")></#if>
<#if visibleVal?is_enumerable>
<#assign visibleAttrText> :style="{display:([<#list visibleVal as entryVal>'${entryVal}'<#sep>,</#list>].includes(formProps.fields.${visibleWhenNode["@field"]})?'':'none')}"</#assign>
<#else>
<#assign visibleAttrText> :style="{display:('${visibleVal}'==formProps.fields.${visibleWhenNode["@field"]}?'':'none')}"</#assign>
</#if>
</#if>
</#if>
<#if bigRow>
<div class="q-mx-sm q-my-auto big-row-item">
<div class="q-mx-sm q-my-auto big-row-item"${visibleAttrText}>
<#else>
<div class="q-ma-sm <#if containerStyle?has_content> ${containerStyle}</#if>">
<div class="q-ma-sm<#if containerStyle?has_content> ${containerStyle}</#if>"${visibleAttrText}>
</#if>
<#t>${sri.pushContext()}
<#assign fieldFormId = formSingleId><#-- set this globally so fieldId macro picks up the proper formSingleId, clear after -->
Expand Down Expand Up @@ -1916,12 +1940,12 @@ a => A, d => D, y => Y
<#assign fieldLabel><@fieldTitle .node?parent/></#assign>
<#assign curTooltip = ec.getResource().expand(.node?parent["@tooltip"]!, "")>
<div class="row">
<q-input dense outlined stack-label label="${fieldLabel} From" name="${curFieldName}_from" id="${tlId}_from"<#if ownerForm?has_content> form="${ownerForm}"</#if><#rt>
<q-input dense outlined stack-label label="${fieldLabel} ${ec.getL10n().localize('From')}" name="${curFieldName}_from" id="${tlId}_from"<#if ownerForm?has_content> form="${ownerForm}"</#if><#rt>
<#t> size="${.node.@size!"10"}"<#if .node.@maxlength?has_content> maxlength="${.node.@maxlength}"</#if>
<#t><#if fieldsJsName?has_content> v-model="${fieldsJsName}.${curFieldName}_from"<#else> value="${ec.getContext().get(curFieldName + "_from")!?default(.node["@default-value-from"]!"")?html}"</#if>>
<#if curTooltip?has_content><q-tooltip>${curTooltip}</q-tooltip></#if>
</q-input>
<q-input class="q-pl-xs" dense outlined stack-label label="${fieldLabel} Thru" name="${curFieldName}_thru" id="${tlId}_thru"<#if ownerForm?has_content> form="${ownerForm}"</#if><#rt>
<q-input class="q-pl-xs" dense outlined stack-label label="${fieldLabel} ${ec.getL10n().localize('Thru')}" name="${curFieldName}_thru" id="${tlId}_thru"<#if ownerForm?has_content> form="${ownerForm}"</#if><#rt>
<#t> size="${.node.@size!"10"}"<#if .node.@maxlength?has_content> maxlength="${.node.@maxlength}"</#if>
<#t><#if fieldsJsName?has_content> v-model="${fieldsJsName}.${curFieldName}_thru"<#else> value="${ec.getContext().get(curFieldName + "_thru")!?default(.node["@default-value-thru"]!"")?html}"</#if>>
<#if curTooltip?has_content><q-tooltip>${curTooltip}</q-tooltip></#if>
Expand Down

0 comments on commit b0a7de9

Please sign in to comment.