mirror of
https://github.com/flarum/framework.git
synced 2024-12-05 00:43:39 +08:00
74e80ea2df
- Write CSS for everything, update templates. - Refactor discussion view. Stream is split into two components (content and scrubber) which have their own responsibilities. - Extract pane functionality into a mixin. - Implement global “back button” system. You give a “paneable” target to the application controller, the back button will modulate its pane-related properties as necessary, and call an action when the button is clicked. - Extract welcome-hero into its own component. - Lots of other general improvements/refactoring. The code is quite well-commented so take a look!
55 lines
1.8 KiB
JavaScript
55 lines
1.8 KiB
JavaScript
import Ember from 'ember';
|
|
|
|
import PostStream from '../models/post-stream';
|
|
|
|
export default Ember.ObjectController.extend(Ember.Evented, {
|
|
|
|
needs: ['application', 'composer'],
|
|
|
|
queryParams: ['start'],
|
|
start: '1',
|
|
searchQuery: '',
|
|
|
|
loaded: false,
|
|
stream: null,
|
|
|
|
setup: function(discussion) {
|
|
this.set('model', discussion);
|
|
|
|
// Set up the post stream object. It needs to know about the discussion
|
|
// its representing the posts for, and we also need to inject the Ember
|
|
// data store.
|
|
var stream = PostStream.create();
|
|
stream.set('discussion', discussion);
|
|
stream.set('store', this.get('store'));
|
|
this.set('stream', stream);
|
|
|
|
// Next, we need to load a list of the discussion's post IDs into the
|
|
// post stream object. If we don't already have this information, we'll
|
|
// need to reload the discussion model.
|
|
var promise = discussion.get('posts') ? Ember.RSVP.resolve(discussion) : discussion.reload();
|
|
|
|
// When we know we have the post IDs, we can set up the post stream with
|
|
// them. Then the view will trigger the stream to load as it sees fit.
|
|
var controller = this;
|
|
promise.then(function(discussion) {
|
|
stream.setup(discussion.get('postIds'));
|
|
controller.set('loaded', true);
|
|
});
|
|
},
|
|
|
|
actions: {
|
|
reply: function() {
|
|
this.set('controllers.composer.showing', true);
|
|
this.set('controllers.composer.title', 'Replying to <em>'+this.get('model.title')+'</em>');
|
|
},
|
|
|
|
// This action is called when the start position of the discussion
|
|
// currently being viewed changes (i.e. when the user scrolls up/down
|
|
// the post stream.)
|
|
updateStart: function(start) {
|
|
this.set('start', start);
|
|
}
|
|
}
|
|
});
|