[IMP]improvements to dashboard.
bzr revid: vme@tinyerp.com-20120606043710-prr9se9pz184dntx
This commit is contained in:
@@ -1630,16 +1630,54 @@ instance.web.search.AddToDashboard = instance.web.search.Input.extend({
|
||||
_in_drawer: true,
|
||||
init: function(){
|
||||
var menu = instance.webclient.menu;
|
||||
var menu_id = menu.$secondary_menus.find("li.oe_active a").data('menu')
|
||||
console.log("menu",menu);
|
||||
this.menu_data = _.map(menu.data.data.children,
|
||||
function(menu){
|
||||
console.log(menu);
|
||||
var obj = {}; obj["id"] = menu.id; obj["name"] = menu.name; return obj;
|
||||
//support after update of _.underscore.js lib 1.3.3
|
||||
//return _.pick(menu, 'id', 'name');
|
||||
});
|
||||
this.selected_menu_id = menu.$element.find('a.oe_active').data('menu');
|
||||
this._super.apply(this, arguments);
|
||||
},
|
||||
start: function () {
|
||||
var self = this;
|
||||
this.$element.on('click', 'h4', this.proxy('show_option'))
|
||||
this.$element
|
||||
.on('click', 'h4', this.proxy('show_option'))
|
||||
.on('submit', 'form', function (e) {e.preventDefault(); self.add_dashboard();});
|
||||
this.$element.find('.searchview_extended_delete_prop').click(function () {self.$element.toggleClass('oe_opened');});
|
||||
},
|
||||
add_dashboard:function(){
|
||||
this.$element.toggleClass('oe_opened');
|
||||
var menu_id = this.$element.find("select").val();
|
||||
var ds_name = this.$element.find("input").val();
|
||||
data = this.getParent().build_search_data();
|
||||
context = new instance.web.CompoundContext(),
|
||||
domain = new instance.web.CompoundDomain();
|
||||
_.each(data.contexts, function(x) {context.add(x);});
|
||||
_.each(data.domains, function(x) {domain.add(x);});
|
||||
this.rpc('/web/searchview/add_to_dashboard', {
|
||||
menu_id: menu_id,
|
||||
action_id: this.view.getParent().action.id,
|
||||
context_to_save: context,
|
||||
domain: domain,
|
||||
view_mode: this.view.getParent().active_view,
|
||||
name: ds_name
|
||||
}, function(r) {
|
||||
if (r === false) {
|
||||
self.do_warn("Could not add filter to dashboard");
|
||||
} else {
|
||||
self.do_notify("Filter added to dashboard", '');
|
||||
}
|
||||
});
|
||||
},
|
||||
show_option:function(){
|
||||
self.$element.toggleClass('oe_opened');
|
||||
console.log(this);
|
||||
this.$element.toggleClass('oe_opened');
|
||||
if (! this.$element.hasClass('oe_opened'))
|
||||
return;
|
||||
var action_id = this.view.getParent().action.id;
|
||||
this.$element.find("input").val(this.getParent().fields_view.name );
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
@@ -1274,16 +1274,6 @@
|
||||
<p>(Any existing filter with the same name will be replaced)</p>
|
||||
</div>
|
||||
</t>
|
||||
<t t-name="SearchView.add_to_dashboard">
|
||||
<div class="oe_form">
|
||||
<p><b>Select Dashboard to add this filter to:</b></p>
|
||||
<select style="width: 100%; margin-right: 1em;">
|
||||
<option t-foreach="dashboards" t-as="menu" t-att-value="menu.id" t-att-selected="(menu.id == selected_menu_id) || undefined"><t t-esc="menu.name"/></option>
|
||||
</select>
|
||||
<p><b>Title of new Dashboard item:</b></p>
|
||||
<input type="text" style="width: 100%; margin-right: 1em;"/>
|
||||
</div>
|
||||
</t>
|
||||
<t t-name="SearchView.render_lines">
|
||||
<table class="oe-searchview-render-line" border="0" cellspacing="0" cellpadding="0"
|
||||
t-foreach="lines" t-as="line">
|
||||
@@ -1422,13 +1412,22 @@
|
||||
<div>
|
||||
</div>
|
||||
</div>
|
||||
<div t-name="SearchView.addtodashboard" class="">
|
||||
<div t-name="SearchView.addtodashboard" class="oe_searchview_advanced">
|
||||
<h4>Add to Dashboard</h4>
|
||||
<form>
|
||||
<ul>
|
||||
<select class="">
|
||||
<t t-js="dict">console.warn('Unhandled widget', dict);</t>
|
||||
<li>
|
||||
<select title = "Select Dashboard to add this filter to" style="width: 30%; margin-right: 1em;">
|
||||
<option t-foreach="widget.menu_data" t-as="menu" t-att-value="menu.id" t-att-selected="(menu.id == widget.selected_menu_id) || undefined"><t t-esc="menu.name"/>
|
||||
</option>
|
||||
</select>
|
||||
|
||||
<input placeholder ="Title of new Dashboard item" title = "Title of new Dashboard item" type="text" style="width: 30%; margin-right: 1em;"/>
|
||||
<button class="oe_apply" type="submit">save</button>
|
||||
<a style="width: 30%;" class="searchview_extended_delete_prop button">x</a>
|
||||
</li>
|
||||
</ul>
|
||||
</form>
|
||||
</div>
|
||||
<div t-name="SearchView.advanced" class="oe_searchview_advanced">
|
||||
<h4>Advanced Search</h4>
|
||||
|
||||
Reference in New Issue
Block a user