In our company we use discourse for everyday business.
Discourse is deeply integrated in our erp software.
For better organization of topics,our erp holds many kind of topics ids and posts ids.
In some parts of our app we want to show user list of specific topics in discource. (filtered by our citiera).
In our app there is form which users fills and our app has array of filtered topics.
Is there a way to send query string or formdata to discource endpoint among with array of wanted topics ids and to get list of topics in discource. (ideally with predefined order or ordered as array was)
Same needs we have for getting specific lists of posts by providing array of topics ids.
J’ai également besoin de cette fonctionnalité. Pour l’instant, je procède comme suit, mais cela prend beaucoup trop de temps.
const selectedTopics = this.selectedTopics
// Consomme les IDs de sujets et renvoie les vrais sujets
this.selectedTopicsID.forEach(function(tid,index){
Topic.find(tid,{}).then(results => {
selectedTopics.pushObject(results)
})
});
Je suis sur le point de réouvrir le listcontroller dans mon plugin.rb pour ajouter un nouveau point de terminaison (endpoint), et de réouvrir topic-list dans l’initialiseur du frontend pour faire quelque chose de similaire à ceci :
import TopicList from 'discourse/models/topic-list';
const selectedTopics = this.selectedTopics
// Consomme les IDs de sujets
TopicList.topics_array(this.selectedTopicsID).then(results => selectedTopics.pushObjects(results.topic_list.topics))
Pour l’instant, cela présente toujours l’inconvénient de ne pas renvoyer de vrais objets Topic, mais je suppose qu’ajouter une ligne comme celle-ci résoudra le problème :
Je suis toujours incertain de savoir si c’est la bonne méthode et/ou si cela compromet la sécurité.
Une autre chose qui pourrait être faite : vérifier d’abord dans le magasin (store) si l’enregistrement existe déjà, puis ne charger que ce qui manque, en utilisant fromMap. Similaire à :
Bref, cela devient trop verbeux ici
Voici ma solution finale, je vais m’arrêter là pour aujourd’hui :