diff --git a/website_snippet_project/static/src/snippets/s_project_list/000.esm.js b/website_snippet_project/static/src/snippets/s_project_list/000.esm.js index 1ffdc94..fa9f8a8 100644 --- a/website_snippet_project/static/src/snippets/s_project_list/000.esm.js +++ b/website_snippet_project/static/src/snippets/s_project_list/000.esm.js @@ -5,24 +5,6 @@ import publicWidget from "web.public.widget"; publicWidget.registry.dynamic_project_list = DynamicSnippetCarousel.extend({ selector: '.s_dynamic_project_list', - - /** - * Parses the project category information from the data attributes - * - * @private - * @returns Parsed JSON object - */ - _parseCategoryData: function() { - const keys = Object.keys(this.$el.get(0).dataset) - const ids = [] - for (let i = 0; i < keys.length; i++) { - if (keys[i].startsWith('projectCategory_') && this.$el.get(0).dataset[keys[i]]){ - ids.push(parseInt(this.$el.get(0).dataset[keys[i]])) - } - } - return ids; - }, - /** * Gets the category search domain * @@ -30,42 +12,14 @@ publicWidget.registry.dynamic_project_list = DynamicSnippetCarousel.extend({ * @returns Search domain */ _getCategorySearchDomain: function() { - const searchDomain = []; const filterByCategoryIds = JSON.parse(this.$el.get(0).dataset.filterByCategoryIds || '[]'); - - if (filterByCategoryIds.length === 0) { - return searchDomain; + if (filterByCategoryIds.length) { + searchDomain.push(['category_id', 'in', filterByCategoryIds.map(projectCategory => projectCategory.id)]); } - searchDomain.push(['category_id', 'in', filterByCategoryIds]); return searchDomain; }, - /** - * @override - * @private - */ - _renderContent: function () { - const result = this._super.apply(this, arguments); - - const projectCategory = this._parseCategoryData(); - const $title = this.$el.find('h3'); - const $subTitle = this.$el.find('h4'); - const $templateArea = this.$el.find('.dynamic_snippet_template'); - - this.trigger_up('widgets_stop_request', { - $target: $templateArea, - }); - $title.text(projectCategory.name || ""); - $subTitle.text(projectCategory.description || ""); - this.trigger_up('widgets_start_request', { - $target: $templateArea, - editableMode: this.editableMode, - }); - - return result; - }, - /** * Method to be overridden in child components in order to provide a search * domain if needed. diff --git a/website_snippet_project/static/src/snippets/s_project_list/options.esm.js b/website_snippet_project/static/src/snippets/s_project_list/options.esm.js index 26cd93e..bbaba13 100644 --- a/website_snippet_project/static/src/snippets/s_project_list/options.esm.js +++ b/website_snippet_project/static/src/snippets/s_project_list/options.esm.js @@ -1,7 +1,6 @@ /** @odoo-module **/ import dynamicSnippetCarouselOptions from "website.s_dynamic_snippet_carousel_options"; import options from "web_editor.snippets.options"; -import utils from "web.utils"; options.registry.dynamic_project_list = dynamicSnippetCarouselOptions.extend({ /** @@ -10,29 +9,8 @@ options.registry.dynamic_project_list = dynamicSnippetCarouselOptions.extend({ */ init: function () { this._super.apply(this, arguments); - this.projectCategories = {}; this.modelNameFilter = "project.project"; }, - - /** - * @override - */ - async willStart() { - const _super = this._super.bind(this); - this.tagIDs = JSON.parse(this.$target[0].dataset.filterByTagIds || '[]'); - const tags = await this._rpc({ - model: 'project.project.category', - method: 'search_read', - domain: [['website_published', '=', true]], - fields: ['id', 'display_name'], - }); - - this.allTagsByID = {}; - for (const tag of tags) { - this.allTagsByID[tag.id] = tag; - } - return _super(...arguments); - }, /** * * @override @@ -41,70 +19,6 @@ options.registry.dynamic_project_list = dynamicSnippetCarouselOptions.extend({ this._super.apply(this, arguments); this.$target[0].dataset.snippet = 'dynamic_project_list'; }, - - async _fetchProjectCategories() { - this.tagIDs = JSON.parse(this.$target[0].dataset.filterByTagIds || '[]'); - const tags = await this._rpc({ - model: 'project.project.category', - method: 'search_read', - domain: [['website_published', '=', true]], - fields: ['id', 'display_name'], - }); - - this.allTagsByID = {}; - for (const tag of tags) { - this.allTagsByID[tag.id] = tag; - } - return this._rpc({ - model: 'project.project.category', - method: 'search_read', - domain: [['website_published', '=', true]], - fields: ['id', 'display_name'], - }); - }, - - /** - * - * @override - * @private - */ - _renderCustomXML: async function (uiFragment) { - // The parent _renderCustomXML function renders a filter and a template selector. - await this._super.apply(this, arguments); - }, - - - _markupDictionary(obj) { - Object.keys(obj).forEach( - key => {obj[key] = typeof obj[key] === "string" ? utils.Markup(obj[key]) : obj[key]}); - return obj; - }, - - - setTags(previewMode, widgetValue, params) { - this.tagIDs = JSON.parse(widgetValue).map(tag => tag.id); - this.selectDataAttribute(previewMode, JSON.stringify(this.tagIDs), params); - }, - - /** - * @override - * @private - */ - _setOptionsDefaultValues: async function () { - this._super.apply(this, arguments); - - this.options.wysiwyg.odooEditor.observerUnactive(); - this._setOptionValue('projectCategory', ''); - this.options.wysiwyg.odooEditor.observerActive(); - }, - - async _computeWidgetState(methodName, params) { - if (methodName === 'setTags') { - return JSON.stringify(this.tagIDs.map(id => this.allTagsByID[id])); - } - return this._super(...arguments); - }, - }); export default { diff --git a/website_snippet_project/views/snippets/options.xml b/website_snippet_project/views/snippets/options.xml index c1f205e..d679e98 100644 --- a/website_snippet_project/views/snippets/options.xml +++ b/website_snippet_project/views/snippets/options.xml @@ -1,16 +1,16 @@ diff --git a/website_snippet_project/views/snippets/s_dynamic_project_list.xml b/website_snippet_project/views/snippets/s_dynamic_project_list.xml index 78fcd0b..048b9cf 100644 --- a/website_snippet_project/views/snippets/s_dynamic_project_list.xml +++ b/website_snippet_project/views/snippets/s_dynamic_project_list.xml @@ -1,16 +1,6 @@ - - - diff --git a/website_snippet_project/views/snippets/s_dynamic_project_list_templates.xml b/website_snippet_project/views/snippets/s_dynamic_project_list_templates.xml index 2cc87b1..653a5a1 100644 --- a/website_snippet_project/views/snippets/s_dynamic_project_list_templates.xml +++ b/website_snippet_project/views/snippets/s_dynamic_project_list_templates.xml @@ -3,12 +3,12 @@