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.
Ho bisogno anch’io di questa funzionalità. Al momento la sto implementando in questo modo, ma ci vuole troppo tempo.
const selectedTopics = this.selectedTopics
//consuma gli ID dei topic e restituisce i topic reali
this.selectedTopicsID.forEach(function(tid,index){
Topic.find(tid,{}).then(results => {
selectedTopics.pushObject(results)
})
});
Sto per riaprire il listcontroller nel mio plugin.rb e aggiungere un nuovo endpoint, oltre a riaprire il topic-list nell’inizializzatore del frontend, per fare qualcosa di simile a questo:
import TopicList from 'discourse/models/topic-list';
const selectedTopics = this.selectedTopics
//consuma gli ID dei topic
TopicList.topics_array(this.selectedTopicsID).then(results => selectedTopics.pushObjects(results.topic_list.topics))
Al momento questo ha ancora lo svantaggio di non restituire oggetti “veri” di tipo Topic, ma immagino che aggiungere una riga come questa lo risolverà:
Sono ancora incerto se questo sia il modo corretto di procedere e/o se ciò comprometta la sicurezza.
Un’altra cosa che si potrebbe fare: controllare prima nello store se il record è già presente e poi caricare solo ciò che manca, utilizzando fromMap. Simile a:
Comunque, sto diventando troppo verboso qui
Questa è la mia soluzione finale; chiudo qui la giornata: