This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/controllers/edit-topic-auto-close.js.es6
Régis Hanol 0947191060 UX: improved our footer handling
- new "show-footer" mixins
- converted most of the routes to ES6
- FIX: handling of "indexStream" in user pages

There will now be a footer on all the following pages
- /exception
- /about
- /latest
- /new
- /unread
- /starred
- /top
- /categories
- /c/:category
- /c/:category/l/latest
- /c/:category/l/new
- /c/:category/l/unread
- /c/:category/l/top
- /t/:topic/:id
- /groups/:name/members
- /user/activity
- /user/activity/topics
- /user/activity/posts
- /user/activity/replies
- /user/activity/likes-given
- /user/activity/likes-received
- /user/activity/bookmarks
- /user/activity/starred
- /user/badges
- /user/notifications
- /user/flagged-posts
- /user/deleted-posts
- /user/private-messages
- /user/private-messages/mine
- /user/private-messages/unread
- /user/invited
- /user/:username/preferences
- /faq (static pages)
- /badges
- /badges/:id/:badge
2014-11-19 20:37:43 +01:00

54 lines
1.8 KiB
JavaScript

import ModalFunctionality from 'discourse/mixins/modal-functionality';
import ObjectController from 'discourse/controllers/object';
// Modal related to auto closing of topics
export default ObjectController.extend(ModalFunctionality, {
auto_close_valid: true,
auto_close_invalid: Em.computed.not('auto_close_valid'),
setAutoCloseTime: function() {
var autoCloseTime = null;
if (this.get("details.auto_close_based_on_last_post")) {
autoCloseTime = this.get("details.auto_close_hours");
} else if (this.get("details.auto_close_at")) {
var closeTime = new Date(this.get("details.auto_close_at"));
if (closeTime > new Date()) {
autoCloseTime = moment(closeTime).format("YYYY-MM-DD HH:mm");
}
}
this.set("auto_close_time", autoCloseTime);
}.observes("details.{auto_close_at,auto_close_hours}"),
actions: {
saveAutoClose: function() { this.setAutoClose(this.get("auto_close_time")); },
removeAutoClose: function() { this.setAutoClose(null); }
},
setAutoClose: function(time) {
var self = this;
this.send('hideModal');
Discourse.ajax({
url: '/t/' + this.get('id') + '/autoclose',
type: 'PUT',
dataType: 'json',
data: {
auto_close_time: time,
auto_close_based_on_last_post: this.get("details.auto_close_based_on_last_post"),
}
}).then(function(result){
if (result.success) {
self.send('closeModal');
self.set('details.auto_close_at', result.auto_close_at);
self.set('details.auto_close_hours', result.auto_close_hours);
} else {
bootbox.alert(I18n.t('composer.auto_close.error'), function() { self.send('showModal'); } );
}
}, function () {
bootbox.alert(I18n.t('composer.auto_close.error'), function() { self.send('showModal'); } );
});
}
});