summaryrefslogtreecommitdiff
path: root/addons/website_blog/static/src/snippets/s_latest_posts/options.js
blob: e70c4041e6d38426d89b5d96000d49cd1ed5f6b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
odoo.define('website_blog.s_latest_posts_editor', function (require) {
'use strict';

var sOptions = require('web_editor.snippets.options');
var wUtils = require('website.utils');

sOptions.registry.js_get_posts_selectBlog = sOptions.Class.extend({

    //--------------------------------------------------------------------------
    // Private
    //--------------------------------------------------------------------------

    /**
     * @override
     */
    _renderCustomXML: function (uiFragment) {
        return this._rpc({
            model: 'blog.blog',
            method: 'search_read',
            args: [wUtils.websiteDomain(this), ['name']],
        }).then(blogs => {
            const menuEl = uiFragment.querySelector('[name="blog_selection"]');
            for (const blog of blogs) {
                const el = document.createElement('we-button');
                el.dataset.selectDataAttribute = blog.id;
                el.textContent = blog.name;
                menuEl.appendChild(el);
            }
        });
    },
});
});