From 8c11ab02395a1a61ff7772aa13bcafd0015aed17 Mon Sep 17 00:00:00 2001 From: Oni-Men Date: Mon, 2 Sep 2019 06:02:35 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=9A=E3=83=BC=E3=82=B8URL=E3=81=8C?= =?UTF-8?q?=E7=A9=BA=E3=81=AE=E6=99=82currentName=E3=82=92=E4=BD=BF?= =?UTF-8?q?=E3=81=86=E3=82=88=E3=81=86=E3=81=AB=20(#5368)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ページURLが空の時currentNameを使う * 空の時はページURLにcurrentNameを代入するように * Update src/client/app/common/views/pages/page-editor/page-editor.vue Co-Authored-By: Acid Chicken (硫酸鶏) * update validator * Update src/client/app/common/views/pages/page-editor/page-editor.vue Co-Authored-By: Acid Chicken (硫酸鶏) * やっぱりuuidは統一 * エラー処理を追加 * some fix * ちょっとだけ翻訳の追加と改善 * リファクタリング * Revert "やっぱりuuidは統一" This reverts commit 965a860504e8b09e5561a4ab862f8bab6a95e8d5. * やっぱりuuidをわける * エラー判定をidからcodeに+リファクタリング --- locales/ja-JP.yml | 2 ++ .../views/pages/page-editor/page-editor.vue | 31 ++++++++++++------- src/server/api/endpoints/pages/create.ts | 2 +- src/server/api/endpoints/pages/update.ts | 2 +- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index e5a37fdc2..b139b3829 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -2020,6 +2020,8 @@ pages: page-created: "ページを作成しました" page-updated: "ページを更新しました" name-already-exists: "指定されたページURLは既に存在しています" + title-invalid-name: "不正なページURLです" + text-invalid-name: "空白でないか確認してください" are-you-sure-delete: "このページを削除しますか?" page-deleted: "ページを削除しました" edit-this-page: "このページを編集" 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 b8db59da4..0e7417700 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 @@ -232,6 +232,23 @@ export default Vue.extend({ eyeCatchingImageId: this.eyeCatchingImageId, }; + function onError(err) { + if (err.id == '3d81ceae-475f-4600-b2a8-2bc116157532') { + if (err.info.param == 'name') { + this.$root.dialog({ + type: 'error', + title: this.$t('title-invalid-name'), + text: this.$t('text-invalid-name') + }); + } + } else if (err.code == 'NAME_ALREADY_EXISTS') { + this.$root.dialog({ + type: 'error', + text: this.$t('name-already-exists') + }); + } + } + if (this.pageId) { options.pageId = this.pageId; this.$root.api('pages/update', options) @@ -242,12 +259,7 @@ export default Vue.extend({ text: this.$t('page-updated') }); }).catch(err => { - if(err.id == '2298a392-d4a1-44c5-9ebb-ac1aeaa5a9ab'){ - this.$root.dialog({ - type: 'error', - text: this.$t('name-already-exists') - }); - } + onError(err); }); } else { this.$root.api('pages/create', options) @@ -260,12 +272,7 @@ export default Vue.extend({ }); this.$router.push(`/i/pages/edit/${this.pageId}`); }).catch(err => { - if(err.id == '4650348e-301c-499a-83c9-6aa988c66bc1'){ - this.$root.dialog({ - type: 'error', - text: this.$t('name-already-exists') - }); - } + onError(err); }); } }, diff --git a/src/server/api/endpoints/pages/create.ts b/src/server/api/endpoints/pages/create.ts index f18c82ffd..62077fa95 100644 --- a/src/server/api/endpoints/pages/create.ts +++ b/src/server/api/endpoints/pages/create.ts @@ -29,7 +29,7 @@ export const meta = { }, name: { - validator: $.str, + validator: $.str.min(1), }, summary: { diff --git a/src/server/api/endpoints/pages/update.ts b/src/server/api/endpoints/pages/update.ts index 564beb84c..e98aedefa 100644 --- a/src/server/api/endpoints/pages/update.ts +++ b/src/server/api/endpoints/pages/update.ts @@ -36,7 +36,7 @@ export const meta = { }, name: { - validator: $.optional.str, + validator: $.str.min(1), }, summary: {