Open Composer with Prefilled information

Hello,

I am facing the issue to open the composer with a prefilled information within it, or in case that it is too complex maybe just create a topic from a custom component/widget. The context of the issue is that I have a custom UI that expect to be used to create a Topic so there are two scenarios we can use that UI to prefill the composer and finally create the topic of embedded all things needed to create the topic from that custom UI. Keep in mind that we want also to have the composer as it is.

I saw I useful idea here: https://meta.discourse.org/t/accessing-the-createtopic-action-while-on-a-topic-route/26423 where the author ends up by reopen the ApplicationRoute and then define his own action, it looks like I can do something like that but not sure where is the right place to write that code; I can define a new custom action to be called on my custom UI button that sends the action of open to the Composer Controller with some arguments.

Cheers.

Does this help?

4 Likes

Awesome! Yes, it does! Sorry for not being able to find it by myself. Thanks for taking the time to answer.

UPDATE: The only bad thing tho, is that the composer doesn’t open instantly. I have added the following code:

_openComposerWithParams($form) {
    var serializedData = $form.serialize();
    var pathToOpenComposer = `/new-topic?${serializedData}`

    // open composer using query params
    DiscourseURL.routeTo(`${pathToOpenComposer}`);
}

And even when it works the page jump to /latest?tags=anonymous (That tag is been added successfully) but I don’t know why it gets “bind” in the url box.

I will post more about this issue at: Issue open pre-filled composer