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.
أحتاج أيضًا إلى هذه الوظيفة. حاليًا أقوم بذلك بهذه الطريقة، لكنها تستغرق وقتًا طويلاً جدًا.
const selectedTopics = this.selectedTopics
//eat topics as ids and let out real topics
this.selectedTopicsID.forEach(function(tid,index){
Topic.find(tid,{}).then(results => {
selectedTopics.pushObject(results)
})
});
كنت على وشك إعادة فتح listcontroller في ملف plugin.rb الخاص بي وإضافة نقطة نهاية جديدة، وإعادة فتح topic-list في مُهيئ الواجهة الأمامية، وفعل شيء مشابه لهذا:
import TopicList from 'discourse/models/topic-list';
const selectedTopics = this.selectedTopics
//eat topics as ids
TopicList.topics_array(this.selectedTopicsID).then(results => selectedTopics.pushObjects(results.topic_list.topics))
حاليًا، لا تزال هناك عيب، ألا وهو أنها لا تُرجع كائنات “Topic” حقيقية، لكنني أظن أن إضافة سطر مثل هذا سيحل المشكلة:
لا تزال غير متأكد مما إذا كانت هذه هي الطريقة الصحيحة للقيام بذلك و/أو ما إذا كانت هذه الطريقة تُخل بالأمان.
هناك شيء آخر يمكن فعله: البحث أولاً في المخزن (store) عما إذا كانت السجلات موجودة بالفعل، ثم تحميل ما هو غير موجود فقط باستخدام fromMap. مشابه لـ:
على أي حال، أصبح هذا النص طويلاً جدًا هنا
هذا هو الحل النهائي الخاص بي، سأعلن إنهاء العمل الآن: