c5baa053 by acetousk

Add emailTemplateId and resourceId with necessary screens and entities

1 parent af2516ad
......@@ -14,9 +14,15 @@ along with this software (see the LICENSE.md file). If not, see
-->
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/entity-definition-3.xsd">
<extend-entity entity-name="ProductStoreEmail" package="mantle.product.store">
<extend-entity entity-name="EmailTemplate" package="moqui.basic.email">
<field name="resourceId" type="id"/>
<relationship type="one" related="moqui.resource.DbResource" short-alias="dbResource"/>
</extend-entity>
<view-entity entity-name="ProductStoreEmailDetail" package="mantle.product.store">
<member-entity entity-alias="PSE" entity-name="mantle.product.store.ProductStoreEmail"/>
<member-relationship entity-alias="ET" join-from-alias="PSE" relationship="template"/>
<alias-all entity-alias="PSE"/>
<alias-all entity-alias="ET"/>
</view-entity>
</entities>
......
......@@ -14,9 +14,16 @@ along with this software (see the LICENSE.md file). If not, see
-->
<screen-extend xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://moqui.org/xsd/xml-screen-3.xsd">
<actions-extend type="actions" when="replace">
<entity-find entity-name="mantle.product.store.ProductStoreEmailDetail" list="storeEmails">
<search-form-inputs default-order-by="emailTypeEnumId"/>
<econdition field-name="productStoreId"/>
</entity-find>
</actions-extend>
<form-list name="StoreEmailsForm">
<field name="editEmailTemplate" align="center"><default-field>
<link url="/mjml" parameter-map="[resourceId:resourceId]" url-type="plain" text="Edit Template"/>
<link url="/mjml" parameter-map="[resourceId:resourceId,emailTemplateId:emailTemplateId]" url-type="plain" text="Edit Template"/>
</default-field></field>
</form-list>
......
......@@ -179,9 +179,10 @@ along with this software (see the LICENSE.md file). If not, see
// Wait for the plugin to be injected by the dev server
window.onload = () => {
window.resourceId = new URLSearchParams(window.location.search).get('resourceId');
window.emailTemplateId = new URLSearchParams(window.location.search).get('emailTemplateId');
const request = new XMLHttpRequest();
request.open("GET", "${baseLinkUrl}/rest/s1/moqui-mjml/mjml?resourceId="+window.resourceId, false); // `false` makes the request synchronous
request.open("GET", ("${baseLinkUrl}/rest/s1/moqui-mjml/mjml?resourceId="+window.resourceId+"&emailTemplateId="+window.emailTemplateId), false); // `false` makes the request synchronous
request.send(null);
let response;
......
......@@ -18,6 +18,7 @@ along with this software (see the LICENSE.md file). If not, see
<description>Create MJML</description>
<in-parameters>
<parameter name="resourceId"/>
<parameter name="emailTemplateId"/>
</in-parameters>
<out-parameters>
<parameter name="resourceId"/>
......@@ -25,8 +26,8 @@ along with this software (see the LICENSE.md file). If not, see
</out-parameters>
<actions>
<if condition="resourceId == 'null'"><set field="resourceId" from="null"/></if>
<log level="warn" message="resourceId is ${resourceId} resourceId.getClass().getName() ${resourceId.getClass().getName()} resourceId == 'null' ${resourceId == 'null'} resourceId == null ${resourceId == null}"/>
<log level="warn" message="load context.toString() ${context.toString()}"/>
<!-- <log level="warn" message="resourceId is ${resourceId} resourceId.getClass().getName() ${resourceId.getClass().getName()} resourceId == 'null' ${resourceId == 'null'} resourceId == null ${resourceId == null}"/>-->
<!-- <log level="warn" message="load context.toString() ${context.toString()}"/>-->
<if condition="!resourceId">
<then>
......@@ -39,6 +40,10 @@ along with this software (see the LICENSE.md file). If not, see
<service-call name="create#moqui.resource.DbResourceFile" in-map="[resourceId: dbResource.resourceId,mimeType: 'text/json',versionName: versionName,rootVersionName: versionName,fileData:data]"/>
<service-call name="create#moqui.resource.DbResourceFileHistory" in-map="[resourceId: dbResource.resourceId,versionDate: ec.user.nowTimestamp,userId: ec.user.userId,isDiff: 'N']"/>
<set field="resourceId" from="dbResource.resourceId"/>
<if condition="emailTemplateId">
<service-call name="update#moqui.basic.email.EmailTemplate" in-map="[emailTemplateId:emailTemplateId,resourceId:resourceId]"/>
</if>
<!-- <set field="resourceId" from="null"/>-->
<!-- <set field="data" from="null"/>-->
</then>
......