summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js
diff options
context:
space:
mode:
authorVidhin Mehta (OpenERP) <vme@tinyerp.com>2012-07-03 19:19:40 +0530
committerVidhin Mehta (OpenERP) <vme@tinyerp.com>2012-07-03 19:19:40 +0530
commitd86457a270afeb4ee2e5f7cfb906c73639fa54f2 (patch)
tree546b5fb24c38652a34728aa89bb6f27001ea9df6 /addons/web/static/src/js
parentc6ffd20a31c1413adb71716c952f36d74e15533c (diff)
parent50413828c552636b596b1b572addc68fae5c261c (diff)
[merge]main branch.
bzr revid: vme@tinyerp.com-20120703134940-27u7n3k8lp43hzep
Diffstat (limited to 'addons/web/static/src/js')
-rw-r--r--addons/web/static/src/js/chrome.js78
-rw-r--r--addons/web/static/src/js/coresetup.js32
-rw-r--r--addons/web/static/src/js/search.js5
-rw-r--r--addons/web/static/src/js/view_form.js40
-rw-r--r--addons/web/static/src/js/view_list.js2
-rw-r--r--addons/web/static/src/js/views.js2
6 files changed, 108 insertions, 51 deletions
diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js
index cab59c50ae7..b87ebe56856 100644
--- a/addons/web/static/src/js/chrome.js
+++ b/addons/web/static/src/js/chrome.js
@@ -136,14 +136,18 @@ instance.web.Dialog = instance.web.Widget.extend({
},
on_close: function() {
if (this.dialog_options.destroy_on_close) {
- this.$element.dialog('destroy');
+ this.destroy();
}
},
on_resized: function() {
},
destroy: function () {
- this.close();
- this.$element.dialog('destroy');
+ _.each(this.getChildren(), function(el) {
+ el.destroy();
+ });
+ if (! this.isDestroyed()) {
+ this.$element.dialog('destroy');
+ }
this._super();
}
});
@@ -579,6 +583,7 @@ instance.web.Menu = instance.web.Widget.extend({
start: function() {
this._super.apply(this, arguments);
this.$secondary_menus = this.getParent().$element.find('.oe_secondary_menus_container');
+ this.$secondary_menus.on('click', 'a[data-menu]', this.on_menu_click);
return this.do_reload();
},
do_reload: function() {
@@ -591,7 +596,6 @@ instance.web.Menu = instance.web.Widget.extend({
this.limit_entries();
this.$secondary_menus.html(QWeb.render("Menu.secondary", { widget : this }));
this.$element.on('click', 'a[data-menu]', this.on_menu_click);
- this.$secondary_menus.on('click', 'a[data-menu]', this.on_menu_click);
// Hide second level submenus
this.$secondary_menus.find('.oe_menu_toggler').siblings('.oe_secondary_submenu').hide();
if (self.current_menu) {
@@ -673,32 +677,37 @@ instance.web.Menu = instance.web.Widget.extend({
* Process a click on a menu item
*
* @param {Number} id the menu_id
+ * @param {Boolean} [needaction=false] whether the triggered action should execute in a `needs action` context
*/
- menu_click: function(id) {
- if (id) {
- // find back the menuitem in dom to get the action
- var $item = this.$element.find('a[data-menu=' + id + ']');
- if (!$item.length) {
- $item = this.$secondary_menus.find('a[data-menu=' + id + ']');
- }
- var action_id = $item.data('action-id');
- // If first level menu doesnt have action trigger first leaf
- if (!action_id) {
- if(this.$element.has($item).length) {
- $sub_menu = this.$secondary_menus.find('.oe_secondary_menu[data-menu-parent=' + id + ']');
- $items = $sub_menu.find('a[data-action-id]').filter('[data-action-id!=""]');
- if($items.length) {
- action_id = $items.data('action-id');
- id = $items.data('menu');
- }
+ menu_click: function(id, needaction) {
+ if (!id) { return; }
+
+ // find back the menuitem in dom to get the action
+ var $item = this.$element.find('a[data-menu=' + id + ']');
+ if (!$item.length) {
+ $item = this.$secondary_menus.find('a[data-menu=' + id + ']');
+ }
+ var action_id = $item.data('action-id');
+ // If first level menu doesnt have action trigger first leaf
+ if (!action_id) {
+ if(this.$element.has($item).length) {
+ var $sub_menu = this.$secondary_menus.find('.oe_secondary_menu[data-menu-parent=' + id + ']');
+ var $items = $sub_menu.find('a[data-action-id]').filter('[data-action-id!=""]');
+ if($items.length) {
+ action_id = $items.data('action-id');
+ id = $items.data('menu');
}
}
- this.open_menu(id);
- this.current_menu = id;
- this.session.active_id = id;
- if (action_id) {
- this.trigger('menu_click', action_id, id, $item);
- }
+ }
+ this.open_menu(id);
+ this.current_menu = id;
+ this.session.active_id = id;
+ if (action_id) {
+ this.trigger('menu_click', {
+ action_id: action_id,
+ needaction: needaction,
+ id: id
+ }, $item);
}
},
/**
@@ -708,7 +717,8 @@ instance.web.Menu = instance.web.Widget.extend({
*/
on_menu_click: function(ev) {
ev.preventDefault();
- this.menu_click($(ev.currentTarget).data('menu'));
+ var needaction = $(ev.target).is('div.oe_menu_counter');
+ this.menu_click($(ev.currentTarget).data('menu'), needaction);
},
});
@@ -1018,8 +1028,16 @@ instance.web.WebClient = instance.web.Widget.extend({
this._current_state = _.clone(state);
$.bbq.pushState(url);
},
- on_menu_action: function(action) {
- this.action_manager.do_action(action);
+ on_menu_action: function(options) {
+ var self = this;
+ this.rpc("/web/action/load", { action_id: options.action_id })
+ .then(function (result) {
+ var action = result.result;
+ if (options.needaction) {
+ action.context.search_default_needaction_pending = true;
+ }
+ self.action_manager.do_action(action);
+ });
},
do_action: function(action) {
var self = this;
diff --git a/addons/web/static/src/js/coresetup.js b/addons/web/static/src/js/coresetup.js
index ee421bee092..a00ca4002e5 100644
--- a/addons/web/static/src/js/coresetup.js
+++ b/addons/web/static/src/js/coresetup.js
@@ -608,15 +608,31 @@ instance.web.qweb.preprocess_node = function() {
};
/** Setup jQuery timeago */
-var timeago_setup = function () {
- var s = $.timeago.settings.strings;
- _.each(s, function(v,k) {
- if(_.isString(v)) {
- s[k] = instance.web._t(v);
- }
- });
+var _t = instance.web._t;
+/*
+ * Strings in timeago are "composed" with prefixes, words and suffixes. This
+ * makes their detection by our translating system impossible. Use all literal
+ * strings we're using with a translation mark here so the extractor can do its
+ * job.
+ */
+{
+ _t('less than a minute ago');
+ _t('about a minute ago');
+ _t('%d minutes ago');
+ _t('about an hour ago');
+ _t('%d hours ago');
+ _t('a day ago');
+ _t('%d days ago');
+ _t('about a month ago');
+ _t('%d months ago');
+ _t('about a year ago');
+ _t('%d years ago');
}
-instance.connection.on('module_loaded', this, timeago_setup);
+
+instance.connection.on('module_loaded', this, function () {
+ // provide timeago.js with our own translator method
+ $.timeago.settings.translator = instance.web._t;
+});
/**
* Registry for all the client actions key: tag value: widget
diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js
index 2e332ed8b28..c8b6f797dba 100644
--- a/addons/web/static/src/js/search.js
+++ b/addons/web/static/src/js/search.js
@@ -352,6 +352,11 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
e.stopImmediatePropagation();
self.$element.toggleClass('oe_searchview_open_drawer');
});
+ instance.web.bus.on('click', this, function(ev) {
+ if ($(ev.target).parents('.oe_searchview').length === 0) {
+ self.$element.removeClass('oe_searchview_open_drawer');
+ }
+ });
// Focus last input if the view itself is clicked (empty section of
// facets element)
this.$element.on('click', function (e) {
diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js
index 8bc2a3894c8..d40a1760e81 100644
--- a/addons/web/static/src/js/view_form.js
+++ b/addons/web/static/src/js/view_form.js
@@ -2891,25 +2891,36 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({
view.embedded_view = self.field.views[mode];
}
if(view.view_type === "list") {
- view.options.selectable = self.multi_selection;
- view.options.sortable = false;
+ _.extend(view.options, {
+ selectable: self.multi_selection,
+ sortable: false,
+ import_enabled: false,
+ });
if (self.get("effective_readonly")) {
- view.options.addable = null;
- view.options.deletable = null;
- view.options.reorderable = false;
+ _.extend(view.options, {
+ addable: null,
+ deletable: null,
+ reorderable: false,
+ });
}
} else if (view.view_type === "form") {
if (self.get("effective_readonly")) {
view.view_type = 'form';
}
- view.options.not_interactible_on_create = true;
+ _.extend(view.options, {
+ not_interactible_on_create: true,
+ });
} else if (view.view_type === "kanban") {
- view.options.confirm_on_delete = false;
+ _.extend(view.options, {
+ confirm_on_delete: false,
+ });
if (self.get("effective_readonly")) {
- view.options.action_buttons = false;
- view.options.quick_creatable = false;
- view.options.creatable = false;
- view.options.read_only_mode = true;
+ _.extend(view.options, {
+ action_buttons: false,
+ quick_creatable: false,
+ creatable: false,
+ read_only_mode: true,
+ });
}
}
views.push(view);
@@ -3519,6 +3530,7 @@ instance.web.form.FieldMany2Many = instance.web.form.AbstractField.extend({
'selectable': self.multi_selection,
'sortable': false,
'reorderable': false,
+ 'import_enabled': false,
});
var embedded = (this.field.views || {}).tree;
if (embedded) {
@@ -3999,6 +4011,7 @@ instance.web.form.SelectCreatePopup = instance.web.form.AbstractFormPopup.extend
_.extend({'deletable': false,
'selectable': !self.options.disable_multiple_selection,
'read_only': true,
+ 'import_enabled': false,
}, self.options.list_view_options || {}));
self.view_list.popup = self;
self.view_list.appendTo($(".oe_popup_list", self.$element)).pipe(function() {
@@ -4359,10 +4372,13 @@ instance.web.form.FieldBinaryImage = instance.web.form.FieldBinary.extend({
});
instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({
- tagName: "span",
+ template: "FieldStatus",
start: function() {
this._super();
this.selected_value = null;
+ if (this.$element.parent().is('header')) {
+ this.$element.after('<div class="oe_clear"/>');
+ }
// preview in start only for selection fields, because of the dynamic behavior of many2one fields.
if (this.field.type in ['selection']) {
this.render_list();
diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js
index 97fccd343f1..b19e483bed9 100644
--- a/addons/web/static/src/js/view_list.js
+++ b/addons/web/static/src/js/view_list.js
@@ -24,6 +24,8 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
// if true, the view can't be editable, ignoring the view's and the context's
// instructions
'read_only': false,
+ // if true, the 'Import', 'Export', etc... buttons will be shown
+ 'import_enabled': true,
},
/**
* Core class for list-type displays.
diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js
index a364b9e0669..98df8a0af0d 100644
--- a/addons/web/static/src/js/views.js
+++ b/addons/web/static/src/js/views.js
@@ -144,7 +144,7 @@ instance.web.ActionManager = instance.web.Widget.extend({
this.dialog_viewmanager.destroy();
}
this.dialog.dialog_title = action.name;
- this.dialog_viewmanager = new instance.web.ViewManagerAction(this, action);
+ this.dialog_viewmanager = new instance.web.ViewManagerAction(this.dialog, action);
this.dialog_viewmanager.appendTo(this.dialog.$element);
this.dialog_viewmanager.$element.addClass("oe_view_manager_" + action.target);
this.dialog.open();