df6362cb by acetousk

Add mjml services and screen

1 parent 5f38bfe0
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3 This software is in the public domain under CC0 1.0 Universal plus a
4 Grant of Patent License.
5
6 To the extent possible under law, the author(s) have dedicated all
7 copyright and related and neighboring rights to this software to the
8 public domain worldwide. This software is distributed without any
9 warranty.
10
11 You should have received a copy of the CC0 Public Domain Dedication
12 along with this software (see the LICENSE.md file). If not, see
13 <http://creativecommons.org/publicdomain/zero/1.0/>.
14 -->
15 <screen-extend xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://moqui.org/xsd/xml-screen-3.xsd">
16
17 </screen-extend>
...\ No newline at end of file ...\ No newline at end of file
...@@ -179,6 +179,7 @@ along with this software (see the LICENSE.md file). If not, see ...@@ -179,6 +179,7 @@ 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 const resourceId = new URLSearchParams(window.location.search).get('resourceId'); 181 const resourceId = new URLSearchParams(window.location.search).get('resourceId');
182 const projectEndpoint = `${baseLinkUrl}/mjml/handleGrapeJs?resourceId=${resourceId}`;
182 183
183 window.editor = grapesjs.init({ 184 window.editor = grapesjs.init({
184 height: '100%', 185 height: '100%',
......
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3 This software is in the public domain under CC0 1.0 Universal plus a
4 Grant of Patent License.
5
6 To the extent possible under law, the author(s) have dedicated all
7 copyright and related and neighboring rights to this software to the
8 public domain worldwide. This software is distributed without any
9 warranty.
10
11 You should have received a copy of the CC0 Public Domain Dedication
12 along with this software (see the LICENSE.md file). If not, see
13 <http://creativecommons.org/publicdomain/zero/1.0/>.
14 -->
15 <services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/service-definition-3.xsd">
16
17 <service verb="load" noun="GrapeJs">
18 <description>Create MJML</description>
19 <in-parameters>
20 <parameter name="resourceId"/>
21 </in-parameters>
22 <out-parameters>
23 <parameter name="resourceId"/>
24 <parameter name="data"/>
25 </out-parameters>
26 <actions>
27 <log level="warn" message="load context.toString() ${context.toString()}"/>
28
29 <if condition="!resourceId">
30 <then>
31 <set field="grapesJsResource" from="ec.resource.getLocationReference('dbresource://grapesjs')"/>
32 <service-call name="create#moqui.resource.DbResource" in-map="[parentResourceId:grapesJsResource.getDbResourceId(),isFile:'Y']" out-map="dbResource"/>
33 <service-call name="update#moqui.resource.DbResource" in-map="[resourceId:dbResource.resourceId,filename:dbResource.resourceId]" out-map="dbResource"/>
34 <set field="versionName" value="01"/>
35 <service-call name="create#moqui.resource.DbResourceFile" in-map="[resourceId: dbResource.resourceId,mimeType: 'text/json',versionName: versionName,rootVersionName: versionName,fileData:null]"/>
36 <service-call name="create#moqui.resource.DbResourceFileHistory" in-map="[resourceId: dbResource.resourceId,versionDate: ec.user.nowTimestamp,userId: ec.user.userId,isDiff: 'N']"/>
37 <set field="resourceId" from="dbResource.resourceId"/>
38 </then>
39 <else>
40 <entity-find-one entity-name="moqui.resource.DbResource" value-field="dbResource" auto-field-map="[resourceId:resourceId]"/>
41 <!-- <log level="warn" message="dbResource ${dbResource}"/>-->
42 <if condition="!dbResource">
43 <return error="true" message="Resource not found"/>
44 </if>
45 <set field="actualDbResourcePath" from="null"/>
46 <set field="dbResourcePath" from="dbResource.filename"/>
47 <set field="lastDbResource" from="dbResource"/>
48 <!-- <log level="warn" message="lastDbResource ${lastDbResource}"/>-->
49 <script>
50 while (actualDbResourcePath == null) {
51 // ec.logger.warn('dbResourcePath: '+dbResourcePath)
52 if (lastDbResource.parentResourceId == null) {
53 dbResourcePath = 'dbresource://'+dbResourcePath
54 actualDbResourcePath = dbResourcePath
55 // ec.logger.warn('actualDbResourcePath: '+actualDbResourcePath)
56 } else {
57 lastDbResource = ec.entity.fastFindOne("moqui.resource.DbResource", true, false, lastDbResource.parentResourceId)
58 dbResourcePath = lastDbResource.filename+'/'+dbResourcePath
59 }
60 }
61 </script>
62 <set field="putDbResource" from="ec.resource.getLocationReference(actualDbResourcePath)"/>
63 <entity-find entity-name="moqui.resource.DbResourceFileHistory" list="dbResourceHistoryList" limit="1">
64 <econdition field-name="resourceId" from="resourceId"/>
65 <order-by field-name="-versionName"/>
66 </entity-find>
67 <if condition="dbResourceHistoryList.size() == 0">
68 <return error="true" message="Resource not found"/>
69 </if>
70
71 <set field="data" from="putDbResource.getText(dbResourceHistoryList.getFirst().versionName)"/>
72 </else>
73 </if>
74 </actions>
75 </service>
76 <service verb="store" noun="GrapeJs" authenticate="anonymous-all">
77 <description>Create MJML</description>
78 <in-parameters>
79 <parameter name="resourceId"/>
80 <parameter name="data">
81 </parameter>
82 </in-parameters>
83 <out-parameters>
84 <parameter name="resourceId"/>
85 </out-parameters>
86 <actions>
87 <log level="warn" message="store context.toString() ${context.toString()}"/>
88 <if condition="!resourceId">
89 <then>
90 <!-- <log level="warn" message="resourceId is null"/>-->
91 <set field="grapesJsResource" from="ec.resource.getLocationReference('dbresource://grapesjs')"/>
92 <service-call name="create#moqui.resource.DbResource" in-map="[parentResourceId:grapesJsResource.getDbResourceId(),isFile:'Y']" out-map="dbResource"/>
93 <service-call name="update#moqui.resource.DbResource" in-map="[resourceId:dbResource.resourceId,filename:dbResource.resourceId]" out-map="dbResource"/>
94 <set field="versionName" value="01"/>
95 <service-call name="create#moqui.resource.DbResourceFile" in-map="[resourceId: dbResource.resourceId,mimeType: 'text/json',versionName: versionName,rootVersionName: versionName,fileData:data]"/>
96 <service-call name="create#moqui.resource.DbResourceFileHistory" in-map="[resourceId: dbResource.resourceId,versionDate: ec.user.nowTimestamp,userId: ec.user.userId,isDiff: 'N']"/>
97 <set field="resourceId" from="dbResource.resourceId"/>
98 </then>
99 <else>
100 <!-- <log level="warn" message="resourceId is ${resourceId}"/>-->
101 <entity-find-one entity-name="moqui.resource.DbResource" value-field="dbResource" auto-field-map="[resourceId:resourceId]"/>
102 <!-- <log level="warn" message="dbResource ${dbResource}"/>-->
103 <if condition="!dbResource">
104 <return error="true" message="Resource not found"/>
105 </if>
106 <set field="actualDbResourcePath" from="null"/>
107 <set field="dbResourcePath" from="dbResource.filename"/>
108 <set field="lastDbResource" from="dbResource"/>
109 <!-- <log level="warn" message="lastDbResource ${lastDbResource}"/>-->
110 <script>
111 while (actualDbResourcePath == null) {
112 // ec.logger.warn('dbResourcePath: '+dbResourcePath)
113 if (lastDbResource.parentResourceId == null) {
114 dbResourcePath = 'dbresource://'+dbResourcePath
115 actualDbResourcePath = dbResourcePath
116 // ec.logger.warn('actualDbResourcePath: '+actualDbResourcePath)
117 } else {
118 lastDbResource = ec.entity.fastFindOne("moqui.resource.DbResource", true, false, lastDbResource.parentResourceId)
119 dbResourcePath = lastDbResource.filename+'/'+dbResourcePath
120 }
121 }
122 </script>
123 <set field="putDbResource" from="ec.resource.getLocationReference(actualDbResourcePath)"/>
124 <script>
125 putDbResource.putText(data)
126 </script>
127
128 </else>
129 </if>
130 </actions>
131 </service>
132
133
134 </services>