mirror of
https://github.com/flarum/framework.git
synced 2024-11-23 07:22:15 +08:00
Rename and delete discussion controls
This commit is contained in:
parent
6138825db6
commit
87159bd9a0
|
@ -102,6 +102,19 @@ export default Ember.Controller.extend(Ember.Evented, UseComposerMixin, {
|
||||||
|
|
||||||
postRemoved: function(post) {
|
postRemoved: function(post) {
|
||||||
this.get('stream').removePost(post);
|
this.get('stream').removePost(post);
|
||||||
|
},
|
||||||
|
|
||||||
|
rename: function(title) {
|
||||||
|
var discussion = this.get('model');
|
||||||
|
discussion.set('title', title);
|
||||||
|
discussion.save();
|
||||||
|
},
|
||||||
|
|
||||||
|
delete: function() {
|
||||||
|
var controller = this;
|
||||||
|
this.get('model').destroyRecord().then(function() {
|
||||||
|
controller.transitionToRoute('index');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<header class="hero discussion-hero">
|
<header class="hero discussion-hero">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h2>{{model.title}}</h2>
|
<h2 class="discussion-title">{{model.title}}</h2>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
|
|
@ -66,5 +66,21 @@ export default Ember.View.extend(HasItemLists, {
|
||||||
view.get('streamContent').send('goToLast');
|
view.get('streamContent').send('goToLast');
|
||||||
view.get('controller').send('reply');
|
view.get('controller').send('reply');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.addSeparatorItem(items);
|
||||||
|
|
||||||
|
this.addActionItem(items, 'rename', 'Rename', 'pencil', 'discussion.canEdit', function() {
|
||||||
|
var discussion = view.get('controller.model');
|
||||||
|
var title = prompt('Enter a new title for this discussion:', discussion.get('title'));
|
||||||
|
if (title) {
|
||||||
|
view.get('controller').send('rename', title);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.addActionItem(items, 'delete', 'Delete', 'times', 'discussion.canDelete', function() {
|
||||||
|
if (confirm('Are you sure you want to delete this discussion?')) {
|
||||||
|
view.get('controller').send('delete');
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user