From 2069c7ab877a993cb771ae29eadba22686cb6100 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Thu, 14 May 2015 22:02:46 +0930 Subject: [PATCH] Make it possible for extensions to modify data before saving --- .../core/js/forum/src/components/composer-edit.js | 10 ++++++++-- .../core/js/forum/src/components/composer-reply.js | 14 +++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/framework/core/js/forum/src/components/composer-edit.js b/framework/core/js/forum/src/components/composer-edit.js index 92cd29fb1..ab06f128c 100644 --- a/framework/core/js/forum/src/components/composer-edit.js +++ b/framework/core/js/forum/src/components/composer-edit.js @@ -27,13 +27,19 @@ export default class ComposerEdit extends ComposerBody { return items; } - onsubmit(content) { + data() { + return { + content: this.content() + }; + } + + onsubmit() { var post = this.props.post; this.loading(true); m.redraw(); - post.save({content}).then(post => { + post.save(this.data()).then(post => { app.composer.hide(); m.redraw(); }, response => { diff --git a/framework/core/js/forum/src/components/composer-reply.js b/framework/core/js/forum/src/components/composer-reply.js index 6af8478c5..aa6f119b6 100644 --- a/framework/core/js/forum/src/components/composer-reply.js +++ b/framework/core/js/forum/src/components/composer-reply.js @@ -19,16 +19,20 @@ export default class ComposerReply extends ComposerBody { return items; } - onsubmit(value) { + data() { + return { + content: this.content(), + links: {discussion: this.props.discussion} + }; + } + + onsubmit() { var discussion = this.props.discussion; this.loading(true); m.redraw(); - var data = { - content: value, - links: {discussion} - }; + var data = this.data(); app.store.createRecord('posts').save(data).then((post) => { app.composer.hide();