forked from Techsystech/web
[PORT] 9.0 web_listview_custom_element_number
parent
884b5e0337
commit
d3a6adbe09
|
@ -1,14 +1,40 @@
|
||||||
|
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
||||||
|
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||||
|
:alt: License: AGPL-3
|
||||||
|
|
||||||
|
=========================================================================
|
||||||
Allow users to set manually a quantity of items to display in a tree view
|
Allow users to set manually a quantity of items to display in a tree view
|
||||||
=========================================================================
|
=========================================================================
|
||||||
|
|
||||||
By default, in Odoo, user can display 80 / 200 / 500 / 2000 elements in
|
This module extends the functionality of web module, to improve list views and
|
||||||
a tree view. With that module, user can select a custom number of items to
|
to allow users to display custom quantity of items.
|
||||||
display;
|
|
||||||
|
(By default, in Odoo, user can only display 80 / 200 / 500 / 2000 elements in
|
||||||
|
a tree view)
|
||||||
|
|
||||||
|
Usage
|
||||||
|
=====
|
||||||
|
|
||||||
|
To use this module, you need to:
|
||||||
|
|
||||||
|
#. Go to a list view
|
||||||
|
#. Click on the item '1 - 80 of xxx'
|
||||||
|
#. Tip a custom quantity of item you want to see, and then press return
|
||||||
|
|
||||||
|
Sample for res.partner model with a limit of 3:
|
||||||
|
|
||||||
|
.. image:: ./web_listview_custom_element_number/static/src/img/screnshot_partner_limit.png
|
||||||
|
|
||||||
|
|
||||||
|
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||||
|
:alt: Try me on Runbot
|
||||||
|
:target: https://runbot.odoo-community.org/runbot/162/9.0
|
||||||
|
|
||||||
|
|
||||||
Technical information
|
Technical information
|
||||||
---------------------
|
=====================
|
||||||
|
|
||||||
* replace a select element by an input with datalist option. That allows
|
* Replace a select element by an input with datalist option. That allows
|
||||||
to set a custom value, or to select an option. (same options as before:
|
to set a custom value, or to select an option. (same options as before:
|
||||||
80 / 200 / 500 / 2000 / unlimited);
|
80 / 200 / 500 / 2000 / unlimited);
|
||||||
|
|
||||||
|
@ -17,38 +43,26 @@ Technical information
|
||||||
user to select manually a value);
|
user to select manually a value);
|
||||||
See browser Support: http://www.w3schools.com/tags/tag_datalist.asp
|
See browser Support: http://www.w3schools.com/tags/tag_datalist.asp
|
||||||
|
|
||||||
|
* The display of the datalist input can be different depending of the browser.
|
||||||
|
* FireFox Display:
|
||||||
|
.. image:: ./web_listview_custom_element_number/static/src/img/screnshot_firefox.png
|
||||||
|
* Chrome Display:
|
||||||
|
.. image:: ./web_listview_custom_element_number/static/src/img/screnshot_chrome.png
|
||||||
|
|
||||||
Usage
|
|
||||||
-----
|
|
||||||
|
|
||||||
* Sample for res.partner model with a limit of 3:
|
Known issues / Roadmap
|
||||||
|
======================
|
||||||
|
|
||||||
.. image:: web_listview_custom_element_number/static/src/img/screnshot_partner_limit.png
|
|
||||||
|
|
||||||
The display of the datalist input can be different depending of the browser.
|
|
||||||
|
|
||||||
* FireFox Display:
|
|
||||||
|
|
||||||
.. image:: web_listview_custom_element_number/static/src/img/screnshot_firefox.png
|
|
||||||
|
|
||||||
* Chrome Display:
|
|
||||||
|
|
||||||
.. image:: web_listview_custom_element_number/static/src/img/screnshot_chrome.png
|
|
||||||
|
|
||||||
Limits / Roadmap
|
|
||||||
================
|
|
||||||
* When pressing Esc key, it could be user friendly to return to the previous
|
* When pressing Esc key, it could be user friendly to return to the previous
|
||||||
state (before editing the quantity).
|
state (before editing the quantity).
|
||||||
|
|
||||||
|
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
|
||||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
|
Bugs are tracked on `GitHub Issues
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
<https://github.com/OCA/web/issues>`_. In case of trouble, please
|
||||||
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback
|
check there if your issue has already been reported. If you spotted it first,
|
||||||
`here <https://github.com/OCA/web/issues/new?body=module:%20web_listview_custom_element_number%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
help us smash it by providing detailed and welcomed feedback.
|
||||||
|
|
||||||
|
|
||||||
Credits
|
Credits
|
||||||
=======
|
=======
|
||||||
|
@ -58,12 +72,19 @@ Contributors
|
||||||
|
|
||||||
* Sylvain LE GAL (https://twitter.com/legalsylvain)
|
* Sylvain LE GAL (https://twitter.com/legalsylvain)
|
||||||
|
|
||||||
|
Funders
|
||||||
|
-------
|
||||||
|
|
||||||
|
The development of this module has been financially supported by:
|
||||||
|
|
||||||
|
* Akretion (http://www.akretion.com)
|
||||||
|
|
||||||
Maintainer
|
Maintainer
|
||||||
----------
|
----------
|
||||||
|
|
||||||
.. image:: http://odoo-community.org/logo.png
|
.. image:: https://odoo-community.org/logo.png
|
||||||
:alt: Odoo Community Association
|
:alt: Odoo Community Association
|
||||||
:target: http://odoo-community.org
|
:target: https://odoo-community.org
|
||||||
|
|
||||||
This module is maintained by the OCA.
|
This module is maintained by the OCA.
|
||||||
|
|
||||||
|
@ -71,4 +92,4 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||||
mission is to support the collaborative development of Odoo features and
|
mission is to support the collaborative development of Odoo features and
|
||||||
promote its widespread use.
|
promote its widespread use.
|
||||||
|
|
||||||
To contribute to this module, please visit http://odoo-community.org.
|
To contribute to this module, please visit https://odoo-community.org.
|
||||||
|
|
|
@ -1,33 +1,16 @@
|
||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
# Copyright (C) 2015-Today Akretion (http://www.akretion.com)
|
||||||
#
|
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
|
||||||
# Web - Custom Element Number in ListView module for Odoo
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
# Copyright (C) 2015-Today Akretion (http://www.akretion.com)
|
|
||||||
# @author Sylvain LE GAL (https://twitter.com/legalsylvain)
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Affero General Public License as
|
|
||||||
# published by the Free Software Foundation, either version 3 of the
|
|
||||||
# License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Affero General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
{
|
{
|
||||||
'name': 'Web - Custom Element Number in ListView',
|
'name': 'Web - Custom Element Number in ListView',
|
||||||
'summary': 'Allow users to set manually a quantity of items to display'
|
'summary': 'Allow users to set manually a quantity of items to display'
|
||||||
' in a tree view',
|
' in a tree view',
|
||||||
'version': '8.0.1.0.0',
|
'version': '9.0.1.0.0',
|
||||||
'category': 'web',
|
'category': 'web',
|
||||||
'author': "Akretion,Odoo Community Association (OCA)",
|
'author': "GRAP,Akretion,Odoo Community Association (OCA)",
|
||||||
'website': 'http://www.akretion.com',
|
'website': 'https://odoo-community.org/',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'depends': [
|
'depends': [
|
||||||
'web',
|
'web',
|
||||||
|
@ -35,5 +18,5 @@
|
||||||
'data': [
|
'data': [
|
||||||
'views/templates.xml',
|
'views/templates.xml',
|
||||||
],
|
],
|
||||||
'installable': False,
|
'installable': True,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,10 @@
|
||||||
/******************************************************************************
|
/*
|
||||||
Web - Custom Element Number in ListView module for Odoo
|
Copyright (C) 2015-Today Akretion (http://www.akretion.com)
|
||||||
Copyright (C) 2015-Today Akretion (http://www.akretion.com)
|
@author: Sylvain LE GAL (https://twitter.com/legalsylvain)
|
||||||
@author Sylvain LE GAL (https://twitter.com/legalsylvain)
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
*/
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Affero General Public License as
|
|
||||||
published by the Free Software Foundation, either version 3 of the
|
|
||||||
License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
.custom_element_number {
|
.custom_element_number {
|
||||||
width:80px;
|
width:80px;
|
||||||
|
height: 29px;
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 6.1 KiB |
Binary file not shown.
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 7.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 27 KiB |
|
@ -1,81 +1,72 @@
|
||||||
/******************************************************************************
|
/*
|
||||||
Web - Custom Element Number in ListView module for Odoo
|
Copyright (C) 2015-Today Akretion (http://www.akretion.com)
|
||||||
Copyright (C) 2015-Today Akretion (http://www.akretion.com)
|
@author: Sylvain LE GAL (https://twitter.com/legalsylvain)
|
||||||
@author Sylvain LE GAL (https://twitter.com/legalsylvain)
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
*/
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
odoo.define('web.web_listview_custom_element_number',function (require) {
|
||||||
it under the terms of the GNU Affero General Public License as
|
"use strict";
|
||||||
published by the Free Software Foundation, either version 3 of the
|
|
||||||
License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
var core = require('web.core');
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
var ListView = require('web.ListView');
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
var _t = core._t;
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
openerp.web_listview_custom_element_number = function (instance) {
|
|
||||||
module = instance.web;
|
|
||||||
_t = module._t;
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
Extend the widget 'instance.web.ListView' to replace the select tag by an
|
Extend the widget 'web.ListView' to replace the select tag by an
|
||||||
input with datalist option.
|
input with datalist option.
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
module.ListView.include({
|
ListView.include({
|
||||||
|
|
||||||
/**
|
render_pager: function($node) {
|
||||||
* Overload 'load_list' function:
|
// Call Original function
|
||||||
*/
|
|
||||||
load_list: function(data) {
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this._super.apply(this, arguments);
|
this._super($node);
|
||||||
|
|
||||||
if (this.$pager){
|
// unbind previous function that added a select tag
|
||||||
// unbind previous function that added a select tag
|
this.$pager.find('.oe_list_pager_state').unbind("click");
|
||||||
this.$pager.find('.oe_list_pager_state').unbind("click");
|
|
||||||
|
|
||||||
// bind a new function on click, that add a input type select
|
// bind a new function on click, that add a input type select
|
||||||
this.$pager.find('.oe_list_pager_state').click(function (e) {
|
this.$pager.find('.oe_list_pager_state').click(function (e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
var $select = $('<input list="page_value" class="custom_element_number" type="text" placeholder="' + (self._limit || '0') + '">')
|
var $select = $('<input list="page_value" class="custom_element_number" type="text" placeholder="' + (self._limit || '0') + '">')
|
||||||
.appendTo($this.empty())
|
.appendTo($this.empty())
|
||||||
.click(function (e) {e.stopPropagation();})
|
.click(function (e) {e.stopPropagation();})
|
||||||
.append(
|
.append(
|
||||||
'<datalist id="page_value">' +
|
'<datalist id="page_value">' +
|
||||||
'<option value="80">' +
|
'<option value="80">' +
|
||||||
'<option value="200">' +
|
'<option value="200">' +
|
||||||
'<option value="500">' +
|
'<option value="500">' +
|
||||||
'<option value="2000">' +
|
'<option value="2000">' +
|
||||||
'<option value="0" label="'+_t("0 (Unlimited)") + '">' +
|
'<option value="0" label="'+_t("Unlimited") + '">' +
|
||||||
'</datalist>')
|
'</datalist>')
|
||||||
.change(function () {
|
.change(function () {
|
||||||
var val = parseInt($select.val(), 10);
|
var val = parseInt($select.val(), 10);
|
||||||
if (!isNaN(val)){
|
if (!isNaN(val)){
|
||||||
if (val == 0){
|
if (val == 0){
|
||||||
self._limit = null;
|
self._limit = null;
|
||||||
}
|
|
||||||
else{
|
|
||||||
self._limit = val;
|
|
||||||
}
|
|
||||||
self.page = 0;
|
|
||||||
self.reload_content();
|
|
||||||
}
|
}
|
||||||
}).blur(function() {
|
else{
|
||||||
|
self._limit = val;
|
||||||
|
}
|
||||||
|
self.page = 0;
|
||||||
|
self.reload_content();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.blur(function() {
|
||||||
|
$(this).trigger('change');
|
||||||
|
})
|
||||||
|
.keypress(function(e) {
|
||||||
|
if(e.which == 13) {
|
||||||
$(this).trigger('change');
|
$(this).trigger('change');
|
||||||
})
|
}
|
||||||
.keypress(function(e) {
|
})
|
||||||
if(e.which == 13) {
|
.bind('select', function () {
|
||||||
$(this).trigger('change');
|
$(this).trigger('change');
|
||||||
}
|
})
|
||||||
})
|
.focus()
|
||||||
.focus()
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
});
|
||||||
|
|
|
@ -1,30 +1,17 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!--***************************************************************************
|
<!--
|
||||||
Web - Custom Element Number in ListView module for Odoo
|
Copyright (C) 2015-Today Akretion (http://www.akretion.com)
|
||||||
Copyright (C) 2015-Today Akretion (http://www.akretion.com)
|
@author: Sylvain LE GAL (https://twitter.com/legalsylvain)
|
||||||
@author Sylvain LE GAL (https://twitter.com/legalsylvain)
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
-->
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
<odoo>
|
||||||
it under the terms of the GNU Affero General Public License as
|
|
||||||
published by the Free Software Foundation, either version 3 of the
|
|
||||||
License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
<template id="assets_backend" name="web_listview_custom_element_number assets" inherit_id="web.assets_backend">
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
<xpath expr="." position="inside">
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
<link rel="stylesheet" href="/web_listview_custom_element_number/static/src/css/web_listview_custom_element_number.css"/>
|
||||||
GNU Affero General Public License for more details.
|
<script type="text/javascript" src="/web_listview_custom_element_number/static/src/js/web_listview_custom_element_number.js"></script>
|
||||||
|
</xpath>
|
||||||
|
</template>
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
</odoo>
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
****************************************************************************-->
|
|
||||||
|
|
||||||
<openerp>
|
|
||||||
<data>
|
|
||||||
<template id="assets_backend" name="web_listview_custom_element_number assets" inherit_id="web.assets_backend">
|
|
||||||
<xpath expr="." position="inside">
|
|
||||||
<link rel="stylesheet" href="/web_listview_custom_element_number/static/src/css/web_listview_custom_element_number.css"/>
|
|
||||||
<script type="text/javascript" src="/web_listview_custom_element_number/static/src/js/web_listview_custom_element_number.js"></script>
|
|
||||||
</xpath>
|
|
||||||
</template>
|
|
||||||
</data>
|
|
||||||
</openerp>
|
|
||||||
|
|
Loading…
Reference in New Issue