From b49579d9a79fb6762440b12527eb1c0490d3d4e8 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Thu, 6 Jul 2017 17:08:29 +0900 Subject: [PATCH] FIX: Disable topic status info when no category has been selected. --- .../discourse/components/auto-update-input.js.es6 | 10 ++++++++-- .../discourse/controllers/edit-topic-timer.js.es6 | 10 ++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/discourse/components/auto-update-input.js.es6 b/app/assets/javascripts/discourse/components/auto-update-input.js.es6 index 747c0617933..be97128e141 100644 --- a/app/assets/javascripts/discourse/components/auto-update-input.js.es6 +++ b/app/assets/javascripts/discourse/components/auto-update-input.js.es6 @@ -5,6 +5,8 @@ import { SET_BASED_ON_LAST_POST } from "discourse/components/auto-update-input-selector"; +import { PUBLISH_TO_CATEGORY_STATUS_TYPE } from 'discourse/controllers/edit-topic-timer'; + export default Ember.Component.extend({ selection: null, date: null, @@ -62,10 +64,14 @@ export default Ember.Component.extend({ } }, - @computed("statusType", "input", "isCustom", "date", "time", "willCloseImmediately") - showTopicStatusInfo(statusType, input, isCustom, date, time, willCloseImmediately) { + @computed("statusType", "input", "isCustom", "date", "time", "willCloseImmediately", "categoryId") + showTopicStatusInfo(statusType, input, isCustom, date, time, willCloseImmediately, categoryId) { if (!statusType || willCloseImmediately) return false; + if (statusType === PUBLISH_TO_CATEGORY_STATUS_TYPE && Ember.isEmpty(categoryId)) { + return false; + } + if (isCustom) { return date || time; } else { diff --git a/app/assets/javascripts/discourse/controllers/edit-topic-timer.js.es6 b/app/assets/javascripts/discourse/controllers/edit-topic-timer.js.es6 index c04c3524e1d..fdb66c1a65f 100644 --- a/app/assets/javascripts/discourse/controllers/edit-topic-timer.js.es6 +++ b/app/assets/javascripts/discourse/controllers/edit-topic-timer.js.es6 @@ -5,7 +5,7 @@ import { popupAjaxError } from 'discourse/lib/ajax-error'; export const CLOSE_STATUS_TYPE = 'close'; const OPEN_STATUS_TYPE = 'open'; -const PUBLISH_TO_CATEGORY_STATUS_TYPE = 'publish_to_category'; +export const PUBLISH_TO_CATEGORY_STATUS_TYPE = 'publish_to_category'; const DELETE_STATUS_TYPE = 'delete'; const REMINDER_TYPE = 'reminder'; @@ -33,9 +33,11 @@ export default Ember.Controller.extend(ModalFunctionality, { ]; }, - @computed('updateTime', 'loading') - saveDisabled(updateTime, loading) { - return Ember.isEmpty(updateTime) || loading; + @computed('updateTime', 'loading', 'publishToCategory', 'topicTimer.category_id') + saveDisabled(updateTime, loading, publishToCategory, topicTimerCategoryId) { + return Ember.isEmpty(updateTime) || + loading || + (publishToCategory && !topicTimerCategoryId); }, @computed("model.visible")