Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit fd6c5fed authored by Julie Thezenas's avatar Julie Thezenas
Browse files

feat: maj topic-list

parent 896298e8
No related branches found
No related tags found
No related merge requests found
import Component from "@ember/component";
import Category from "discourse/models/category";
import discourseComputed, { observes } from "discourse-common/utils/decorators";
import { inject as service } from "@ember/service";
import { defaultHomepage } from "discourse/lib/utilities";
import { and } from "@ember/object/computed";
import {
navigateToTopic,
showEntrance,
} from "discourse/components/topic-list-item";
import Component from "@ember/component";
import discourseComputed from "discourse-common/utils/decorators";
export default Component.extend({
router: service(),
tagName: "",
didInsertElement() {
attributeBindings: ["topic.id:data-topic-id"],
classNameBindings: [":latest-topic-list-item", "unboundClassNames"],
showEntrance,
navigateToTopic,
this._super(...arguments);
this._updateBodyClasses();
},
......@@ -28,20 +38,38 @@ export default Component.extend({
}
},
get categoriesLoaded() {
return Category.list().length !== 0;
// get categoriesLoaded() {
// return Category.list().length !== 0;
// },
// //tests 4 derniers posts et 4 top sujets
// get category1() {
// if (!this.categoriesLoaded) return false;
// return Category.findById(settings.feed_one_category);
// },
// get category2() {
// if (!this.categoriesLoaded) return false;
// return Category.findById(settings.feed_two_category);
// },
get topicLoaded() {
return navigateToTopic.list().length !== 0;
},
//tests 4 derniers posts et 4 top sujets
get category1() {
if (!this.categoriesLoaded) return false;
return Category.findById(settings.feed_one_category);
if (!this.topicLoaded) return false;
return navigateToTopic.findById(settings.feed_one_category);
},
get category2() {
if (!this.categoriesLoaded) return false;
return Category.findById(settings.feed_two_category);
if (!this.topicLoaded) return false;
return navigateToTopic.findById(settings.feed_two_category);
},
@discourseComputed("router.currentRouteName")
shouldShow(currentRouteName) {
let showSidebar =
......@@ -50,4 +78,41 @@ export default Component.extend({
},
showTopicLists: and("shouldShow", "category1", "category2")
/////
click(e) {
// for events undefined has a different meaning than false
if (this.showEntrance(e) === false) {
return false;
}
return this.unhandledRowClick(e, this.topic);
},
// Can be overwritten by plugins to handle clicks on other parts of the row
unhandledRowClick() {},
@discourseComputed("topic")
unboundClassNames(topic) {
let classes = [];
if (topic.get("category")) {
classes.push("category-" + topic.get("category.fullSlug"));
}
if (topic.get("tags")) {
topic.get("tags").forEach((tagName) => classes.push("tag-" + tagName));
}
["liked", "archived", "bookmarked", "pinned", "closed", "visited"].forEach(
(name) => {
if (topic.get(name)) {
classes.push(name);
}
}
);
return classes.join(" ");
},
});
# show_as_sidebar:
show_as_sidebar:
type: bool
default: false
description: "If enabled, the showcased categories will only be rendered in a sidebar on the latest page."
featured_topic_lists_title:
type: string
default: "Showcased Categories"
description: "Title for showcased categories lists section"
feed_one_title:
type: string
default: "Custom List One"
description: "Title for left area of topics on homepage"
feed_one_category:
type: list
list_type: latest-topic-list-item
default: "latest-topic-list-item"
description: "Choose only ONE category for the Feed One topic list"
feed_two_title:
type: string
default: "Custom List Two"
description: "Title for right area of topics on homepage"
feed_two_category:
type: list
list_type: latest-topic-list-item
default: "latest-topic-list-item"
description: "Choose only ONE category for the Feed Two topic list"
max_list_length:
type: integer
default: 4
min: 1
max: 4
description: "How many topics should appear in the custom lists?"
plugin_outlet:
type: enum
default: "above-main-container"
choices:
- "above-main-container"
- "below-site-header"
description: "Advanced setting for additional customization"
# /////////////////////////////////////////////////////
# /////////////////////////////////////////////////////
# /////////////////////////////////////////////////////
# show_as_sidebar:
# type: bool
# default: false
# description: "If enabled, the showcased categories will only be rendered in a sidebar on the latest page."
......@@ -8,27 +50,22 @@
# description: "Title for showcased categories lists section"
# feed_one_title:
# type: string
# default: "The 4 Latest subjects"
# default: "Custom List One"
# description: "Title for left area of topics on homepage"
# # ////////////////////////////
# first category:
# #latest: "Latest"
# #view_latest_topics: "view latest topics"
# feed_one_category:
# type: list
# list_type: category
# default: ""
# description: "Choose only ONE category for the Feed One topic list"
# feed_two_title:
# type: string
# default: "The 4 top subjects"
# default: "Custom List Two"
# description: "Title for right area of topics on homepage"
# second category:
# #top_topics: "Top Topics"
# feed_two_category:
# type: list
# list_type: category
# default: ""
# description: "Choose only ONE category for the Feed Two topic list"
# # //////////////////////////////
# max_list_length:
# type: integer
# default: 5
......@@ -41,43 +78,4 @@
# choices:
# - "above-main-container"
# - "below-site-header"
# description: "Advanced setting for additional customization"
show_as_sidebar:
type: bool
default: false
description: "If enabled, the showcased categories will only be rendered in a sidebar on the latest page."
featured_topic_lists_title:
type: string
default: "Showcased Categories"
description: "Title for showcased categories lists section"
feed_one_title:
type: string
default: "Custom List One"
description: "Title for left area of topics on homepage"
feed_one_category:
type: list
list_type: category
default: ""
description: "Choose only ONE category for the Feed One topic list"
feed_two_title:
type: string
default: "Custom List Two"
description: "Title for right area of topics on homepage"
feed_two_category:
type: list
list_type: category
default: ""
description: "Choose only ONE category for the Feed Two topic list"
max_list_length:
type: integer
default: 5
min: 1
max: 5
description: "How many topics should appear in the custom lists?"
plugin_outlet:
type: enum
default: "above-main-container"
choices:
- "above-main-container"
- "below-site-header"
description: "Advanced setting for additional customization"
\ No newline at end of file
# description: "Advanced setting for additional customization"
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment