Update `Topic#closed` client side when closing/opening a topic temporarily.

This commit is contained in:
Guo Xiang Tan 2017-03-31 15:02:36 +08:00
parent ed577fbff8
commit b6e9871b4b
4 changed files with 5 additions and 2 deletions

View File

@ -71,6 +71,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
this.send('closeModal');
this.set('topicStatusUpdate.execute_at', result.execute_at);
this.set('topicStatusUpdate.duration', result.duration);
this.set('model.closed', result.closed);
} else {
this.set('topicStatusUpdate', Ember.Object.create({}));
this.set('selection', null);

View File

@ -347,7 +347,6 @@ export default createWidget('topic-timeline', {
result.push(h('div.title', elems));
}
if (!attrs.fullScreen && currentUser && currentUser.get('canManageTopic')) {
result.push(h('div.timeline-controls', this.attach('topic-admin-menu-button', { topic })));
}

View File

@ -310,7 +310,8 @@ class TopicsController < ApplicationController
render json: success_json.merge!({
execute_at: topic_status_update&.execute_at,
duration: topic_status_update&.duration,
based_on_last_post: topic_status_update&.based_on_last_post
based_on_last_post: topic_status_update&.based_on_last_post,
closed: topic.closed
})
else
render_json_error(topic)

View File

@ -56,6 +56,7 @@ RSpec.describe "Managing a topic's status update", type: :request do
.to be_within(1.seconds).of(DateTime.parse(topic_status_update.execute_at.to_s))
expect(json['duration']).to eq(topic_status_update.duration)
expect(json['closed']).to eq(topic.reload.closed)
end
it 'should be able to delete a topic status update' do
@ -72,6 +73,7 @@ RSpec.describe "Managing a topic's status update", type: :request do
expect(json['execute_at']).to eq(nil)
expect(json['duration']).to eq(nil)
expect(json['closed']).to eq(topic.closed)
end
describe 'invalid status type' do