I am working on a plugin that should allow users to create specially flagged posts when pressing a button in the topic view. The post flag is just a boolean value. This is for interaction with an external tool. Currently, I have solved the following:
- I have added a custom action that opens the composer when the user presses the new button. Currently, the action is added by:
api.modifyClass('controller:topic', {
actions: {
postFlagged(post) {
...
- I have added a custom field to the Post class and added it to the serializer. The field shows up in the serialized json as expected:
Post.register_custom_field_type('my_flag', :boolean)
add_to_serializer(:post, :my_flag, false) do
object.custom_fields['my_flag']
end
- I can add a method to the composer and have the value stored for the flag show up via handlebars template:
api.modifyClass('model:composer', {
flag: function() {
return this.get('post.my_flag');
}.property('post.my_flag'),
});
Now, my problem is that I have no idea how to set my custom field flag in the composer. How do I do that?