From e3ec0ad97e988467301488624f3c74aeec26b477 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 5 Nov 2018 10:40:01 +0900 Subject: [PATCH] [Client] Improve admin panel usability --- locales/ja-JP.yml | 3 ++ src/client/app/admin/views/announcements.vue | 29 ++++++++++++++------ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 4d87859d8..2650d3c21 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1151,6 +1151,9 @@ admin/views/announcements.vue: title: "タイトル" text: "内容" saved: "保存しました" + _remove: + are-you-sure: "「$1」を削除しますか?" + removed: "削除しました" admin/views/hashtags.vue: hided-tags: "Hidden Tags" diff --git a/src/client/app/admin/views/announcements.vue b/src/client/app/admin/views/announcements.vue index 926426844..bd99e1bc0 100644 --- a/src/client/app/admin/views/announcements.vue +++ b/src/client/app/admin/views/announcements.vue @@ -10,7 +10,7 @@ %i18n:@text% - %fa:save R% %i18n:@save% + %fa:save R% %i18n:@save% %fa:trash-alt R% %i18n:@remove% @@ -46,18 +46,31 @@ export default Vue.extend({ }, remove(i) { - this.announcements = this.announcements.filter((_, j) => j !== i); - this.save(); + this.$swal({ + type: 'warning', + text: '%i18n:@_remove.are-you-sure%'.replace('$1', this.announcements.find((_, j) => j == i).title), + showCancelButton: true + }).then(res => { + if (!res.value) return; + this.announcements = this.announcements.filter((_, j) => j !== i); + this.save(true); + this.$swal({ + type: 'success', + text: '%i18n:@_remove.removed%' + }); + }); }, - save() { + save(silent) { (this as any).api('admin/update-meta', { broadcasts: this.announcements }).then(() => { - this.$swal({ - type: 'success', - text: '%i18n:@saved%' - }); + if (!silent) { + this.$swal({ + type: 'success', + text: '%i18n:@saved%' + }); + } }).catch(e => { this.$swal({ type: 'error',