[IMP] pre-commit run after update

Includes some manual fixes to silent ESLint warnings.
pull/2684/head
Jairo Llopis 2020-01-24 13:45:39 +00:00 committed by Taras Shabaranskyi
parent 2d2f079fa9
commit 7db4a9ee3e
9 changed files with 305 additions and 274 deletions

View File

@ -42,8 +42,7 @@ $chatter_zone_width: 35%;
}
.o_menu_sections,
.o_menu_systray,
{
.o_menu_systray {
padding: 0;
}
}
@ -56,8 +55,7 @@ $chatter_zone_width: 35%;
// Hide big things
.o_menu_brand,
.o_menu_sections,
.oe_topbar_name,
{
.oe_topbar_name {
display: none;
}
@ -85,8 +83,7 @@ $chatter_zone_width: 35%;
> li,
.o_menu_entry_lvl_1,
.o_menu_header_lvl_1,
{
.o_menu_header_lvl_1 {
// Homogeneous background color
background-color: $dropdown-bg;
color: $dropdown-link-color;
@ -137,7 +134,6 @@ $chatter_zone_width: 35%;
// Iconized full screen apps menu
.o_menu_apps {
.search-input:focus {
border-color: $o-brand-primary;
}
@ -238,8 +234,7 @@ html .o_web_client .o_action_manager .o_action {
.o_cp_buttons,
.o_cp_left,
.o_cp_right,
.o_cp_searchview,
{
.o_cp_searchview {
flex: 1 1 100%;
@include media-breakpoint-up(md) {
flex-basis: 50%;
@ -251,8 +246,7 @@ html .o_web_client .o_action_manager .o_action {
}
.o_cp_searchview,
.o_cp_right,
{
.o_cp_right {
flex-basis: 10%;
}
@ -333,7 +327,8 @@ html .o_web_client .o_action_manager .o_action {
}
// Normal views
.o_content, .modal-content {
.o_content,
.modal-content {
max-width: 100%;
// Form views
@ -380,14 +375,13 @@ html .o_web_client .o_action_manager .o_action {
.oe_button_box {
.o_dropdown_more {
button:last-child {
border-right: 1px solid gray('400');
border-right: 1px solid gray("400");
}
}
}
// Avoid overflow on forms with title and/or button box
.oe_title,
{
.oe_title {
max-width: 100%;
}
@ -442,8 +436,7 @@ html .o_web_client .o_action_manager .o_action {
// Full width in form sheets
.o_form_sheet,
.oe_chatter,
{
.oe_chatter {
min-width: auto;
max-width: 98%;
}
@ -508,7 +501,7 @@ html .o_web_client .o_action_manager .o_action {
}
.o_chatter {
border-left: 1px solid gray('400');
border-left: 1px solid gray("400");
flex: 0 0 $chatter_zone_width;
max-width: initial;
min-width: initial;
@ -547,7 +540,8 @@ html .o_web_client .o_action_manager .o_action {
.table-responsive {
.o_list_table {
// th & td are here for compatibility with chrome
thead, thead tr:nth-child(1) th {
thead,
thead tr:nth-child(1) th {
position: sticky;
top: 0;
z-index: 1;
@ -555,7 +549,8 @@ html .o_web_client .o_action_manager .o_action {
thead tr:nth-child(1) th {
background-color: $o-list-footer-bg-color;
}
tfoot, tfoot tr:nth-child(1) td {
tfoot,
tfoot tr:nth-child(1) td {
position: sticky;
bottom: 0;
}
@ -585,10 +580,12 @@ html .o_web_client .o_action_manager .o_action {
right: 0;
/* Show/Hide control buttons (next, prev, etc..) */
&:hover .arrow, &:hover .o_viewer_toolbar {
&:hover .arrow,
&:hover .o_viewer_toolbar {
display: flex;
}
.arrow, .o_viewer_toolbar {
.arrow,
.o_viewer_toolbar {
display: none;
}
@ -611,7 +608,8 @@ html .o_web_client .o_action_manager .o_action {
}
}
@include media-breakpoint-down(lg) {
.o_minimize_btn, .o_maximize_btn {
.o_minimize_btn,
.o_maximize_btn {
display: none;
}
}
@ -619,7 +617,8 @@ html .o_web_client .o_action_manager .o_action {
}
/* Max/Min buttons only are usefull in sided mode */
.o_web_client:not(.o_chatter_position_sided) {
.o_minimize_btn, .o_maximize_btn {
.o_minimize_btn,
.o_maximize_btn {
display: none;
}
}

View File

@ -1,28 +1,28 @@
/* Copyright 2018 Tecnativa - Jairo Llopis
* License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). */
odoo.define('web_responsive', function (require) {
'use strict';
odoo.define("web_responsive", function(require) {
"use strict";
const ActionManager = require('web.ActionManager');
const ActionManager = require("web.ActionManager");
const AbstractWebClient = require("web.AbstractWebClient");
const AppsMenu = require("web.AppsMenu");
const BasicController = require('web.BasicController');
const BasicController = require("web.BasicController");
const config = require("web.config");
const core = require("web.core");
const FormRenderer = require('web.FormRenderer');
const FormRenderer = require("web.FormRenderer");
const Menu = require("web.Menu");
const RelationalFields = require('web.relational_fields');
const Chatter = require('mail.Chatter');
const ListRenderer = require('web.ListRenderer');
const DocumentViewer = require('mail.DocumentViewer');
const RelationalFields = require("web.relational_fields");
const Chatter = require("mail.Chatter");
const ListRenderer = require("web.ListRenderer");
const DocumentViewer = require("mail.DocumentViewer");
/*
* Helper function to know if are waiting
*
*/
function isWaiting() {
return $('.oe_wait').length !== 0;
return $(".oe_wait").length !== 0;
}
/**
@ -82,14 +82,17 @@ odoo.define('web_responsive', function (require) {
}
AppsMenu.include({
events: _.extend({
events: _.extend(
{
"keydown .search-input input": "_searchResultsNavigate",
"input .search-input input": "_searchMenusSchedule",
"click .o-menu-search-result": "_searchResultChosen",
"shown.bs.dropdown": "_searchFocus",
"hidden.bs.dropdown": "_searchReset",
"hide.bs.dropdown": "_hideAppsMenu",
}, AppsMenu.prototype.events),
},
AppsMenu.prototype.events
),
/**
* Rescue some menu data stripped out in original method.
@ -99,16 +102,11 @@ odoo.define('web_responsive', function (require) {
init: function(parent, menuData) {
this._super.apply(this, arguments);
// Keep base64 icon for main menus
for (let n in this._apps) {
this._apps[n].web_icon_data =
menuData.children[n].web_icon_data;
for (const n in this._apps) {
this._apps[n].web_icon_data = menuData.children[n].web_icon_data;
}
// Store menu data in a format searchable by fuzzy.js
this._searchableMenus = _.reduce(
menuData.children,
findNames,
{}
);
this._searchableMenus = _.reduce(menuData.children, findNames, {});
// Search only after timeout, for fast typers
this._search_def = false;
},
@ -144,9 +142,12 @@ odoo.define('web_responsive', function (require) {
*/
_menuInfo: function(key) {
const original = this._searchableMenus[key];
return _.extend({
action_id: parseInt(original.action.split(',')[1], 10),
}, original);
return _.extend(
{
action_id: parseInt(original.action.split(",")[1], 10),
},
original
);
},
/**
@ -171,7 +172,7 @@ odoo.define('web_responsive', function (require) {
* Schedule a search on current menu items.
*/
_searchMenusSchedule: function() {
this._search_def = new Promise((resolve) => {
this._search_def = new Promise(resolve => {
setTimeout(resolve, 50);
});
this._search_def.then(this._searchMenus.bind(this));
@ -187,26 +188,16 @@ odoo.define('web_responsive', function (require) {
this.$search_results.empty();
return;
}
var results = fuzzy.filter(
query,
_.keys(this._searchableMenus),
{
var results = fuzzy.filter(query, _.keys(this._searchableMenus), {
pre: "<b>",
post: "</b>",
}
);
this.$search_container.toggleClass(
"has-results",
Boolean(results.length)
);
});
this.$search_container.toggleClass("has-results", Boolean(results.length));
this.$search_results.html(
core.qweb.render(
"web_responsive.MenuSearchResults",
{
core.qweb.render("web_responsive.MenuSearchResults", {
results: results,
widget: this,
}
)
})
);
},
@ -293,12 +284,11 @@ odoo.define('web_responsive', function (require) {
* Control if AppDrawer can be closed
*/
_hideAppsMenu: function() {
return !isWaiting() && !this.$('input').is(':focus');
return !isWaiting() && !this.$("input").is(":focus");
},
});
BasicController.include({
/**
* Close the AppDrawer if the data set is dirty and a discard dialog
* is opened
@ -307,25 +297,27 @@ odoo.define('web_responsive', function (require) {
*/
canBeDiscarded: function(recordID) {
if (this.model.isDirty(recordID || this.handle)) {
$('.o_menu_apps .dropdown:has(.dropdown-menu.show) > a')
.dropdown('toggle');
$('.o_menu_sections li.show .dropdown-toggle')
.dropdown('toggle');
$(".o_menu_apps .dropdown:has(.dropdown-menu.show) > a").dropdown(
"toggle"
);
$(".o_menu_sections li.show .dropdown-toggle").dropdown("toggle");
}
return this._super.apply(this, arguments);
},
});
Menu.include({
events: _.extend({
events: _.extend(
{
// Clicking a hamburger menu item should close the hamburger
"click .o_menu_sections [role=menuitem]": "_hideMobileSubmenus",
// Opening any dropdown in the navbar should hide the hamburger
"show.bs.dropdown .o_menu_systray, .o_menu_apps":
"_hideMobileSubmenus",
"show.bs.dropdown .o_menu_systray, .o_menu_apps": "_hideMobileSubmenus",
// Prevent close section menu
"hide.bs.dropdown .o_menu_sections": "_hideMenuSection",
}, Menu.prototype.events),
},
Menu.prototype.events
),
start: function() {
this.$menu_toggle = this.$(".o-menu-toggle");
@ -378,7 +370,6 @@ odoo.define('web_responsive', function (require) {
});
RelationalFields.FieldStatus.include({
/**
* Fold all on mobiles.
*
@ -387,7 +378,7 @@ odoo.define('web_responsive', function (require) {
_setState: function() {
this._super.apply(this, arguments);
if (config.device.isMobile) {
_.map(this.status_information, (value) => {
_.map(this.status_information, value => {
value.fold = true;
});
}
@ -400,9 +391,10 @@ odoo.define('web_responsive', function (require) {
const self = this;
return this._super.apply(this, arguments).then(() => {
const $col_selector = self.$el.find(
'.o_optional_columns_dropdown_toggle');
".o_optional_columns_dropdown_toggle"
);
if ($col_selector.length !== 0) {
const $th = self.$el.find('thead>tr:first>th:last');
const $th = self.$el.find("thead>tr:first>th:last");
$col_selector.appendTo($th);
}
});
@ -421,7 +413,6 @@ odoo.define('web_responsive', function (require) {
// Responsive view "action" buttons
FormRenderer.include({
/**
* In mobiles, put all statusbar buttons in a dropdown.
*
@ -438,9 +429,9 @@ odoo.define('web_responsive', function (require) {
// $buttons must be appended by JS because all events are bound
$buttons.addClass("dropdown-menu");
const $dropdown = $(core.qweb.render(
'web_responsive.MenuStatusbarButtons'
));
const $dropdown = $(
core.qweb.render("web_responsive.MenuStatusbarButtons")
);
$buttons.addClass("dropdown-menu").appendTo($dropdown);
return $dropdown;
},
@ -449,9 +440,11 @@ odoo.define('web_responsive', function (require) {
// Chatter Hide Composer
Chatter.include({
_openComposer: function(options) {
if (this._composer &&
if (
this._composer &&
options.isLog === this._composer.options.isLog &&
this._composer.$el.is(':visible')) {
this._composer.$el.is(":visible")
) {
this._closeComposer(false);
} else {
this._super.apply(this, arguments);
@ -461,7 +454,6 @@ odoo.define('web_responsive', function (require) {
// Hide AppDrawer or Menu when the action has been completed
ActionManager.include({
/**
* Because the menu aren't closed when click, this method
* searchs for the menu with the action executed to close it.
@ -472,26 +464,33 @@ odoo.define('web_responsive', function (require) {
* The executed action
*/
_hideMenusByAction: function(action) {
const uniq_sel = '[data-action-id='+action.id+']';
const uniq_sel = "[data-action-id=" + action.id + "]";
// Need close AppDrawer?
const menu_apps_dropdown = document.querySelector(
'.o_menu_apps .dropdown');
$(menu_apps_dropdown).has('.dropdown-menu.show')
.has(uniq_sel).find('> a').dropdown('toggle');
const menu_apps_dropdown = document.querySelector(".o_menu_apps .dropdown");
$(menu_apps_dropdown)
.has(".dropdown-menu.show")
.has(uniq_sel)
.find("> a")
.dropdown("toggle");
// Need close Sections Menu?
const menu_sections = document.querySelector(
'.o_menu_sections li.show');
$(menu_sections).has(uniq_sel).find('.dropdown-toggle')
.dropdown('toggle');
const menu_sections = document.querySelector(".o_menu_sections li.show");
$(menu_sections)
.has(uniq_sel)
.find(".dropdown-toggle")
.dropdown("toggle");
// Need close Mobile?
const menu_sections_mobile = document.querySelector(
'.o_menu_sections.show');
$(menu_sections_mobile).has(uniq_sel).hide();
".o_menu_sections.show"
);
$(menu_sections_mobile)
.has(uniq_sel)
.hide();
},
_handleAction: function(action) {
return this._super.apply(this, arguments).finally(
$.proxy(this, '_hideMenusByAction', action));
return this._super
.apply(this, arguments)
.finally($.proxy(this, "_hideMenusByAction", action));
},
});
@ -508,7 +507,6 @@ odoo.define('web_responsive', function (require) {
* enable this behavior.
*/
var KeyboardNavigationShiftAltMixin = {
/**
* Alter the key event to require pressing Shift.
*
@ -559,24 +557,24 @@ odoo.define('web_responsive', function (require) {
// this.$el is active, but now the modal have buttons that can obtain
// the focus. For this reason we now listen core events, that are
// dispatched every time.
events: _.extend(_.omit(DocumentViewer.prototype.events, [
'keydown',
'keyup',
]), {
'click .o_maximize_btn': '_onClickMaximize',
'click .o_minimize_btn': '_onClickMinimize',
'shown.bs.modal': '_onShownModal',
}),
events: _.extend(
_.omit(DocumentViewer.prototype.events, ["keydown", "keyup"]),
{
"click .o_maximize_btn": "_onClickMaximize",
"click .o_minimize_btn": "_onClickMinimize",
"shown.bs.modal": "_onShownModal",
}
),
start: function() {
core.bus.on('keydown', this, this._onKeydown);
core.bus.on('keyup', this, this._onKeyUp);
core.bus.on("keydown", this, this._onKeydown);
core.bus.on("keyup", this, this._onKeyUp);
return this._super.apply(this, arguments);
},
destroy: function() {
core.bus.off('keydown', this, this._onKeydown);
core.bus.off('keyup', this, this._onKeyUp);
core.bus.off("keydown", this, this._onKeydown);
core.bus.off("keyup", this, this._onKeyUp);
this._super.apply(this, arguments);
},
@ -584,13 +582,13 @@ odoo.define('web_responsive', function (require) {
// Disable auto-focus to allow to use controls in edit mode.
// This only affects the active modal.
// More info: https://stackoverflow.com/a/14795256
$(document).off('focusin.modal');
$(document).off("focusin.modal");
},
_onClickMaximize: function() {
this.$el.removeClass('o_responsive_document_viewer');
this.$el.removeClass("o_responsive_document_viewer");
},
_onClickMinimize: function() {
this.$el.addClass('o_responsive_document_viewer');
this.$el.addClass("o_responsive_document_viewer");
},
});
});

View File

@ -1,12 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Copyright 2018 Tecnativa - Jairo Llopis
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
<template>
<t t-extend="AppsMenu">
<!-- App icons must be clickable -->
<t t-jquery=".o_app" t-operation="attributes">
<attribute name="t-attf-href">#menu_id=#{app.menuID}&amp;action_id=#{app.actionID}</attribute>
<attribute
name="t-attf-href"
>#menu_id=#{app.menuID}&amp;action_id=#{app.actionID}</attribute>
</t>
<!-- App icons should be more than a text -->
@ -29,10 +30,12 @@
<i class="fa fa-search" />
</div>
</div>
<input type="search"
<input
type="search"
autocomplete="off"
placeholder="Search menus..."
class="form-control"/>
class="form-control"
/>
</div>
</div>
<div class="search-results col-md-10 ml-auto mr-auto" />
@ -42,8 +45,10 @@
<!-- Separate app icon template, for easier inheritance -->
<t t-name="web_responsive.AppIcon">
<img class="o-app-icon"
t-attf-src="data:image/png;base64,#{app.web_icon_data}"/>
<img
class="o-app-icon"
t-attf-src="data:image/png;base64,#{app.web_icon_data}"
/>
<span class="o-app-name">
<t t-esc="app.name" />
</span>
@ -53,13 +58,15 @@
<t t-name="web_responsive.MenuSearchResults">
<t t-foreach="results" t-as="result">
<t t-set="menu" t-value="widget._menuInfo(result.original)" />
<a t-attf-class="o-menu-search-result dropdown-item col-12 ml-auto mr-auto #{result_first ? 'active' : ''}"
<a
t-attf-class="o-menu-search-result dropdown-item col-12 ml-auto mr-auto #{result_first ? 'active' : ''}"
t-attf-style="background-image:url('data:image/png;base64,#{menu.web_icon_data}')"
t-attf-href="#menu_id=#{menu.id}&amp;action_id=#{menu.action_id}"
t-att-data-menu-id="menu.id"
t-att-data-action-id="menu.action_id"
t-att-data-parent-id="menu.parent_id[0]"
t-raw="result.string"/>
t-raw="result.string"
/>
</t>
</t>
</template>

View File

@ -1,11 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Copyright 2019 Tecnativa - Alexandre Díaz
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
<template>
<t t-extend="DocumentViewer">
<t t-jquery=".o_modal_fullscreen" t-operation="attributes">
<attribute name="class">modal o_modal_fullscreen o_document_viewer o_responsive_document_viewer</attribute>
<attribute
name="class"
>modal o_modal_fullscreen o_document_viewer o_responsive_document_viewer</attribute>
<attribute name="data-backdrop">false</attribute>
</t>
</t>
@ -13,9 +14,27 @@
<t t-extend="DocumentViewer.Content">
<t t-jquery=".o_close_btn" t-operation="replace">
<div class="o_buttons float-right mr8">
<a role="button" class="mr8 o_maximize_btn" tabindex="0" aria-label="Maximize" title="Maximize"><i class="fa fa-window-maximize"></i></a>
<a role="button" class="mr8 o_minimize_btn" tabindex="0" aria-label="Minimize" title="Minimize"><i class="fa fa-window-minimize"></i></a>
<a role="button" class="o_close_btn" tabindex="0" aria-label="Close" title="Close"><i class="fa fa-close"></i></a>
<a
role="button"
class="mr8 o_maximize_btn"
tabindex="0"
aria-label="Maximize"
title="Maximize"
><i class="fa fa-window-maximize" /></a>
<a
role="button"
class="mr8 o_minimize_btn"
tabindex="0"
aria-label="Minimize"
title="Minimize"
><i class="fa fa-window-minimize" /></a>
<a
role="button"
class="o_close_btn"
tabindex="0"
aria-label="Close"
title="Close"
><i class="fa fa-close" /></a>
</div>
</t>
</t>

View File

@ -5,23 +5,23 @@
Copyright 2018 Tecnativa - Jairo Llopis
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
-->
<templates id="form_view" xml:space="preserve">
<!-- Template for buttons that display only the icon in xs -->
<t t-name="web_responsive.icon_button">
<i t-attf-class="fa fa-#{icon}"
t-att-title="label"/>
<i t-attf-class="fa fa-#{icon}" t-att-title="label" />
<span class="d-none d-sm-inline" t-esc="label" />
</t>
<t t-name="web_responsive.MenuStatusbarButtons">
<div class="dropdown">
<button class="o_statusbar_buttons_dropdown btn btn-secondary dropdown-toggle"
<button
class="o_statusbar_buttons_dropdown btn btn-secondary dropdown-toggle"
type="button"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false">
aria-expanded="false"
>
<t t-call="web_responsive.icon_button">
<t t-set="icon" t-value="'cogs'" />
<t t-set="label">Quick actions</t>
@ -114,8 +114,10 @@
<t t-extend="Sidebar">
<!-- Replace some common sections by icons in mobile -->
<t t-jquery=".o_dropdown_toggler_btn t[t-esc='section.label']"
t-operation="replace">
<t
t-jquery=".o_dropdown_toggler_btn t[t-esc='section.label']"
t-operation="replace"
>
<t t-set="label" t-value="section.label" />
<t t-if="section.name == 'files'">
<t t-call="web_responsive.icon_button">

View File

@ -1,14 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Copyright 2017-2018 Tecnativa - Jairo Llopis
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
<template>
<t t-extend="Menu">
<t t-jquery=".o_menu_apps" t-operation="after">
<!-- Hamburger button to show submenus in sm screens -->
<button class="o-menu-toggle d-md-none"
<button
class="o-menu-toggle d-md-none"
data-toggle="collapse"
data-target=".o_main_navbar .o_menu_sections">
data-target=".o_main_navbar .o_menu_sections"
>
<i class="fa fa-bars" />
</button>
</t>

View File

@ -1,18 +1,22 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2016 LasLabs Inc.
@author Dave Lasley <dave@laslabs.com>
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
-->
<odoo>
<template id="assets_backend" name="Open Mobile Assets" inherit_id="web.assets_backend">
<template
id="assets_backend"
name="Open Mobile Assets"
inherit_id="web.assets_backend"
>
<xpath expr=".">
<link rel="stylesheet"
<link
rel="stylesheet"
href="/web_responsive/static/src/css/web_responsive.scss"
/>
<script type="application/javascript"
<script
type="application/javascript"
src="/web_responsive/static/src/js/web_responsive.js"
/>
</xpath>

View File

@ -1,11 +1,9 @@
<?xml version="1.0" ?>
<!--
Copyright 2018
@author Alexanre Díaz <dev@redneboa.es>
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
-->
<odoo>
<record id="view_users_form_simple_modif" model="ir.ui.view">

View File

@ -1,18 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2018 Alexandre Díaz
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
-->
<odoo>
<template id="webclient_bootstrap"
<template
id="webclient_bootstrap"
inherit_id="web.webclient_bootstrap"
name="App Drawer - Web Client"
>
<xpath expr="//t[@t-set='body_classname']" position="attributes">
<attribute name="t-value" add="+ ' o_chatter_position_' + (request.env.user.chatter_position or 'normal')" separator=" " />
<attribute
name="t-value"
add="+ ' o_chatter_position_' + (request.env.user.chatter_position or 'normal')"
separator=" "
/>
</xpath>
</template>