summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web/static/src/js')
-rw-r--r--addons/web/static/src/js/chrome.js2
-rw-r--r--addons/web/static/src/js/core.js29
-rw-r--r--addons/web/static/src/js/data_export.js2
-rw-r--r--addons/web/static/src/js/search.js32
-rw-r--r--addons/web/static/src/js/testing.js23
-rw-r--r--addons/web/static/src/js/view_form.js11
6 files changed, 44 insertions, 55 deletions
diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js
index e1b654aa3f7..0aa46ebb104 100644
--- a/addons/web/static/src/js/chrome.js
+++ b/addons/web/static/src/js/chrome.js
@@ -1460,7 +1460,7 @@ instance.web.embed = function (origin, dbname, login, key, action, options) {
$('head').append($('<link>', {
'rel': 'stylesheet',
'type': 'text/css',
- 'href': origin +'/web/webclient/css'
+ 'href': origin +'/web/css/web.assets_webclient'
}));
var currentScript = document.currentScript;
if (!currentScript) {
diff --git a/addons/web/static/src/js/core.js b/addons/web/static/src/js/core.js
index a4bcd1922de..c64da7e5810 100644
--- a/addons/web/static/src/js/core.js
+++ b/addons/web/static/src/js/core.js
@@ -232,7 +232,7 @@ instance.web.Session.include( /** @lends instance.web.Session# */{
var self = this;
return this.session_reload().then(function(result) {
var modules = instance._modules.join(',');
- var deferred = self.rpc('/web/webclient/qweblist', {mods: modules}).then(self.load_qweb.bind(self));
+ var deferred = self.load_qweb(modules);
if(self.session_is_valid()) {
return deferred.then(function() { return self.load_modules(); });
}
@@ -318,7 +318,7 @@ instance.web.Session.include( /** @lends instance.web.Session# */{
loaded = $.when(
loaded,
self.rpc('/web/webclient/csslist', {mods: to_load}).done(self.load_css.bind(self)),
- self.rpc('/web/webclient/qweblist', {mods: to_load}).then(self.load_qweb.bind(self)),
+ self.load_qweb(to_load),
self.rpc('/web/webclient/jslist', {mods: to_load}).done(function(files) {
file_list = file_list.concat(files);
})
@@ -375,14 +375,12 @@ instance.web.Session.include( /** @lends instance.web.Session# */{
}
return d;
},
- load_qweb: function(files) {
+ load_qweb: function(mods) {
var self = this;
- _.each(files, function(file) {
- self.qweb_mutex.exec(function() {
- return self.rpc('/web/proxy/load', {path: file}).then(function(xml) {
- if (!xml) { return; }
- instance.web.qweb.add_template(_.str.trim(xml));
- });
+ self.qweb_mutex.exec(function() {
+ return self.rpc('/web/proxy/load', {path: '/web/webclient/qweb?mods=' + mods}).then(function(xml) {
+ if (!xml) { return; }
+ instance.web.qweb.add_template(_.str.trim(xml));
});
});
return self.qweb_mutex.def;
@@ -460,14 +458,11 @@ instance.web.Session.include( /** @lends instance.web.Session# */{
.appendTo(document.body)
.load(function () {
try {
- if (options.error) {
- if (!this.contentDocument.body.childNodes[1]) {
- options.error(this.contentDocument.body.childNodes);
- }
- else {
- options.error(JSON.parse(this.contentDocument.body.childNodes[1].textContent));
- }
- }
+ if (options.error) {
+ var body = this.contentDocument.body;
+ var node = body.childNodes[1] || body.childNodes[0];
+ options.error(JSON.parse(node.textContent));
+ }
} finally {
complete();
}
diff --git a/addons/web/static/src/js/data_export.js b/addons/web/static/src/js/data_export.js
index 2de933f45e8..2f7ff81d089 100644
--- a/addons/web/static/src/js/data_export.js
+++ b/addons/web/static/src/js/data_export.js
@@ -32,7 +32,7 @@ instance.web.DataExport = instance.web.Dialog.extend({
var self = this;
var options = {
buttons: [
- {text: _t("Close"), click: function () { self.close(); }},
+ {text: _t("Close"), click: function () { self.$el.parents('.modal').modal('hide'); }},
{text: _t("Export To File"), click: function () { self.on_click_export_data(); }}
],
close: function () { self.close();}
diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js
index 04bb1a61d99..832faa4ca62 100644
--- a/addons/web/static/src/js/search.js
+++ b/addons/web/static/src/js/search.js
@@ -29,8 +29,8 @@ my.Facet = B.Model.extend({
B.Model.prototype.initialize.apply(this, arguments);
this.values = new my.FacetValues(values || []);
- this.values.on('add remove change reset', function () {
- this.trigger('change', this);
+ this.values.on('add remove change reset', function (_, options) {
+ this.trigger('change', this, options);
}, this);
},
get: function (key) {
@@ -399,7 +399,8 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
this.setup_global_completion();
this.query = new my.SearchQuery()
.on('add change reset remove', this.proxy('do_search'))
- .on('add change reset remove', this.proxy('renderFacets'));
+ .on('change', this.proxy('renderChangedFacets'))
+ .on('add reset remove', this.proxy('renderFacets'));
if (this.options.hidden) {
this.$el.hide();
@@ -578,14 +579,20 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
.trigger('blur');
},
/**
- *
- * @param {openerp.web.search.SearchQuery | openerp.web.search.Facet} _1
- * @param {openerp.web.search.Facet} [_2]
+ * Call the renderFacets method with the correct arguments.
+ * This is due to the fact that change events are called with two arguments
+ * (model, options) while add, reset and remove events are called with
+ * (collection, model, options) as arguments
+ */
+ renderChangedFacets: function (model, options) {
+ this.renderFacets(undefined, model, options);
+ },
+ /**
+ * @param {openerp.web.search.SearchQuery | undefined} Undefined if event is change
+ * @param {openerp.web.search.Facet}
* @param {Object} [options]
*/
- renderFacets: function (_1, _2, options) {
- // _1: model if event=change, otherwise collection
- // _2: undefined if event=change, otherwise model
+ renderFacets: function (collection, model, options) {
var self = this;
var started = [];
var $e = this.$('div.oe_searchview_facets');
@@ -610,6 +617,7 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
});
$.when.apply(null, started).then(function () {
+ if (options && options.focus_input === false) return;
var input_to_focus;
// options.at: facet inserted at given index, focus next input
// otherwise just focus last input
@@ -618,7 +626,6 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
} else {
input_to_focus = self.input_subviews[(options.at + 1) * 2];
}
-
input_to_focus.$el.focus();
});
},
@@ -1602,8 +1609,11 @@ instance.web.search.ManyToOneField = instance.web.search.CharField.extend({
return facetValue.get('label');
},
make_domain: function (name, operator, facetValue) {
- if (operator === this.default_operator) {
+ switch(operator){
+ case this.default_operator:
return [[name, '=', facetValue.get('value')]];
+ case 'child_of':
+ return [[name, 'child_of', facetValue.get('value')]];
}
return this._super(name, operator, facetValue);
},
diff --git a/addons/web/static/src/js/testing.js b/addons/web/static/src/js/testing.js
index 1f1c718ad5f..5e9483addc1 100644
--- a/addons/web/static/src/js/testing.js
+++ b/addons/web/static/src/js/testing.js
@@ -48,15 +48,6 @@ openerp.testing = {};
testing.dependencies = window['oe_all_dependencies'] || [];
testing.current_module = null;
- testing.templates = { };
- testing.add_template = function (name) {
- var xhr = QWeb2.Engine.prototype.get_xhr();
- xhr.open('GET', name, false);
- xhr.send(null);
- (testing.templates[testing.current_module] =
- testing.templates[testing.current_module] || [])
- .push(xhr.responseXML);
- };
/**
* Function which does not do anything
*/
@@ -206,7 +197,7 @@ openerp.testing = {};
teardown: testing.noop
});
- QUnit.module(testing.current_module + '.' + name, {_oe: options});
+ QUnit.module(name, {_oe: options});
body(testing['case']);
};
testing['case'] = function (name, options, callback) {
@@ -244,18 +235,6 @@ openerp.testing = {};
expect(opts.asserts);
}
- if (opts.templates) {
- for(var i=0; i<module_deps.length; ++i) {
- var dep = module_deps[i];
- var templates = testing.templates[dep];
- if (_.isEmpty(templates)) { continue; }
-
- for (var j=0; j < templates.length; ++j) {
- instance.web.qweb.add_template(templates[j]);
- }
- }
- }
-
var $fixture = $('#qunit-fixture');
var mock, async = false;
diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js
index 247fd2d2a1a..2c68a23dbf9 100644
--- a/addons/web/static/src/js/view_form.js
+++ b/addons/web/static/src/js/view_form.js
@@ -1940,7 +1940,7 @@ instance.web.form.WidgetButton = instance.web.form.FormWidget.extend({
init: function(field_manager, node) {
node.attrs.type = node.attrs['data-button-type'];
this.is_stat_button = /\boe_stat_button\b/.test(node.attrs['class']);
- this.icon = node.attrs.icon && "<span class=\"fa " + node.attrs.icon + " fa-fw\"></span>";
+ this.icon_class = node.attrs.icon && "stat_button_icon fa " + node.attrs.icon + " fa-fw";
this._super(field_manager, node);
this.force_disabled = false;
this.string = (this.node.attrs.string || '').replace(/_/g, '');
@@ -3356,13 +3356,16 @@ instance.web.form.CompletionFieldMixin = {
instance.web.form.M2ODialog = instance.web.Dialog.extend({
template: "M2ODialog",
init: function(parent) {
+ this.name = parent.string;
this._super(parent, {
- title: _.str.sprintf(_t("Add %s"), parent.string),
+ title: _.str.sprintf(_t("Create a %s"), parent.string),
size: 'medium',
});
},
start: function() {
var self = this;
+ var text = _.str.sprintf(_t("You are creating a new %s, are you sure it does not exist yet?"), self.name);
+ this.$("p").text( text );
this.$buttons.html(QWeb.render("M2ODialog.buttons"));
this.$("input").val(this.getParent().last_query);
this.$buttons.find(".oe_form_m2o_qc_button").click(function(){
@@ -3486,7 +3489,7 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc
self.display_value_backup = {};
self.render_value();
self.focus();
- self.view.do_onchange(self);
+ self.trigger('changed_value');
});
});
});
@@ -3621,6 +3624,8 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc
minLength: 0,
delay: 250
});
+ // set position for list of suggestions box
+ this.$input.autocomplete( "option", "position", { my : "left top", at: "left bottom" } );
this.$input.autocomplete("widget").openerpClass();
// used to correct a bug when selecting an element by pushing 'enter' in an editable list
this.$input.keyup(function(e) {