summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2019-07-07 05:12:31 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2019-07-07 05:12:31 +0900
commite9251debe067077c91b7505d310f53388ed4944d (patch)
treea892f94592c1fd5e340e9698264c538993a018cd /src
parentPages: ボタンを色付き表示できるように (diff)
downloadsharkey-e9251debe067077c91b7505d310f53388ed4944d.tar.gz
sharkey-e9251debe067077c91b7505d310f53388ed4944d.tar.bz2
sharkey-e9251debe067077c91b7505d310f53388ed4944d.zip
イベント送信時に指定の変数の値を添付出来るように
Diffstat (limited to 'src')
-rw-r--r--src/client/app/common/views/pages/page-editor/els/page-editor.el.button.vue17
-rw-r--r--src/client/app/common/views/pages/page/page.button.vue5
-rw-r--r--src/server/api/endpoints/page-push.ts5
3 files changed, 25 insertions, 2 deletions
diff --git a/src/client/app/common/views/pages/page-editor/els/page-editor.el.button.vue b/src/client/app/common/views/pages/page-editor/els/page-editor.el.button.vue
index 04001d8560..6a82b0eec9 100644
--- a/src/client/app/common/views/pages/page-editor/els/page-editor.el.button.vue
+++ b/src/client/app/common/views/pages/page-editor/els/page-editor.el.button.vue
@@ -17,6 +17,17 @@
<template v-else-if="value.action === 'pushEvent'">
<ui-input v-model="value.event"><span>{{ $t('blocks._button._action._pushEvent.event') }}</span></ui-input>
<ui-input v-model="value.message"><span>{{ $t('blocks._button._action._pushEvent.message') }}</span></ui-input>
+ <ui-select v-model="value.var">
+ <template #label>{{ $t('blocks._button._action._pushEvent.variable') }}</template>
+ <option :value="null">{{ $t('blocks._button._action._pushEvent.no-variable') }}</option>
+ <option v-for="v in aiScript.getVarsByType()" :value="v.name">{{ v.name }}</option>
+ <optgroup :label="$t('script.pageVariables')">
+ <option v-for="v in aiScript.getPageVarsByType()" :value="v">{{ v }}</option>
+ </optgroup>
+ <optgroup :label="$t('script.enviromentVariables')">
+ <option v-for="v in aiScript.getEnvVarsByType()" :value="v">{{ v }}</option>
+ </optgroup>
+ </ui-select>
</template>
</section>
</x-container>
@@ -39,6 +50,9 @@ export default Vue.extend({
value: {
required: true
},
+ aiScript: {
+ required: true,
+ },
},
data() {
@@ -53,7 +67,8 @@ export default Vue.extend({
if (this.value.content == null) Vue.set(this.value, 'content', null);
if (this.value.event == null) Vue.set(this.value, 'event', null);
if (this.value.message == null) Vue.set(this.value, 'message', null);
- if (this.value.message == null) Vue.set(this.value, 'primary', false);
+ if (this.value.primary == null) Vue.set(this.value, 'primary', false);
+ if (this.value.var == null) Vue.set(this.value, 'var', null);
},
});
</script>
diff --git a/src/client/app/common/views/pages/page/page.button.vue b/src/client/app/common/views/pages/page/page.button.vue
index d3f0307625..4dc6570019 100644
--- a/src/client/app/common/views/pages/page/page.button.vue
+++ b/src/client/app/common/views/pages/page/page.button.vue
@@ -30,7 +30,10 @@ export default Vue.extend({
} else if (this.value.action === 'pushEvent') {
this.$root.api('page-push', {
pageId: this.script.page.id,
- event: this.value.event
+ event: this.value.event,
+ ...(this.value.var ? {
+ var: this.script.vars[this.value.var]
+ } : {})
});
this.$root.dialog({
diff --git a/src/server/api/endpoints/page-push.ts b/src/server/api/endpoints/page-push.ts
index 300df7c250..f5e1a4d1eb 100644
--- a/src/server/api/endpoints/page-push.ts
+++ b/src/server/api/endpoints/page-push.ts
@@ -16,6 +16,10 @@ export const meta = {
event: {
validator: $.str
+ },
+
+ var: {
+ validator: $.optional.nullable.any
}
},
@@ -37,6 +41,7 @@ export default define(meta, async (ps, user) => {
publishMainStream(user.id, 'pageEvent', {
pageId: ps.pageId,
event: ps.event,
+ var: ps.var,
user: await Users.pack(user, page.userId, {
detail: true
})