לדוגמה,
api.addCommunitySectionLink({
name: "intersection-navigator",
route:"tags.intersection",
title: I18n.t("tag_intersection_navigator.link.title"),
text: I18n.t("tag_intersection_navigator.link.text")
})
… ייכשל מכיוון שמסלול זה דורש tag_id.
ניסיתי להוסיף:
params: { tag_id: siteSettings.discourse_tag_intersection_navigator_all_word },
model: { tag_id: siteSettings.discourse_tag_intersection_navigator_all_word },
… אבל אני חושד מאוד שזה לא מעובד כנדרש על ידי ה-API …
4 לייקים
Specifically, I think it’s here: discourse/app/assets/javascripts/discourse/app/lib/sidebar/custom-community-section-links.js at d0c3f3b8fe6905e7e33ae4944cdf44c11ccc0df6 · discourse/discourse · GitHub
if we add this it should work:
get models() {
return args.models;
}
3 לייקים
אה, ומכיוון שיש תנאי typeof args === "function", אתה יכול לעשות משהו כזה באופן מיידי:
api.addCommunitySectionLink((Base) =>
class CustomLink extends Base {
get name() {
return "intersection-navigator";
}
get route() {
return "tag.show";
}
get models() {
return ["tagid"];
}
get title() {
return I18n.t("tag_intersection_navigator.link.title");
}
get text() {
return I18n.t("tag_intersection_navigator.link.text");
}
}
);
לייק 1
כן, זה מה שאני כבר עושה… אבל יש קטע מצחיק בהמשך התהליך
לייק 1
משום מה, זה לא ממש זה ואני מקבל תלונה על חוסר postStream בעת לחיצה:
api.addCommunitySectionLink((baseSectionLink) => {
return class CustomSectionLink extends baseSectionLink {
get name() {
return "intersection-navigator";
}
get route() {
return "tags.intersection";
}
get models() {
return [{tag_id: siteSettings.discourse_tag_intersection_navigator_all_word}];
}
get title() {
return I18n.t("tag_intersection_navigator.link.title")
}
get text() {
return I18n.t("tag_intersection_navigator.link.text");
}
};
});
זה כמעט כאילו שאתה צריך לכלול את המודל עבור המסלול הנוכחי, וזה מוזר!
לייק 1
מה הפלט של ההגדרה הזו? נראה שהיא עובדת בסדר כשאני עושה את זה ידנית:
get models() {
return ["featured", "tv"];
}
2 לייקים
כן, זה עובד, זה ממש מועיל, תודה!
ההגדרה היא רק מחרוזת. אני חושב שחשבתי על זה יותר מדי.
השם “models” עבור פרמטרי השאילתה הוא לא אינטואיטיבי ב-100%?
יחסי הציבור שלך יהפכו את זה להרבה יותר מסודר, תודה!
2 לייקים
yeah it wasn’t clear to me at first either, but it’s because in the end it uses Ember’s LinkTo component, which expects a model argument…
לייק 1
system
(system)
נסגר ב־
11
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.