From 52ec536cef2ec84af0b36746f19a8cdf9f23fe2a Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Fri, 21 Dec 2018 10:37:10 +0000 Subject: [PATCH] [REF] *: make stronger bootstrap assets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * portal, theme_bootswatch, web, web_editor, website With less2sass and bs3tobs4 tasks, the assets structure was reviewed to handle the specificities of both framework and to prepare for our next odoo tasks. In particular, the assets_helpers and bootstrap overrides were basically split into 4 parts: utils, primary variables, secondary variables and bootstrap variables. (see https://github.com/odoo/odoo/commit/6e4db7d13a926845bf82f5b035afede42d6d5a89) Using the !default system for the bootstrap variables parts seems now a good improvement. This is part of what this commit does: adding the default flag for all bootstrap variables overrides and inverting the order of the files in the _assets_backend_helpers and _assets_frontend_helpers templates. This allows to avoid code like this: portal: ``` $body-bg: white; ``` website: ``` @​if $var != null { $body-bg: $var; } ``` This code makes the body white with portal or equal to $var with website if $var has a value. The same behavior in the new file order is achieved with: website: ``` $body-bg: $var !default; ``` portal: ``` $body-bg: white !default; ``` This order is now also followed for the _assets_secondary_variables templates (there are only a few). This commit also make better assets hierarchy by making website inherit from portal assets (instead of web) and portal inherit from web_editor assets (instead of web) (thus relying on strong dependencies instead of installation order which is not always right for migrated databases). closes odoo/odoo#29757 --- addons/portal/__manifest__.py | 2 +- .../static/src/scss/bootstrap_overridden.scss | 13 +-- addons/portal/views/assets.xml | 6 +- .../views/theme_bootswatch_templates.xml | 38 ++++---- .../static/src/scss/bootstrap_overridden.scss | 88 ++++++++----------- .../scss/bootstrap_overridden_frontend.scss | 2 +- .../static/src/scss/secondary_variables.scss | 32 +++---- .../static/src/scss/bootstrap_overridden.scss | 24 +---- .../static/src/scss/secondary_variables.scss | 37 ++++++++ addons/web_editor/views/editor.xml | 10 ++- .../static/src/scss/bootstrap_overridden.scss | 24 +++-- addons/website/views/website_templates.xml | 12 +-- 12 files changed, 152 insertions(+), 136 deletions(-) create mode 100644 addons/web_editor/static/src/scss/secondary_variables.scss diff --git a/addons/portal/__manifest__.py b/addons/portal/__manifest__.py index e9fe1e36151..1fb78f87335 100644 --- a/addons/portal/__manifest__.py +++ b/addons/portal/__manifest__.py @@ -15,7 +15,7 @@ portal. This module contains most code coming from odoo v10 website_portal. Purpose of this module is to allow the display of a customer portal without having a dependency towards website edition and customization capabilities.""", - 'depends': ['http_routing', 'mail'], + 'depends': ['web', 'web_editor', 'http_routing', 'mail'], 'data': [ 'data/portal_data.xml', 'views/assets.xml', diff --git a/addons/portal/static/src/scss/bootstrap_overridden.scss b/addons/portal/static/src/scss/bootstrap_overridden.scss index 8f129e7bee4..b1eb608633b 100644 --- a/addons/portal/static/src/scss/bootstrap_overridden.scss +++ b/addons/portal/static/src/scss/bootstrap_overridden.scss @@ -1,23 +1,24 @@ // This variable affects the `.h-*` and `.w-*` classes. -$sizes: ( +$sizes: () !default; +$sizes: map-merge(( 0: 0, -); +), $sizes); // Body // // Settings for the `` element. -$body-bg: $o-portal-default-body-bg; +$body-bg: $o-portal-default-body-bg !default; // Fonts // // Font, line-height, and color for body text, headings, and more. -$font-size-sm: (12 / 16) * 1rem; +$font-size-sm: (12 / 16) * 1rem !default; // Buttons // // For each of Bootstrap's buttons, define text, background, and border color. -$btn-padding-y-sm: (1 / 16) * 1rem; -$btn-padding-x-sm: (5 / 16) * 1rem; +$btn-padding-y-sm: (1 / 16) * 1rem !default; +$btn-padding-x-sm: (5 / 16) * 1rem !default; diff --git a/addons/portal/views/assets.xml b/addons/portal/views/assets.xml index d83de5c4898..da71821fa9a 100644 --- a/addons/portal/views/assets.xml +++ b/addons/portal/views/assets.xml @@ -5,13 +5,13 @@ -