diff options
| author | Alexandre Kühn <aku@odoo.com> | 2018-04-10 14:14:15 +0200 |
|---|---|---|
| committer | Géry Debongnie <ged@odoo.com> | 2018-04-10 17:41:12 +0200 |
| commit | 4f6f562c973ce2efd5631ea0e249e75d94cac104 (patch) | |
| tree | d78e3b26ed2c7f7300b38aec38e1630f3d1e7092 | |
| parent | 270dd268bf0ea7d22c0cbcaf2c4c02b948bf74bd (diff) | |
[IMP] base: generic Edit View menu item text in debug mode
With this commit, the menu item for editing a view in debug mode has been
changed.
Instead of "Edit List View", it is now "Edit View: List".
That way, the code is shorter, generic, and translatable.
Exception to above changes: search view, which is unchanged
(it remains "Edit Searchview")
| -rw-r--r-- | addons/web/static/src/xml/base.xml | 9 | ||||
| -rw-r--r-- | addons/web/static/tests/widgets/debug_manager_tests.js | 71 | ||||
| -rw-r--r-- | addons/web/views/webclient_templates.xml | 1 |
3 files changed, 73 insertions, 8 deletions
diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 0cd931553f0..931cb9ccf86 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -264,14 +264,7 @@ <t t-if="can_edit"> <li> <a href="#" data-action="edit" data-model="ir.ui.view" t-att-data-id="view.fieldsView.view_id"> - <t t-if="view.type == 'form'">Edit Form view</t> - <t t-elif="view.type == 'list'">Edit List view</t> - <t t-elif="view.type == 'kanban'">Edit Kanban view</t> - <t t-elif="view.type == 'graph'">Edit Graph view</t> - <t t-elif="view.type == 'gantt'">Edit Gantt view</t> - <t t-elif="view.type == 'pivot'">Edit Pivot view</t> - <t t-elif="view.type == 'calendar'">Edit Calendar view</t> - <t t-else="1">Edit view, type: <t t-esc="_.str.capitalize(view.type)"/></t> + Edit View: <t t-esc="_.str.capitalize(view.type)"/> </a> </li> <li t-if="searchview and searchview.$el.is(':visible')"><a href="#" data-action="edit" data-model="ir.ui.view" t-att-data-id="action.searchFieldsView.view_id">Edit SearchView</a></li> diff --git a/addons/web/static/tests/widgets/debug_manager_tests.js b/addons/web/static/tests/widgets/debug_manager_tests.js new file mode 100644 index 00000000000..c63fd02e48d --- /dev/null +++ b/addons/web/static/tests/widgets/debug_manager_tests.js @@ -0,0 +1,71 @@ +odoo.define('web.debugManagerTests', function (require) { +"use strict"; + +var DebugManager = require('web.DebugManager'); +var testUtils = require('web.test_utils'); + +/** + * Create and return an instance of DebugManager with all rpcs going through a + * mock method, assuming that the user has access rights, and is an admin. + * + * @param {Object} [params={}] + */ +var createDebugManager = function (params) { + params = params || {}; + _.extend(params, { + mockRPC: function (route, args) { + if (args.method === 'check_access_rights') { + return $.when(true); + } + if (args.method === 'xmlid_to_res_id') { + return $.when(true); + } + return this._super.apply(this, arguments); + }, + session: { + user_has_group: function (group) { + if (group === 'base.group_no_one') { + return $.when(true); + } + return this._super.apply(this, arguments); + }, + }, + }); + var debugManager = new DebugManager(); + testUtils.addMockEnvironment(debugManager, params); + return debugManager; +}; + +QUnit.module('DebugManager', {}, function () { + + QUnit.test("edit view menu item", function (assert) { + assert.expect(3); + + var debugManager = createDebugManager(); + + debugManager.appendTo($('#qunit-fixture')); + + // Simulate update debug manager from web client + var action = { + views: [{ + fieldsView: { + view_id: 1, + }, + type: "list", + }], + }; + var view = { + viewType: "list", + }; + debugManager.update('action', action, view); + + var $editView = debugManager.$('a[data-action=edit][data-model="ir.ui.view"]'); + assert.strictEqual($editView.length, 1, "should have edit view menu item"); + assert.strictEqual($editView.text().trim(), "Edit View: List", + "should have correct menu item text for editing view"); + assert.strictEqual($editView.data('id'), 1, "should have correct view_id"); + + debugManager.destroy(); + }); +}); +}); diff --git a/addons/web/views/webclient_templates.xml b/addons/web/views/webclient_templates.xml index 92290a846c8..0e5c6990e9e 100644 --- a/addons/web/views/webclient_templates.xml +++ b/addons/web/views/webclient_templates.xml @@ -509,6 +509,7 @@ <script type="text/javascript" src="/web/static/tests/chrome/pager_tests.js"></script> <script type="text/javascript" src="/web/static/tests/widgets/data_export_tests.js"/> + <script type="text/javascript" src="/web/static/tests/widgets/debug_manager_tests.js"/> <script type="text/javascript" src="/web/static/tests/widgets/domain_selector_tests.js"/> <script type="text/javascript" src="/web/static/tests/widgets/model_field_selector_tests.js"/> <script type="text/javascript" src="/web/static/tests/widgets/rainbow_man_tests.js"/> |
