[REF] web, *: review the assets helpers organization

* survey, website_slides

While not changing their name or their amount, this commit reorganizes
the assets helpers to:

Avoid all file duplicates in different helpers
----------------------------------------------

Before, we had to put some files in different helpers, like our
bootstrap mixin overrides which were in the _assets_utils template and
in the _assets_bootstrap template.

Enforce the use of an helper when using bootstrap
-------------------------------------------------

Bootstrap functions, variables and mixins are now out of the
_assets_bootstrap template, which now only contains bootstrap css rules
and our bootstrap fixes and extensions.

Allow using the correct bootstrap utils in all assets
-----------------------------------------------------

In some assets (especially editor ones), we may want to use bootstrap
variables even though bootstrap is not included in those. This worked
before but using *default* bootstrap variables. Now, our overrides can
be properly included if necessary.

Note: this commit may also be a first step to allow for backend
bootstrap and frontend bootstrap to co-exist.

closes odoo/odoo#28204
This commit is contained in:
qsm-odoo
2018-11-26 12:23:09 +00:00
parent 4173d4603e
commit 2dcd8c8566
6 changed files with 31 additions and 35 deletions
+4 -2
View File
@@ -11,7 +11,9 @@
<script type="text/javascript" src="/survey/static/src/js/tour_test_survey.js"></script>
<script type="text/javascript" src="/web/static/src/js/fields/field_utils.js"></script>
<t t-call="web._assets_frontend_helpers"/>
<t t-call="web._assets_helpers">
<t t-call="web._assets_frontend_helpers"/>
</t>
<link href="/web/static/lib/nvd3/nv.d3.css" rel="stylesheet" type="text/css"></link>
<t t-call="web._assets_bootstrap"/>
<link rel="stylesheet" type="text/less" href="/web/static/src/scss/fonts.scss" />
@@ -27,4 +29,4 @@
</xpath>
</template>
</data>
</odoo>
</odoo>
@@ -1,11 +1,14 @@
// This file is importing bootstrap. While a simple "import "bootstrap";"
// should be enough, this does not allow overridding mixins. Overridding mixins
// is necessary for some of our need and allow to generate more efficient CSS
// than adding more rules. This file instead copies the second part of the
// content of the "bootstrap.scss" files to allow adding mixin overrides in
// between.
// should be enough, this does not allow overridding mixins/functions.
// Overridding those is necessary for some of our need and allow to generate
// more efficient CSS than adding more rules. This file instead copies the
// content of the "bootstrap.scss" files but do not import functions, variables
// and mixins which will be handled "by hand" in _assets_helpers.
// @import "functions";
// @import "variables";
// @import "mixins";
@import "root";
@import "reboot";
@import "type";
@@ -1,11 +0,0 @@
// This file is importing bootstrap. While a simple "import "bootstrap";"
// should be enough, this does not allow overridding mixins. Overridding mixins
// is necessary for some of our need and allow to generate more efficient CSS
// than adding more rules. This file instead copies the first part of the
// content of the "bootstrap.scss" files to allow adding mixin overrides in
// between.
@import "functions";
@import "variables";
@import "mixins";
+4 -3
View File
@@ -3,10 +3,11 @@
<!-- Assets for reports -->
<template id="report_assets_common">
<t t-call="web._assets_helpers"><t t-set="no_bs_vars" t-value="True"/></t>
<t t-call="web._assets_helpers">
<!-- FIXME web_editor ? -->
<link rel="stylesheet" type="text/scss" href="/web_editor/static/src/scss/bootstrap_overridden.scss"/>
</t>
<!-- FIXME web_editor ? -->
<link rel="stylesheet" type="text/scss" href="/web_editor/static/src/scss/bootstrap_overridden.scss"/>
<t t-call="web._assets_bootstrap"/>
<link href="/base/static/src/css/description.css" rel="stylesheet" type="text/css"/>
+13 -12
View File
@@ -3,8 +3,10 @@
<template id="_assets_utils">
<link rel="stylesheet" type="text/scss" href="/web/static/lib/bootstrap/scss/_functions.scss"/>
<link rel="stylesheet" type="text/scss" href="/web/static/lib/bootstrap/scss/_mixins.scss"/>
<link rel="stylesheet" type="text/scss" href="/web/static/src/scss/utils.scss"/>
<link rel="stylesheet" type="text/scss" href="/web/static/src/scss/bs_mixins_overrides.scss"/>
<link rel="stylesheet" type="text/scss" href="/web/static/src/scss/utils.scss"/>
</template>
<template id="_assets_primary_variables">
@@ -20,26 +22,21 @@
<t t-call="web._assets_primary_variables"/>
<t t-call="web._assets_secondary_variables"/>
<!-- Bootstrap variables should not be necessary, all pages come with bootstrap in at least one of their -->
<!-- bundle and, ideally, these should be available in all assets... with their odoo override. This system -->
<!-- however works for now as non-backend and non-frontend assets do not need overriden BS variables yet. -->
<link t-if="not no_bs_vars" rel="stylesheet" type="text/scss" href="/web/static/lib/bootstrap/scss/_variables.scss"/>
<t t-raw="0"/>
<link rel="stylesheet" type="text/scss" href="/web/static/lib/bootstrap/scss/_variables.scss"/>
</template>
<template id="_assets_backend_helpers">
<t t-call="web._assets_helpers"><t t-set="no_bs_vars" t-value="True"/></t>
<link rel="stylesheet" type="text/scss" href="/web/static/src/scss/bootstrap_overridden.scss"/>
</template>
<template id="_assets_frontend_helpers">
<t t-call="web._assets_helpers"><t t-set="no_bs_vars" t-value="True"/></t>
<link rel="stylesheet" type="text/scss" href="/web/static/src/scss/bootstrap_overridden_frontend.scss"/>
</template>
<template id="_assets_bootstrap">
<link rel="stylesheet" type="text/scss" href="/web/static/src/scss/import_bootstrap_part1.scss"/>
<link rel="stylesheet" type="text/scss" href="/web/static/src/scss/bs_mixins_overrides.scss"/>
<link rel="stylesheet" type="text/scss" href="/web/static/src/scss/import_bootstrap_part2.scss"/>
<link rel="stylesheet" type="text/scss" href="/web/static/src/scss/import_bootstrap.scss"/>
<link rel="stylesheet" type="text/scss" href="/web/static/src/scss/bootstrap_review.scss"/>
</template>
@@ -141,7 +138,9 @@
</template>
<template id="assets_backend" name="Backend Assets (used in backend interface)">
<t t-call="web._assets_backend_helpers"/>
<t t-call="web._assets_helpers">
<t t-call="web._assets_backend_helpers"/>
</t>
<t t-call="web._assets_bootstrap"/>
<link rel="stylesheet" type="text/scss" href="/web/static/lib/tempusdominus/tempusdominus.scss"/>
@@ -316,7 +315,9 @@
</template>
<template id="web.assets_frontend" name="Website Assets">
<t t-call="web._assets_frontend_helpers"/>
<t t-call="web._assets_helpers">
<t t-call="web._assets_frontend_helpers"/>
</t>
<t t-call="web._assets_bootstrap"/>
<link rel="stylesheet" type="text/scss" href="/web/static/lib/tempusdominus/tempusdominus.scss"/>
+2 -2
View File
@@ -21,7 +21,7 @@
<!-- Bundle (minimal) for embedded slide iframe -->
<template id="website_slides.slide_embed_assets" name="Website slides embed assets">
<t t-call="web._assets_helpers"><t t-set="no_bs_vars" t-value="True"/></t>
<t t-call="web._assets_helpers"/>
<t t-call="web._assets_bootstrap"/>
<link rel="stylesheet" type="text/scss" href="/website_slides/static/src/scss/website_slides.scss" t-ignore="true"/>
@@ -32,4 +32,4 @@
</data>
</odoo>
</odoo>