From 2e8e5c2751aba86a03c564dc7aa2dc7e595caac5 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 30 Apr 2019 06:40:02 +0900 Subject: [PATCH] Improve MisskeyPages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ifブロック を追加 * ボタンやスイッチなどのテキストに変数使えるようにした --- locales/ja-JP.yml | 4 + .../page-editor.el.button.vue} | 4 +- .../page-editor/els/page-editor.el.if.vue | 113 ++++++++++++++++++ .../page-editor.el.image.vue} | 6 +- .../page-editor.el.input.vue} | 4 +- .../page-editor.el.section.vue} | 29 ++--- .../page-editor.el.switch.vue} | 4 +- .../page-editor.el.text.vue} | 4 +- .../page-editor/page-editor.block.vue | 22 ++-- .../components/page-editor/page-editor.vue | 62 ++++++---- .../common/views/pages/page/page.block.vue | 3 +- .../common/views/pages/page/page.button.vue | 2 +- .../app/common/views/pages/page/page.if.vue | 30 +++++ .../common/views/pages/page/page.input.vue | 2 +- .../common/views/pages/page/page.switch.vue | 2 +- .../app/common/views/pages/page/page.vue | 1 + 16 files changed, 227 insertions(+), 65 deletions(-) rename src/client/app/common/views/components/page-editor/{page-editor.button.vue => els/page-editor.el.button.vue} (93%) create mode 100644 src/client/app/common/views/components/page-editor/els/page-editor.el.if.vue rename src/client/app/common/views/components/page-editor/{page-editor.image.vue => els/page-editor.el.image.vue} (89%) rename src/client/app/common/views/components/page-editor/{page-editor.input.vue => els/page-editor.el.input.vue} (94%) rename src/client/app/common/views/components/page-editor/{page-editor.section.vue => els/page-editor.el.section.vue} (80%) rename src/client/app/common/views/components/page-editor/{page-editor.switch.vue => els/page-editor.el.switch.vue} (91%) rename src/client/app/common/views/components/page-editor/{page-editor.text.vue => els/page-editor.el.text.vue} (90%) create mode 100644 src/client/app/common/views/pages/page/page.if.vue diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index e2bfb2e89..343d9cfc3 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1842,6 +1842,7 @@ dev/views/new-app.vue: pages: new-page: "ページの作成" edit-page: "ページの編集" + read-page: "ソースを表示中" page-created: "ページを作成しました" page-updated: "ページを更新しました" are-you-sure-delete: "このページを削除しますか?" @@ -1871,6 +1872,9 @@ pages: section: "セクション" image: "画像" button: "ボタン" + if: "もし" + _if: + variable: "変数" input: "ユーザー入力" _input: name: "変数名" diff --git a/src/client/app/common/views/components/page-editor/page-editor.button.vue b/src/client/app/common/views/components/page-editor/els/page-editor.el.button.vue similarity index 93% rename from src/client/app/common/views/components/page-editor/page-editor.button.vue rename to src/client/app/common/views/components/page-editor/els/page-editor.el.button.vue index d5fc24381..3e2d3fe19 100644 --- a/src/client/app/common/views/components/page-editor/page-editor.button.vue +++ b/src/client/app/common/views/components/page-editor/els/page-editor.el.button.vue @@ -16,9 +16,9 @@ + + diff --git a/src/client/app/common/views/components/page-editor/page-editor.image.vue b/src/client/app/common/views/components/page-editor/els/page-editor.el.image.vue similarity index 89% rename from src/client/app/common/views/components/page-editor/page-editor.image.vue rename to src/client/app/common/views/components/page-editor/els/page-editor.el.image.vue index 0bc1816e8..5ada8c77b 100644 --- a/src/client/app/common/views/components/page-editor/page-editor.image.vue +++ b/src/client/app/common/views/components/page-editor/els/page-editor.el.image.vue @@ -15,11 +15,11 @@ diff --git a/src/client/app/common/views/components/page-editor/page-editor.vue b/src/client/app/common/views/components/page-editor/page-editor.vue index 8b2582851..f39985952 100644 --- a/src/client/app/common/views/components/page-editor/page-editor.vue +++ b/src/client/app/common/views/components/page-editor/page-editor.vue @@ -2,16 +2,16 @@
-
{{ pageId ? $t('edit-page') : $t('new-page') }}
+
{{ readonly ? $t('read-page') : pageId ? $t('edit-page') : $t('new-page') }}
- + - +
- {{ $t('view-page') }} + {{ $t('view-page') }} {{ $t('title') }} @@ -23,7 +23,7 @@ - + {{ $t('url') }} @@ -45,10 +45,10 @@
- +
- +
@@ -70,7 +70,7 @@
- + {{ $t('more-details') }} @@ -106,11 +106,17 @@ export default Vue.extend({ page: { type: String, required: false - } + }, + readonly: { + type: Boolean, + required: false, + default: false + }, }, data() { return { + author: this.$store.state.i, pageId: null, currentName: null, title: '', @@ -157,6 +163,7 @@ export default Vue.extend({ this.$root.api('pages/show', { pageId: this.page, }).then(page => { + this.author = page.user; this.pageId = page.id; this.title = page.title; this.name = page.name; @@ -180,7 +187,9 @@ export default Vue.extend({ provide() { return { - getScriptBlockList: this.getScriptBlockList + readonly: this.readonly, + getScriptBlockList: this.getScriptBlockList, + getPageBlockList: this.getPageBlockList } }, @@ -250,19 +259,7 @@ export default Vue.extend({ type: null, title: this.$t('choose-block'), select: { - items: [{ - value: 'section', text: this.$t('blocks.section') - }, { - value: 'text', text: this.$t('blocks.text') - }, { - value: 'image', text: this.$t('blocks.image') - }, { - value: 'button', text: this.$t('blocks.button') - }, { - value: 'input', text: this.$t('blocks.input') - }, { - value: 'switch', text: this.$t('blocks.switch') - }] + items: this.getPageBlockList() }, showCancelButton: true }); @@ -324,6 +321,24 @@ export default Vue.extend({ this.variables = newValue; }, + getPageBlockList() { + return [{ + value: 'section', text: this.$t('blocks.section') + }, { + value: 'text', text: this.$t('blocks.text') + }, { + value: 'image', text: this.$t('blocks.image') + }, { + value: 'button', text: this.$t('blocks.button') + }, { + value: 'input', text: this.$t('blocks.input') + }, { + value: 'switch', text: this.$t('blocks.switch') + }, { + value: 'if', text: this.$t('blocks.if') + }]; + }, + getScriptBlockList(type: string = null) { const list = []; @@ -436,6 +451,7 @@ export default Vue.extend({ > .view display inline-block margin 16px 0 0 0 + font-size 14px > .content margin-bottom 16px diff --git a/src/client/app/common/views/pages/page/page.block.vue b/src/client/app/common/views/pages/page/page.block.vue index 48a89f9de..e3a758ed4 100644 --- a/src/client/app/common/views/pages/page/page.block.vue +++ b/src/client/app/common/views/pages/page/page.block.vue @@ -10,10 +10,11 @@ import XImage from './page.image.vue'; import XButton from './page.button.vue'; import XInput from './page.input.vue'; import XSwitch from './page.switch.vue'; +import XIf from './page.if.vue'; export default Vue.extend({ components: { - XText, XSection, XImage, XButton, XInput, XSwitch + XText, XSection, XImage, XButton, XInput, XSwitch, XIf }, props: { 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 5063d2712..b77d856d5 100644 --- a/src/client/app/common/views/pages/page/page.button.vue +++ b/src/client/app/common/views/pages/page/page.button.vue @@ -1,6 +1,6 @@ diff --git a/src/client/app/common/views/pages/page/page.if.vue b/src/client/app/common/views/pages/page/page.if.vue new file mode 100644 index 000000000..9dbeaf64f --- /dev/null +++ b/src/client/app/common/views/pages/page/page.if.vue @@ -0,0 +1,30 @@ + + + diff --git a/src/client/app/common/views/pages/page/page.input.vue b/src/client/app/common/views/pages/page/page.input.vue index cda555033..9f4cfd91f 100644 --- a/src/client/app/common/views/pages/page/page.input.vue +++ b/src/client/app/common/views/pages/page/page.input.vue @@ -1,6 +1,6 @@ diff --git a/src/client/app/common/views/pages/page/page.switch.vue b/src/client/app/common/views/pages/page/page.switch.vue index 962ab84bb..d36ecbfba 100644 --- a/src/client/app/common/views/pages/page/page.switch.vue +++ b/src/client/app/common/views/pages/page/page.switch.vue @@ -1,6 +1,6 @@ diff --git a/src/client/app/common/views/pages/page/page.vue b/src/client/app/common/views/pages/page/page.vue index e7e8f76d5..7cbd3ed81 100644 --- a/src/client/app/common/views/pages/page/page.vue +++ b/src/client/app/common/views/pages/page/page.vue @@ -38,6 +38,7 @@ class Script { } public interpolate(str: string) { + if (str == null) return null; return str.replace(/\{(.+?)\}/g, match => { const v = this.vars.find(x => x.name === match.slice(1, -1).trim()).value; return v == null ? 'NULL' : v.toString();