1
0
mirror of https://github.com/flarum/core.git synced 2025-08-09 09:57:06 +02:00

Work on composer, early implementation of replying

This commit is contained in:
Toby Zerner
2015-01-30 12:22:19 +10:30
parent edce73d6e9
commit 12622e6c28
11 changed files with 229 additions and 72 deletions

View File

@@ -0,0 +1,42 @@
import Ember from 'ember';
export default Ember.Controller.extend({
needs: ['index', 'application'],
user: Ember.Object.create({avatarNumber: 1}),
discussion: null,
showing: true,
minimized: false,
title: 'Replying to <em>Some Discussion Title</em>',
actions: {
close: function() {
this.set('showing', false);
},
minimize: function() {
this.set('minimized', true);
},
show: function() {
this.set('minimized', false);
},
save: function(value) {
var store = this.store;
var discussion = this.get('discussion');
var controller = this;
var post = store.createRecord('post', {
content: value,
discussion: discussion
});
post.save().then(function(post) {
discussion.set('posts', discussion.get('posts')+','+post.get('id'));
controller.get('delegate').send('replyAdded', post);
});
}
}
});

View File

@@ -40,8 +40,26 @@ export default Ember.ObjectController.extend(Ember.Evented, {
actions: {
reply: function() {
this.set('controllers.composer.showing', true);
this.set('controllers.composer.title', 'Replying to <em>'+this.get('model.title')+'</em>');
var composer = this.get('controllers.composer');
// composer.beginPropertyChanges();
composer.set('minimized', false);
composer.set('showing', true);
composer.set('title', 'Replying to <em>'+this.get('model.title')+'</em>');
composer.set('delegate', this);
composer.set('discussion', this.get('model'));
// composer.endPropertyChanges();
},
replyAdded: function(post) {
var stream = this.get('stream');
stream.set('ids', this.get('model.postIds'));
var index = stream.get('count') - 1;
stream.get('content').pushObject(Ember.Object.create({
indexStart: index,
indexEnd: index,
content: post
}));
this.get('controllers.composer').set('showing', false);
},
// This action is called when the start position of the discussion