FIX: Disable topic status info when no category has been selected.

This commit is contained in:
Guo Xiang Tan 2017-07-06 17:08:29 +09:00
parent f6491ee125
commit b49579d9a7
2 changed files with 14 additions and 6 deletions

View File

@ -5,6 +5,8 @@ import {
SET_BASED_ON_LAST_POST SET_BASED_ON_LAST_POST
} from "discourse/components/auto-update-input-selector"; } from "discourse/components/auto-update-input-selector";
import { PUBLISH_TO_CATEGORY_STATUS_TYPE } from 'discourse/controllers/edit-topic-timer';
export default Ember.Component.extend({ export default Ember.Component.extend({
selection: null, selection: null,
date: null, date: null,
@ -62,10 +64,14 @@ export default Ember.Component.extend({
} }
}, },
@computed("statusType", "input", "isCustom", "date", "time", "willCloseImmediately") @computed("statusType", "input", "isCustom", "date", "time", "willCloseImmediately", "categoryId")
showTopicStatusInfo(statusType, input, isCustom, date, time, willCloseImmediately) { showTopicStatusInfo(statusType, input, isCustom, date, time, willCloseImmediately, categoryId) {
if (!statusType || willCloseImmediately) return false; if (!statusType || willCloseImmediately) return false;
if (statusType === PUBLISH_TO_CATEGORY_STATUS_TYPE && Ember.isEmpty(categoryId)) {
return false;
}
if (isCustom) { if (isCustom) {
return date || time; return date || time;
} else { } else {

View File

@ -5,7 +5,7 @@ import { popupAjaxError } from 'discourse/lib/ajax-error';
export const CLOSE_STATUS_TYPE = 'close'; export const CLOSE_STATUS_TYPE = 'close';
const OPEN_STATUS_TYPE = 'open'; 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 DELETE_STATUS_TYPE = 'delete';
const REMINDER_TYPE = 'reminder'; const REMINDER_TYPE = 'reminder';
@ -33,9 +33,11 @@ export default Ember.Controller.extend(ModalFunctionality, {
]; ];
}, },
@computed('updateTime', 'loading') @computed('updateTime', 'loading', 'publishToCategory', 'topicTimer.category_id')
saveDisabled(updateTime, loading) { saveDisabled(updateTime, loading, publishToCategory, topicTimerCategoryId) {
return Ember.isEmpty(updateTime) || loading; return Ember.isEmpty(updateTime) ||
loading ||
(publishToCategory && !topicTimerCategoryId);
}, },
@computed("model.visible") @computed("model.visible")