From feec5e88fcb0b0d89931dba1c2032ea315b553bf Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 10 Jul 2019 18:30:51 +0900 Subject: [PATCH] Pages: Implement radio button --- locales/ja-JP.yml | 7 +++ .../app/common/scripts/collect-page-vars.ts | 6 +++ .../views/components/page/page.block.vue | 3 +- .../components/page/page.radio-button.vue | 37 +++++++++++++ .../els/page-editor.el.radio-button.vue | 53 +++++++++++++++++++ .../pages/page-editor/page-editor.blocks.vue | 3 +- .../views/pages/page-editor/page-editor.vue | 1 + 7 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 src/client/app/common/views/components/page/page.radio-button.vue create mode 100644 src/client/app/common/views/pages/page-editor/els/page-editor.el.radio-button.vue diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index d2776c45b..2efe8461e 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -2066,6 +2066,13 @@ pages: variable: "送信する変数" no-variable: "なし" + radioButton: "選択肢" + _radioButton: + name: "変数名" + title: "タイトル" + values: "改行で区切った選択肢" + default: "デフォルト値" + script: categories: flow: "制御" diff --git a/src/client/app/common/scripts/collect-page-vars.ts b/src/client/app/common/scripts/collect-page-vars.ts index 4c40d5d88..a4096fb2c 100644 --- a/src/client/app/common/scripts/collect-page-vars.ts +++ b/src/client/app/common/scripts/collect-page-vars.ts @@ -32,6 +32,12 @@ export function collectPageVars(content) { type: 'number', value: 0 }); + } else if (x.type === 'radioButton') { + pageVars.push({ + name: x.name, + type: 'string', + value: x.default || '' + }); } else if (x.children) { collect(x.children); } diff --git a/src/client/app/common/views/components/page/page.block.vue b/src/client/app/common/views/components/page/page.block.vue index 1c421fc2c..56d182201 100644 --- a/src/client/app/common/views/components/page/page.block.vue +++ b/src/client/app/common/views/components/page/page.block.vue @@ -16,10 +16,11 @@ import XIf from './page.if.vue'; import XTextarea from './page.textarea.vue'; import XPost from './page.post.vue'; import XCounter from './page.counter.vue'; +import XRadioButton from './page.radio-button.vue'; export default Vue.extend({ components: { - XText, XSection, XImage, XButton, XNumberInput, XTextInput, XTextareaInput, XTextarea, XPost, XSwitch, XIf, XCounter + XText, XSection, XImage, XButton, XNumberInput, XTextInput, XTextareaInput, XTextarea, XPost, XSwitch, XIf, XCounter, XRadioButton }, props: { diff --git a/src/client/app/common/views/components/page/page.radio-button.vue b/src/client/app/common/views/components/page/page.radio-button.vue new file mode 100644 index 000000000..27c11beba --- /dev/null +++ b/src/client/app/common/views/components/page/page.radio-button.vue @@ -0,0 +1,37 @@ + + + + + diff --git a/src/client/app/common/views/pages/page-editor/els/page-editor.el.radio-button.vue b/src/client/app/common/views/pages/page-editor/els/page-editor.el.radio-button.vue new file mode 100644 index 000000000..3401c46f4 --- /dev/null +++ b/src/client/app/common/views/pages/page-editor/els/page-editor.el.radio-button.vue @@ -0,0 +1,53 @@ + + + diff --git a/src/client/app/common/views/pages/page-editor/page-editor.blocks.vue b/src/client/app/common/views/pages/page-editor/page-editor.blocks.vue index c5f3419e7..4d7293231 100644 --- a/src/client/app/common/views/pages/page-editor/page-editor.blocks.vue +++ b/src/client/app/common/views/pages/page-editor/page-editor.blocks.vue @@ -19,10 +19,11 @@ import XSwitch from './els/page-editor.el.switch.vue'; import XIf from './els/page-editor.el.if.vue'; import XPost from './els/page-editor.el.post.vue'; import XCounter from './els/page-editor.el.counter.vue'; +import XRadioButton from './els/page-editor.el.radio-button.vue'; export default Vue.extend({ components: { - XDraggable, XSection, XText, XImage, XButton, XTextarea, XTextInput, XTextareaInput, XNumberInput, XSwitch, XIf, XPost, XCounter + XDraggable, XSection, XText, XImage, XButton, XTextarea, XTextInput, XTextareaInput, XNumberInput, XSwitch, XIf, XPost, XCounter, XRadioButton }, props: { diff --git a/src/client/app/common/views/pages/page-editor/page-editor.vue b/src/client/app/common/views/pages/page-editor/page-editor.vue index ade7d8699..0162915c3 100644 --- a/src/client/app/common/views/pages/page-editor/page-editor.vue +++ b/src/client/app/common/views/pages/page-editor/page-editor.vue @@ -342,6 +342,7 @@ export default Vue.extend({ label: this.$t('input-blocks'), items: [ { value: 'button', text: this.$t('blocks.button') }, + { value: 'radioButton', text: this.$t('blocks.radioButton') }, { value: 'textInput', text: this.$t('blocks.textInput') }, { value: 'textareaInput', text: this.$t('blocks.textareaInput') }, { value: 'numberInput', text: this.$t('blocks.numberInput') },