From 3e36d4c5f0163717edbdc6d48e0e74053d4c0302 Mon Sep 17 00:00:00 2001 From: David E Jones Date: Mon, 28 Feb 2022 14:19:40 -0800 Subject: [PATCH 1/4] In qvt screen macros add support for visisble-when element, qvt only for now, could be supported in vuet but would be a bit of work as it does not currently have something like formProps.fields that can be used for style logic like this, and in html mode would have to add explicit field listeners --- .../screen-macro/DefaultScreenMacros.qvt.ftl | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/template/screen-macro/DefaultScreenMacros.qvt.ftl b/template/screen-macro/DefaultScreenMacros.qvt.ftl index 43bb2bc06..132bfb2b3 100644 --- a/template/screen-macro/DefaultScreenMacros.qvt.ftl +++ b/template/screen-macro/DefaultScreenMacros.qvt.ftl @@ -574,6 +574,10 @@ ${sri.renderIncludeScreen(.node["@location"], .node["@share-scope"]!)} <#return> + +<#-- for visible-when do nothing, handled explicitly as child element --> +<#macro "visible-when"> + <#macro formSingleWidget fieldSubNode formSingleId colPrefix inFieldRow bigRow> <#assign fieldSubParent = fieldSubNode?parent> <#if fieldSubNode["ignored"]?has_content><#return> @@ -581,10 +585,30 @@ ${sri.renderIncludeScreen(.node["@location"], .node["@share-scope"]!)} <#if fieldSubNode["hidden"]?has_content><#recurse fieldSubNode/><#return> <#assign containerStyle = ec.getResource().expandNoL10n(fieldSubNode["@container-style"]!, "")> <#assign curFieldTitle><@fieldTitle fieldSubNode/> + + <#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 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 visibleVal?is_enumerable> + <#assign visibleAttrText> :style="{display:([<#list visibleVal as entryVal>'${entryVal}'<#sep>,].includes(formProps.fields.${visibleWhenNode["@field"]})?'':'none')}" + <#else> + <#assign visibleAttrText> :style="{display:('${visibleVal}'==formProps.fields.${visibleWhenNode["@field"]}?'':'none')}" + + + <#if bigRow> -
+
<#else> -
+
<#t>${sri.pushContext()} <#assign fieldFormId = formSingleId><#-- set this globally so fieldId macro picks up the proper formSingleId, clear after --> From 6052b318ed0e735c943c1821b91550025f826fe2 Mon Sep 17 00:00:00 2001 From: David E Jones Date: Sat, 5 Mar 2022 15:50:44 -0800 Subject: [PATCH 2/4] Add entities to include, iso date/time, and table/column names fields to DataSnapshot screen, note that this requires an update to the export#DataSnapshot service an a recent moqui-framework commit --- .../screen/Tools/Entity/DataSnapshot.xml | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/base-component/tools/screen/Tools/Entity/DataSnapshot.xml b/base-component/tools/screen/Tools/Entity/DataSnapshot.xml index 33e2fb63d..269fdbdd1 100644 --- a/base-component/tools/screen/Tools/Entity/DataSnapshot.xml +++ b/base-component/tools/screen/Tools/Entity/DataSnapshot.xml @@ -19,13 +19,15 @@ along with this software (see the LICENSE.md file). If not, see Started Export Entity Data Snapshot ${baseFilename} (Job ID ${jobRunId}) @@ -86,12 +88,15 @@ along with this software (see the LICENSE.md file). If not, see - - - + + - - + + + + + + @@ -101,14 +106,12 @@ along with this software (see the LICENSE.md file). If not, see - @@ -128,7 +131,7 @@ along with this software (see the LICENSE.md file). If not, see - + From fd864a5bcd9e64d3110ec7268e7ab93f7d2b5261 Mon Sep 17 00:00:00 2001 From: Yao Chunlin Date: Tue, 15 Mar 2022 11:52:57 +0000 Subject: [PATCH 3/4] Localize `From` and `Thru` for range-find widget in qvt mode. --- template/screen-macro/DefaultScreenMacros.qvt.ftl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/template/screen-macro/DefaultScreenMacros.qvt.ftl b/template/screen-macro/DefaultScreenMacros.qvt.ftl index 132bfb2b3..087664c7d 100644 --- a/template/screen-macro/DefaultScreenMacros.qvt.ftl +++ b/template/screen-macro/DefaultScreenMacros.qvt.ftl @@ -1940,12 +1940,12 @@ a => A, d => D, y => Y <#assign fieldLabel><@fieldTitle .node?parent/> <#assign curTooltip = ec.getResource().expand(.node?parent["@tooltip"]!, "")>
- form="${ownerForm}"<#rt> + form="${ownerForm}"<#rt> <#t> size="${.node.@size!"10"}"<#if .node.@maxlength?has_content> maxlength="${.node.@maxlength}" <#t><#if fieldsJsName?has_content> v-model="${fieldsJsName}.${curFieldName}_from"<#else> value="${ec.getContext().get(curFieldName + "_from")!?default(.node["@default-value-from"]!"")?html}"> <#if curTooltip?has_content>${curTooltip} - form="${ownerForm}"<#rt> + form="${ownerForm}"<#rt> <#t> size="${.node.@size!"10"}"<#if .node.@maxlength?has_content> maxlength="${.node.@maxlength}" <#t><#if fieldsJsName?has_content> v-model="${fieldsJsName}.${curFieldName}_thru"<#else> value="${ec.getContext().get(curFieldName + "_thru")!?default(.node["@default-value-thru"]!"")?html}"> <#if curTooltip?has_content>${curTooltip} From 3e5ad8bef055ec7d310f7b89dc9d2c4ebf54d443 Mon Sep 17 00:00:00 2001 From: Arzang Kasiri Date: Thu, 31 Mar 2022 11:40:36 -0500 Subject: [PATCH 4/4] Export multiple CSV files out to browser as a single zip (#194) * Fix bug when setting content type * Export multiple CSV files out to browser as a single zip * Use 'application/zip' when sending a zip file --- .../tools/screen/Tools/Entity/DataExport.xml | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/base-component/tools/screen/Tools/Entity/DataExport.xml b/base-component/tools/screen/Tools/Entity/DataExport.xml index 489644059..e442a20d8 100644 --- a/base-component/tools/screen/Tools/Entity/DataExport.xml +++ b/base-component/tools/screen/Tools/Entity/DataExport.xml @@ -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 } ]]>