mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
init
This commit is contained in:
3
app_dynamic_list/static/src/css/my.css
Normal file
3
app_dynamic_list/static/src/css/my.css
Normal file
@@ -0,0 +1,3 @@
|
||||
.o_main_content .o_list_buttons {
|
||||
position:relative;
|
||||
}
|
||||
97
app_dynamic_list/static/src/js/dynamic_list.js
Normal file
97
app_dynamic_list/static/src/js/dynamic_list.js
Normal file
@@ -0,0 +1,97 @@
|
||||
odoo.define('app_dynamic_list.shcolumns', function (require) {
|
||||
"use strict";
|
||||
|
||||
var core = require('web.core');
|
||||
var ListView = require('web.ListView');
|
||||
var QWeb = core.qweb;
|
||||
|
||||
ListView.include({
|
||||
reload: function () {
|
||||
this.setup_columns(this.fields_view.fields, this.grouped);
|
||||
this.$el.html(QWeb.render(this._template, this));
|
||||
return this.reload_content();
|
||||
},
|
||||
|
||||
render_buttons: function($node) {
|
||||
var self = this;
|
||||
this._super($node);
|
||||
this.$buttons.find('.oe_select_columns').click(this.proxy('my_setup_columns'));
|
||||
this.$buttons.find('.oe_dropdown_btn').click(this.proxy('hide_show_columns'));
|
||||
this.$buttons.find('.dropdown-menu').click(this.proxy('stop_event'));
|
||||
},
|
||||
|
||||
my_setup_columns: function (fields, grouped) {
|
||||
$("#showcb").toggle();
|
||||
var getcb = document.getElementById('showcb');
|
||||
this.visible_columns = _.filter(this.columns, function (column) {
|
||||
var firstcheck = document.getElementById(column.id);
|
||||
if(firstcheck == null)
|
||||
{
|
||||
var li= document.createElement("li");
|
||||
var description = document.createTextNode(column.string);
|
||||
var checkbox = document.createElement("input");
|
||||
checkbox.id = column.id;
|
||||
checkbox.type = "checkbox";
|
||||
checkbox.name = "cb";
|
||||
|
||||
if(column.invisible !== '1')
|
||||
{
|
||||
checkbox.checked = true;
|
||||
}
|
||||
li.appendChild(checkbox);
|
||||
li.appendChild(description);
|
||||
getcb.appendChild(li);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(column.invisible !== '1')
|
||||
{
|
||||
firstcheck.checked = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
firstcheck.checked = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
stop_event : function(e)
|
||||
{
|
||||
e.stopPropagation();
|
||||
},
|
||||
|
||||
hide_show_columns : function()
|
||||
{
|
||||
$("#showcb").hide();
|
||||
this.setup_columns(this.fields_view.fields, this.grouped);
|
||||
this.$el.html(QWeb.render(this._template, this));
|
||||
return this.reload_content();
|
||||
},
|
||||
|
||||
setup_columns: function (fields, grouped) {
|
||||
this._super(fields, grouped);
|
||||
this.visible_columns = _.filter(this.columns, function (column) {
|
||||
var cbid = document.getElementById(column.id);
|
||||
if(cbid !== null)
|
||||
{
|
||||
var cbid = cbid.checked;
|
||||
if(cbid !== false)
|
||||
{
|
||||
column.invisible = '2';
|
||||
}
|
||||
else
|
||||
{
|
||||
column.invisible = '1';
|
||||
}
|
||||
}
|
||||
return column.invisible !== '1';
|
||||
});
|
||||
this.aggregate_columns = _(this.visible_columns).invoke('to_aggregate');
|
||||
},
|
||||
});
|
||||
|
||||
$(document).click(function(){
|
||||
$("#showcb").hide();
|
||||
});
|
||||
|
||||
});
|
||||
23
app_dynamic_list/static/src/xml/listview_button_view.xml
Normal file
23
app_dynamic_list/static/src/xml/listview_button_view.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<templates t-name="selectcolumns">
|
||||
<t t-extend="ListView.buttons">
|
||||
|
||||
<t t-jquery="button.o_list_button_add" t-operation="after">
|
||||
|
||||
<button name="select_columns" id="select_columns"
|
||||
class="oe_select_columns btn btn-default btn-sm dropdown-toggle dropdown-toggle"
|
||||
data-toggle="dropdown">
|
||||
Set Columns
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
|
||||
<ul id="showcb" class="dropdown-menu" style="max-height:320px; overflow:auto;padding: 3px 10px;right:0px;left:auto;">
|
||||
<li>
|
||||
<button name="apply" id="apply" class="oe_dropdown_btn btn btn-primary btn-block">
|
||||
Apply
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</t>
|
||||
</t>
|
||||
</templates>
|
||||
Reference in New Issue
Block a user