Skip to content

Commit 179878a

Browse files
committed
Additional fix for script boilerplate
1 parent 93bbd4c commit 179878a

3 files changed

Lines changed: 39 additions & 49 deletions

File tree

resources/js/processes/scripts/components/ScriptEditor.vue

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -402,11 +402,10 @@
402402
</template>
403403

404404
<script>
405-
import Vue from "vue";
406405
import MonacoEditor from "vue-monaco";
407406
import _ from "lodash";
408407
import TopMenu from "../../../components/Menu.vue";
409-
import "../customFilters";
408+
import { formatScriptBoilerplate } from "../customFilters";
410409
import autosaveMixins from "../../../modules/autosave/mixins";
411410
import AssetRedirectMixin from "../../../components/shared/AssetRedirectMixin";
412411
import AiTab from "./AiTab.vue";
@@ -885,28 +884,9 @@ export default {
885884
},
886885
loadBoilerplateTemplate() {
887886
if (this.script.code === "[]") {
888-
switch (this.script.language) {
889-
case "php":
890-
case "php-nayra":
891-
this.code = Vue.filter("php")(this.boilerPlateTemplate);
892-
break;
893-
case "lua":
894-
this.code = Vue.filter("lua")(this.boilerPlateTemplate);
895-
break;
896-
case "javascript":
897-
this.code = Vue.filter("javascript")(this.boilerPlateTemplate);
898-
break;
899-
case "csharp":
900-
this.code = Vue.filter("csharp")(this.boilerPlateTemplate);
901-
break;
902-
case "java":
903-
this.code = Vue.filter("java")(this.boilerPlateTemplate);
904-
break;
905-
case "python":
906-
this.code = Vue.filter("python")(this.boilerPlateTemplate);
907-
break;
908-
default:
909-
break;
887+
const formatted = formatScriptBoilerplate(this.language, this.boilerPlateTemplate);
888+
if (formatted !== this.boilerPlateTemplate) {
889+
this.code = formatted;
910890
}
911891
912892
// Save boilerplate template to avoid issues when script code is [].

resources/js/processes/scripts/customFilters.js

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import Vue from "vue";
2-
3-
// PHP
4-
Vue.filter("php", (value) => {
1+
export function phpBoilerplate(value) {
52
value = value.split("\r");
63
let format = "";
74
const content = [];
@@ -23,10 +20,9 @@ Vue.filter("php", (value) => {
2320
});
2421

2522
return `${content.join("\n")}\n\n\ return [];`;
26-
});
23+
}
2724

28-
// JAVASCRIPT
29-
Vue.filter("javascript", (value) => {
25+
export function javascriptBoilerplate(value) {
3026
value = value.split("\r");
3127
let format = "";
3228
const content = [];
@@ -48,10 +44,9 @@ Vue.filter("javascript", (value) => {
4844
});
4945

5046
return `${content.join("\n")}\n\n\ return {};`;
51-
});
47+
}
5248

53-
// LUA
54-
Vue.filter("lua", (value) => {
49+
export function luaBoilerplate(value) {
5550
value = value.split("\r");
5651
let format = "";
5752
const content = [];
@@ -73,10 +68,9 @@ Vue.filter("lua", (value) => {
7368
});
7469

7570
return `${content.join("\n")}\n\n\ return {};`;
76-
});
71+
}
7772

78-
// C#
79-
Vue.filter("csharp", (value) => {
73+
export function csharpBoilerplate(value) {
8074
value = value.split("\r");
8175
let format = "";
8276
const content = [];
@@ -98,10 +92,9 @@ Vue.filter("csharp", (value) => {
9892
});
9993

10094
return `${content.join("\n")}\n\n\ return {};`;
101-
});
95+
}
10296

103-
// JAVA
104-
Vue.filter("java", (value) => {
97+
export function javaBoilerplate(value) {
10598
value = value.split("\r");
10699
let format = "";
107100
const content = [];
@@ -123,16 +116,15 @@ Vue.filter("java", (value) => {
123116
});
124117

125118
return `${content.join("\n")}\n\n\ return {};`;
126-
});
119+
}
127120

128-
// Python
129-
Vue.filter("python", (value) => {
121+
export function pythonBoilerplate(value) {
130122
value = value.split("\r");
131123
let format = "";
132124
const content = [];
133125

134126
value.shift();
135-
value.forEach((line, i) => {
127+
value.forEach((line) => {
136128
line = line.replace("{accessEnvVar}", "os.environ['ENV_VAR_NAME']");
137129
line = line.replace("{dataVariable}", "the data variable");
138130
line = line.replace("{configVariable}", "the config variable");
@@ -146,4 +138,19 @@ Vue.filter("python", (value) => {
146138
content.push("# output = {\"name\": user.fullname}");
147139

148140
return `${content.join("\n")}\n\noutput={};`;
149-
});
141+
}
142+
143+
const boilerplateByLanguage = {
144+
php: phpBoilerplate,
145+
"php-nayra": phpBoilerplate,
146+
javascript: javascriptBoilerplate,
147+
lua: luaBoilerplate,
148+
csharp: csharpBoilerplate,
149+
java: javaBoilerplate,
150+
python: pythonBoilerplate,
151+
};
152+
153+
export function formatScriptBoilerplate(language, template) {
154+
const formatter = boilerplateByLanguage[language];
155+
return formatter ? formatter(template) : template;
156+
}

vite.config.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,12 @@ export default defineConfig(({ mode }) => {
342342
dest: "../js/img",
343343
rename: { stripBase: 5 },
344344
},
345-
// BPMN font symbols
346-
{ src: "node_modules/bpmn-font/dist", dest: "../css/bpmn-symbols" },
345+
// BPMN font symbols — layout expects /css/bpmn-symbols/css/bpmn.css
346+
{
347+
src: "node_modules/bpmn-font/dist/**/*",
348+
dest: "../css/bpmn-symbols",
349+
rename: { stripBase: 3 },
350+
},
347351
// Monaco Editor (mirrors webpack.mix.js lines 119-138)
348352
...monacoTargets,
349353
],
@@ -399,8 +403,7 @@ export default defineConfig(({ mode }) => {
399403
|| id.includes("libraries/processesComponents")
400404
|| id.includes("libraries/processesCatalogueComponents")
401405
|| id.includes("libraries/scriptsComponents")
402-
|| id.includes("libraries/screensComponents")
403-
|| id.includes("processes/scripts/customFilters"),
406+
|| id.includes("libraries/screensComponents"),
404407
},
405408
},
406409
},

0 commit comments

Comments
 (0)