summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/core/utils.js22
-rw-r--r--addons/web/static/src/js/tools/test_menus.js4
2 files changed, 24 insertions, 2 deletions
diff --git a/addons/web/static/src/js/core/utils.js b/addons/web/static/src/js/core/utils.js
index 243f3f51cd0..699a912ccc3 100644
--- a/addons/web/static/src/js/core/utils.js
+++ b/addons/web/static/src/js/core/utils.js
@@ -629,6 +629,28 @@ var utils = {
].join(';');
},
/**
+ * Returns a string formatted using given values.
+ * If the value is an object, its keys will replace `%(key)s` expressions.
+ * If the values are a set of strings, they will replace `%s` expressions.
+ * If no value is given, the string will not be formatted.
+ *
+ * @param {string} string
+ * @param {(Object|...string)} values
+ */
+ sprintf: function (string, ...values) {
+ if (values.length === 1 && typeof values[0] === 'object') {
+ const valuesDict = values[0];
+ for (const value in valuesDict) {
+ string = string.replace(`%(${value})s`, valuesDict[value]);
+ }
+ } else {
+ for (const value of values) {
+ string = string.replace(/%s/, value);
+ }
+ }
+ return string;
+ },
+ /**
* Sort an array in place, keeping the initial order for identical values.
*
* @param {Array} array
diff --git a/addons/web/static/src/js/tools/test_menus.js b/addons/web/static/src/js/tools/test_menus.js
index 9767aa29fed..0f91cab4c60 100644
--- a/addons/web/static/src/js/tools/test_menus.js
+++ b/addons/web/static/src/js/tools/test_menus.js
@@ -216,8 +216,8 @@
function testFilters() {
if (appsMenusOnly === true) return Promise.resolve();
var filterProm = Promise.resolve();
- // var $filters = $('div.o_control_panel div.btn-group.o_dropdown > ul.o_filters_menu > li:not(.o_add_custom_filter)');
- var $filters = $('.o_filters_menu > .o_menu_item:not(.d-none)');
+ // var $filters = $('div.o_control_panel div.btn-group.o_dropdown > ul.o_filter_menu > li:not(.o_add_custom_filter)');
+ var $filters = $('.o_filter_menu > .o_menu_item:not(.d-none)');
console.log("Testing " + $filters.length + " filters");
var filter_ids = _.compact(_.map($filters, function(f) { return f.dataset.id}));
filter_ids.forEach(function(filter_id){