3
0
Fork 0

[REF] remove half developed functionality that allowed to create on the fly tiles, but that was limited regarding configuration

16.0
Sylvain LE GAL 2021-11-02 15:33:18 +01:00
parent b68d5ca3dd
commit 5faa0bb858
5 changed files with 0 additions and 152 deletions

View File

@ -19,7 +19,6 @@
"views/menu.xml",
"views/tile_tile.xml",
"views/tile_category.xml",
"views/templates.xml",
],
"demo": [
"demo/tile_category.xml",

View File

@ -51,12 +51,6 @@
display: block;
}
/* Favorites menu in control panel */
.o_add_to_dashboard_tile {
/* hidden by default */
display: none;
}
/* Make dropdown menu button not affect text flow */
.o_kanban_view .oe_dashboard_tile .o_dropdown_kanban {
float: none;

View File

@ -1,112 +0,0 @@
/*
Copyright (C) 2010-2013 OpenERP s.a. (<http://www.openerp.com>)
Copyright (C) 2014 initOS GmbH & Co. KG (<http://initos.com>)
Copyright (C) 2018 Iván Todorovich (<ivan.todorovich@gmail.com>)
Copyright (C) 2019-Today GRAP (http://www.grap.coop)
@author: Sylvain LE GAL (https://twitter.com/legalsylvain)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
*/
odoo.define('web_dashboard_tile', function (require) {
'use strict';
var core = require('web.core');
var FavoriteMenu = require('web.FavoriteMenu');
var Domain = require('web.Domain');
var qweb = core.qweb;
var _t = core._t;
FavoriteMenu.include({
start: function () {
var self = this;
if (this.action_id === undefined) {
return this._super();
}
if (this.action.type === 'ir.actions.act_window') {
this.add_to_dashboard_available = true;
this.$('.o_favorites_menu').append(qweb.render('SearchView.addtodashboardtile'));
this.$add_to_dashboard_tile = this.$('.o_add_to_dashboard_tile');
this.$add_to_dashboard_tile_name = this.$('.o_add_to_dashboard_tile_name')[0];
// Add event on button and link clicks
this.$add_to_dashboard_tile_link = this.$('.o_add_to_dashboard_tile_link');
this.$add_to_dashboard_tile_link.click(function (e) {
e.preventDefault();
self._toggleDashboardTileMenu();
});
this.$add_to_dashboard_tile_button = this.$('.o_add_to_dashboard_tile_button');
this.$add_to_dashboard_tile_button.click(this.proxy('_addDashboardTile'));
// Add categories to the select list
this.$add_to_dashboard_tile_category = this.$('.o_add_to_dashboard_tile_category')[0];
this._rpc({
model: 'tile.category',
method: 'search_read',
args: [[], ['id', 'name']],
}).then(function (res) {
res.forEach(function(item){
var newOption = document.createElement("option");
newOption.text = item.name;
newOption.value = item.id;
self.$add_to_dashboard_tile_category.appendChild(newOption);
});
});
}
return this._super();
},
_toggleDashboardTileMenu: function (isOpen) {
this.$add_to_dashboard_tile_link
.toggleClass('o_closed_menu', !(_.isUndefined(isOpen)) ? !isOpen : undefined)
.toggleClass('o_open_menu', isOpen);
this.$add_to_dashboard_tile.toggle(isOpen);
if (this.$add_to_dashboard_tile_link.hasClass('o_open_menu')) {
this.$add_to_dashboard_tile_name.focus();
}
},
_addDashboardTile: function () {
var self = this;
var tile_name = this.$add_to_dashboard_tile_name.value;
var tile_category_id = this.$add_to_dashboard_tile_category.value;
if (!tile_name.length){
this.do_warn(_t("Error"), _t("Name Field is required."));
this.$add_to_dashboard_tile_name.focus();
return;
}
var search_data = this.searchview.build_search_data();
var domain = this.action.domain ? this.action.domain.slice(0) : [];
_.each(search_data.domains, function (d) {
domain.push.apply(domain, Domain.prototype.stringToArray(d));
});
return this._rpc({
route: '/web_dashboard_tile/create_tile',
params: {
model_name: self.action.res_model,
name: tile_name,
category_id: tile_category_id,
domain: domain,
action_id: this.action_id,
},
}).then(function (res) {
if (res) {
self.do_notify(
_.str.sprintf(_t("'%s' added to the overview dashboard"), tile_name),
_t('Please refresh your browser for the changes to take effect.')
);
self._toggleDashboardTileMenu(false);
} else {
self.do_warn(_t("Could not add new element to the overview dashboard"));
}
});
},
});
});

View File

@ -1,19 +0,0 @@
<template>
<t t-name="SearchView.addtodashboardtile">
<a href="#" class="dropdown-item o_add_to_dashboard_tile_link o_closed_menu">Add to the Overview Dashboard</a>
<div class="dropdown-item-text o_add_to_dashboard_tile">
Name
<input class="o_input o_required_modifier o_add_to_dashboard_tile_name" type="text"/>
</div>
<div class="dropdown-item-text o_add_to_dashboard_tile">
Category
<select class="o_input o_required_modifier o_add_to_dashboard_tile_category">
</select>
</div>
<div class="dropdown-item-text o_add_to_dashboard_tile">
<button type="button" class="btn btn-primary o_add_to_dashboard_tile_button">Add</button>
</div>
</t>
</template>

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<template id="assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<link rel="stylesheet"
href="/web_dashboard_tile/static/src/css/web_dashboard_tile.css"/>
<script type="text/javascript"
src="/web_dashboard_tile/static/src/js/web_dashboard_tile.js"/>
</xpath>
</template>
</odoo>