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