diff options
| author | Harpritsinh Sisodiya <hsi@odoo.com> | 2020-01-31 11:07:56 +0000 |
|---|---|---|
| committer | Damien Bouvy <dbo@odoo.com> | 2020-02-21 08:34:24 +0000 |
| commit | 7639f7fbcb7578ca77509c656737747904b1b927 (patch) | |
| tree | 30d30e597a225dd3aedf89bdd3115611e0fa243a /addons/web_editor/static/src | |
| parent | 0c4d808fd73a4d11aafe6aaab8529283da43fef1 (diff) | |
[IMP] web_editor: check resource is custom or not to display warning on editor
adds _isCustomResource method which will check whether resource is custom or
not, this method checks for JS and SCSS resource, if resource is custom then
do not show "No Update" warning inside ace editor.
task-2167570
closes odoo/odoo#44536
Related: odoo/enterprise#8368
Signed-off-by: Damien Bouvy (dbo) <dbo@odoo.com>
Co-authored-by: Mohammed Shekha <msh@odoo.com>
Diffstat (limited to 'addons/web_editor/static/src')
| -rw-r--r-- | addons/web_editor/static/src/js/common/ace.js | 28 | ||||
| -rw-r--r-- | addons/web_editor/static/src/xml/ace.xml | 2 |
2 files changed, 20 insertions, 10 deletions
diff --git a/addons/web_editor/static/src/js/common/ace.js b/addons/web_editor/static/src/js/common/ace.js index dc2d78a53c7..4bbaf5f8fdd 100644 --- a/addons/web_editor/static/src/js/common/ace.js +++ b/addons/web_editor/static/src/js/common/ace.js @@ -378,27 +378,20 @@ var ViewEditor = Widget.extend({ } this.aceEditor.setSession(editingSession); - var isCustomized = false; if (this.currentType === 'xml') { this.$viewID.text(_.str.sprintf(_t("Template ID: %s"), this.views[resID].key)); } else if (this.currentType === 'scss') { - isCustomized = this.scss[resID].customized; this.$viewID.text(_.str.sprintf(_t("SCSS file: %s"), resID)); } else { - isCustomized = this.js[resID].customized; this.$viewID.text(_.str.sprintf(_t("JS file: %s"), resID)); } + const isCustomized = this._isCustomResource(resID); this.$lists[this.currentType].select2('val', resID); this.$resetButton.toggleClass('d-none', this.currentType === 'xml' || !isCustomized); - // TODO the warning message is always shown for XML templates but: - // 1) We have to implement a way to be able to reset XML templates - // otherwise the warning message is not accurate - // 2) We should be able to detect if the XML template is customized to - // not show the warning in that case this.$warningMessage.toggleClass('d-none', - this.currentType !== 'xml' && (resID.indexOf('/user_custom_') >= 0 || isCustomized)); + this.currentType !== 'xml' && (resID.indexOf('/user_custom_') >= 0) || isCustomized); this.aceEditor.resize(true); }, @@ -428,6 +421,23 @@ var ViewEditor = Widget.extend({ return parseInt(value, 10) || value; }, /** + * Checks resource is customized or not. + * + * @private + * @param {integer|string} resID + */ + _isCustomResource(resID) { + // TODO we should be able to detect if the XML template is customized + // to not show the warning in that case + let isCustomized = false; + if (this.currentType === 'scss') { + isCustomized = this.scss[resID].customized; + } else if (this.currentType === 'js') { + isCustomized = this.js[resID].customized; + } + return isCustomized; + }, + /** * Loads data the ace editor will vizualize and process it. Default behavior * is loading the activate views, index them and build their hierarchy. * diff --git a/addons/web_editor/static/src/xml/ace.xml b/addons/web_editor/static/src/xml/ace.xml index f299aa25b92..5d27aa0c7fc 100644 --- a/addons/web_editor/static/src/xml/ace.xml +++ b/addons/web_editor/static/src/xml/ace.xml @@ -50,7 +50,7 @@ </div> <span class="o_ace_editor_resource_info"/> <div class="alert alert-warning alert-dismissible mt-2 mb-0" role="alert"> - If you edit and save this file, you will never receive updates from Odoo anymore unless you reset your customizations. + Editing a built-in file through this editor is not advised, as it will prevent it from being updated during future App upgrades. <button type="button" class="close" aria-label="Close"> <span>&times;</span> </button> |
