refactor(client): ✨
This commit is contained in:
parent
533c9a4fe1
commit
2ee0e07bb6
25 changed files with 285 additions and 293 deletions
|
@ -21,12 +21,12 @@
|
|||
<mk-select v-model="value.var">
|
||||
<template #label>{{ $t('_pages.blocks._button._action._pushEvent.variable') }}</template>
|
||||
<option :value="null">{{ $t('_pages.blocks._button._action._pushEvent.no-variable') }}</option>
|
||||
<option v-for="v in aoiScript.getVarsByType()" :value="v.name">{{ v.name }}</option>
|
||||
<option v-for="v in hpml.getVarsByType()" :value="v.name">{{ v.name }}</option>
|
||||
<optgroup :label="$t('_pages.script.pageVariables')">
|
||||
<option v-for="v in aoiScript.getPageVarsByType()" :value="v">{{ v }}</option>
|
||||
<option v-for="v in hpml.getPageVarsByType()" :value="v">{{ v }}</option>
|
||||
</optgroup>
|
||||
<optgroup :label="$t('_pages.script.enviromentVariables')">
|
||||
<option v-for="v in aoiScript.getEnvVarsByType()" :value="v">{{ v }}</option>
|
||||
<option v-for="v in hpml.getEnvVarsByType()" :value="v">{{ v }}</option>
|
||||
</optgroup>
|
||||
</mk-select>
|
||||
</template>
|
||||
|
@ -57,7 +57,7 @@ export default Vue.extend({
|
|||
value: {
|
||||
required: true
|
||||
},
|
||||
aoiScript: {
|
||||
hpml: {
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -10,16 +10,16 @@
|
|||
<section class="romcojzs">
|
||||
<mk-select v-model="value.var">
|
||||
<template #label>{{ $t('_pages.blocks._if.variable') }}</template>
|
||||
<option v-for="v in aoiScript.getVarsByType('boolean')" :value="v.name">{{ v.name }}</option>
|
||||
<option v-for="v in hpml.getVarsByType('boolean')" :value="v.name">{{ v.name }}</option>
|
||||
<optgroup :label="$t('_pages.script.pageVariables')">
|
||||
<option v-for="v in aoiScript.getPageVarsByType('boolean')" :value="v">{{ v }}</option>
|
||||
<option v-for="v in hpml.getPageVarsByType('boolean')" :value="v">{{ v }}</option>
|
||||
</optgroup>
|
||||
<optgroup :label="$t('_pages.script.enviromentVariables')">
|
||||
<option v-for="v in aoiScript.getEnvVarsByType('boolean')" :value="v">{{ v }}</option>
|
||||
<option v-for="v in hpml.getEnvVarsByType('boolean')" :value="v">{{ v }}</option>
|
||||
</optgroup>
|
||||
</mk-select>
|
||||
|
||||
<x-blocks class="children" v-model="value.children" :aoi-script="aoiScript"/>
|
||||
<x-blocks class="children" v-model="value.children" :hpml="hpml"/>
|
||||
</section>
|
||||
</x-container>
|
||||
</template>
|
||||
|
@ -45,7 +45,7 @@ export default Vue.extend({
|
|||
value: {
|
||||
required: true
|
||||
},
|
||||
aoiScript: {
|
||||
hpml: {
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
</template>
|
||||
|
||||
<section class="ilrvjyvi">
|
||||
<x-blocks class="children" v-model="value.children" :aoi-script="aoiScript"/>
|
||||
<x-blocks class="children" v-model="value.children" :hpml="hpml"/>
|
||||
</section>
|
||||
</x-container>
|
||||
</template>
|
||||
|
@ -37,7 +37,7 @@ export default Vue.extend({
|
|||
value: {
|
||||
required: true
|
||||
},
|
||||
aoiScript: {
|
||||
hpml: {
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<x-draggable tag="div" :list="blocks" handle=".drag-handle" :group="{ name: 'blocks' }" animation="150" swap-threshold="0.5">
|
||||
<component v-for="block in blocks" :is="'x-' + block.type" :value="block" @input="updateItem" @remove="() => removeItem(block)" :key="block.id" :aoi-script="aoiScript"/>
|
||||
<component v-for="block in blocks" :is="'x-' + block.type" :value="block" @input="updateItem" @remove="() => removeItem(block)" :key="block.id" :hpml="hpml"/>
|
||||
</x-draggable>
|
||||
</template>
|
||||
|
||||
|
@ -32,7 +32,7 @@ export default Vue.extend({
|
|||
type: Array,
|
||||
required: true
|
||||
},
|
||||
aoiScript: {
|
||||
hpml: {
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -24,15 +24,15 @@
|
|||
</section>
|
||||
<section v-else-if="value.type === 'ref'" class="hpdwcrvs">
|
||||
<select v-model="value.value">
|
||||
<option v-for="v in aoiScript.getVarsByType(getExpectedType ? getExpectedType() : null).filter(x => x.name !== name)" :value="v.name">{{ v.name }}</option>
|
||||
<option v-for="v in hpml.getVarsByType(getExpectedType ? getExpectedType() : null).filter(x => x.name !== name)" :value="v.name">{{ v.name }}</option>
|
||||
<optgroup :label="$t('_pages.script.argVariables')">
|
||||
<option v-for="v in fnSlots" :value="v.name">{{ v.name }}</option>
|
||||
</optgroup>
|
||||
<optgroup :label="$t('_pages.script.pageVariables')">
|
||||
<option v-for="v in aoiScript.getPageVarsByType(getExpectedType ? getExpectedType() : null)" :value="v">{{ v }}</option>
|
||||
<option v-for="v in hpml.getPageVarsByType(getExpectedType ? getExpectedType() : null)" :value="v">{{ v }}</option>
|
||||
</optgroup>
|
||||
<optgroup :label="$t('_pages.script.enviromentVariables')">
|
||||
<option v-for="v in aoiScript.getEnvVarsByType(getExpectedType ? getExpectedType() : null)" :value="v">{{ v }}</option>
|
||||
<option v-for="v in hpml.getEnvVarsByType(getExpectedType ? getExpectedType() : null)" :value="v">{{ v }}</option>
|
||||
</optgroup>
|
||||
</select>
|
||||
</section>
|
||||
|
@ -44,13 +44,13 @@
|
|||
<span>{{ $t('_pages.script.blocks._fn.slots') }}</span>
|
||||
<template #desc>{{ $t('_pages.script.blocks._fn.slots-info') }}</template>
|
||||
</mk-textarea>
|
||||
<x-v v-if="value.value.expression" v-model="value.value.expression" :title="$t(`_pages.script.blocks._fn.arg1`)" :get-expected-type="() => null" :aoi-script="aoiScript" :fn-slots="value.value.slots" :name="name"/>
|
||||
<x-v v-if="value.value.expression" v-model="value.value.expression" :title="$t(`_pages.script.blocks._fn.arg1`)" :get-expected-type="() => null" :hpml="hpml" :fn-slots="value.value.slots" :name="name"/>
|
||||
</section>
|
||||
<section v-else-if="value.type.startsWith('fn:')" class="" style="padding:16px;">
|
||||
<x-v v-for="(x, i) in value.args" v-model="value.args[i]" :title="aoiScript.getVarByName(value.type.split(':')[1]).value.slots[i].name" :get-expected-type="() => null" :aoi-script="aoiScript" :name="name" :key="i"/>
|
||||
<x-v v-for="(x, i) in value.args" v-model="value.args[i]" :title="hpml.getVarByName(value.type.split(':')[1]).value.slots[i].name" :get-expected-type="() => null" :hpml="hpml" :name="name" :key="i"/>
|
||||
</section>
|
||||
<section v-else class="" style="padding:16px;">
|
||||
<x-v v-for="(x, i) in value.args" v-model="value.args[i]" :title="$t(`_pages.script.blocks._${value.type}.arg${i + 1}`)" :get-expected-type="() => _getExpectedType(i)" :aoi-script="aoiScript" :name="name" :fn-slots="fnSlots" :key="i"/>
|
||||
<x-v v-for="(x, i) in value.args" v-model="value.args[i]" :title="$t(`_pages.script.blocks._${value.type}.arg${i + 1}`)" :get-expected-type="() => _getExpectedType(i)" :hpml="hpml" :name="name" :fn-slots="fnSlots" :key="i"/>
|
||||
</section>
|
||||
</x-container>
|
||||
</template>
|
||||
|
@ -62,7 +62,7 @@ import { v4 as uuid } from 'uuid';
|
|||
import i18n from '../../i18n';
|
||||
import XContainer from './page-editor.container.vue';
|
||||
import MkTextarea from '../../components/ui/textarea.vue';
|
||||
import { isLiteralBlock, funcDefs, blockDefs } from '../../scripts/aoiscript/index';
|
||||
import { isLiteralBlock, funcDefs, blockDefs } from '../../scripts/hpml/index';
|
||||
|
||||
export default Vue.extend({
|
||||
i18n,
|
||||
|
@ -88,7 +88,7 @@ export default Vue.extend({
|
|||
required: false,
|
||||
default: false
|
||||
},
|
||||
aoiScript: {
|
||||
hpml: {
|
||||
required: true,
|
||||
},
|
||||
name: {
|
||||
|
@ -156,7 +156,7 @@ export default Vue.extend({
|
|||
|
||||
if (this.value.type && this.value.type.startsWith('fn:')) {
|
||||
const fnName = this.value.type.split(':')[1];
|
||||
const fn = this.aoiScript.getVarByName(fnName);
|
||||
const fn = this.hpml.getVarByName(fnName);
|
||||
|
||||
const empties = [];
|
||||
for (let i = 0; i < fn.value.slots.length; i++) {
|
||||
|
@ -202,9 +202,9 @@ export default Vue.extend({
|
|||
deep: true
|
||||
});
|
||||
|
||||
this.$watch('aoiScript.variables', () => {
|
||||
this.$watch('hpml.variables', () => {
|
||||
if (this.type != null && this.value) {
|
||||
this.error = this.aoiScript.typeCheck(this.value);
|
||||
this.error = this.hpml.typeCheck(this.value);
|
||||
}
|
||||
}, {
|
||||
deep: true
|
||||
|
@ -226,7 +226,7 @@ export default Vue.extend({
|
|||
},
|
||||
|
||||
_getExpectedType(slot: number) {
|
||||
return this.aoiScript.getExpectedType(this.value, slot);
|
||||
return this.hpml.getExpectedType(this.value, slot);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
</div>
|
||||
</template>
|
||||
|
||||
<x-blocks class="content" v-model="content" :aoi-script="aoiScript"/>
|
||||
<x-blocks class="content" v-model="content" :hpml="hpml"/>
|
||||
|
||||
<mk-button @click="add()" v-if="!readonly"><fa :icon="faPlus"/></mk-button>
|
||||
</section>
|
||||
|
@ -62,7 +62,7 @@
|
|||
@input="v => updateVariable(v)"
|
||||
@remove="() => removeVariable(variable)"
|
||||
:key="variable.name"
|
||||
:aoi-script="aoiScript"
|
||||
:hpml="hpml"
|
||||
:name="variable.name"
|
||||
:title="variable.name"
|
||||
:draggable="true"
|
||||
|
@ -100,8 +100,8 @@ import MkButton from '../../components/ui/button.vue';
|
|||
import MkSelect from '../../components/ui/select.vue';
|
||||
import MkSwitch from '../../components/ui/switch.vue';
|
||||
import MkInput from '../../components/ui/input.vue';
|
||||
import { blockDefs } from '../../scripts/aoiscript/index';
|
||||
import { ASTypeChecker } from '../../scripts/aoiscript/type-checker';
|
||||
import { blockDefs } from '../../scripts/hpml/index';
|
||||
import { HpmlTypeChecker } from '../../scripts/hpml/type-checker';
|
||||
import { url } from '../../config';
|
||||
import { collectPageVars } from '../../scripts/collect-page-vars';
|
||||
import { selectDriveFile } from '../../scripts/select-drive-file';
|
||||
|
@ -145,7 +145,7 @@ export default Vue.extend({
|
|||
alignCenter: false,
|
||||
hideTitleWhenPinned: false,
|
||||
variables: [],
|
||||
aoiScript: null,
|
||||
hpml: null,
|
||||
script: '',
|
||||
showOptions: false,
|
||||
url,
|
||||
|
@ -166,14 +166,14 @@ export default Vue.extend({
|
|||
},
|
||||
|
||||
async created() {
|
||||
this.aoiScript = new ASTypeChecker();
|
||||
this.hpml = new HpmlTypeChecker();
|
||||
|
||||
this.$watch('variables', () => {
|
||||
this.aoiScript.variables = this.variables;
|
||||
this.hpml.variables = this.variables;
|
||||
}, { deep: true });
|
||||
|
||||
this.$watch('content', () => {
|
||||
this.aoiScript.pageVars = collectPageVars(this.content);
|
||||
this.hpml.pageVars = collectPageVars(this.content);
|
||||
}, { deep: true });
|
||||
|
||||
if (this.initPageId) {
|
||||
|
@ -322,7 +322,7 @@ export default Vue.extend({
|
|||
|
||||
name = name.trim();
|
||||
|
||||
if (this.aoiScript.isUsedName(name)) {
|
||||
if (this.hpml.isUsedName(name)) {
|
||||
this.$root.dialog({
|
||||
type: 'error',
|
||||
text: this.$t('_pages.variableNameIsAlreadyUsed')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue