summaryrefslogtreecommitdiff
path: root/addons/website/static/src/js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/website/static/src/js')
-rw-r--r--addons/website/static/src/js/backend/dashboard.js21
-rw-r--r--addons/website/static/src/js/content/website_root.js18
-rw-r--r--addons/website/static/src/js/menu/content.js13
3 files changed, 49 insertions, 3 deletions
diff --git a/addons/website/static/src/js/backend/dashboard.js b/addons/website/static/src/js/backend/dashboard.js
index 9ece194ab1e..393709b91db 100644
--- a/addons/website/static/src/js/backend/dashboard.js
+++ b/addons/website/static/src/js/backend/dashboard.js
@@ -64,6 +64,7 @@ var Dashboard = AbstractAction.extend(ControlPanelMixin, {
return this._rpc({
route: '/website/fetch_dashboard_data',
params: {
+ website_id: this.website_id || false,
date_from: this.date_from.year()+'-'+(this.date_from.month()+1)+'-'+this.date_from.date(),
date_to: this.date_to.year()+'-'+(this.date_to.month()+1)+'-'+this.date_to.date(),
},
@@ -72,6 +73,7 @@ var Dashboard = AbstractAction.extend(ControlPanelMixin, {
self.dashboards_data = result.dashboards;
self.currency_id = result.currency_id;
self.groups = result.groups;
+ self.websites = result.websites;
});
},
@@ -245,6 +247,16 @@ var Dashboard = AbstractAction.extend(ControlPanelMixin, {
},
+ on_website_button: function(website_id) {
+ var self = this;
+ this.website_id = website_id;
+ $.when(this.fetch_data()).then(function() {
+ self.$('.o_website_dashboard').empty();
+ self.render_dashboards();
+ self.render_graphs();
+ });
+ },
+
on_reverse_breadcrumb: function() {
var self = this;
web_client.do_push_state({});
@@ -293,10 +305,15 @@ var Dashboard = AbstractAction.extend(ControlPanelMixin, {
this.$searchview = $(QWeb.render("website.DateRangeButtons", {
widget: this,
}));
- this.$searchview.click('button.js_date_range', function(ev) {
+ this.$searchview.find('button.js_date_range').click(function(ev) {
+ self.$searchview.find('button.js_date_range.active').removeClass('active');
+ $(ev.target).addClass('active');
self.on_date_range_button($(ev.target).data('date'));
- $(this).find('button.js_date_range.active').removeClass('active');
+ });
+ this.$searchview.find('button.js_website').click(function(ev) {
+ self.$searchview.find('button.js_website.active').removeClass('active');
$(ev.target).addClass('active');
+ self.on_website_button($(ev.target).data('website-id'));
});
}
this.update_control_panel({
diff --git a/addons/website/static/src/js/content/website_root.js b/addons/website/static/src/js/content/website_root.js
index 29163838f7a..162bd42c07b 100644
--- a/addons/website/static/src/js/content/website_root.js
+++ b/addons/website/static/src/js/content/website_root.js
@@ -40,6 +40,7 @@ var WebsiteRoot = BodyManager.extend({
'click .js_publish_management .js_publish_btn': '_onPublishBtnClick',
'submit .js_website_submit_form': '_onWebsiteFormSubmit',
'click .js_disable_on_click': '_onDisableOnClick',
+ 'click .js_multi_website_switch': '_multiWebsiteSwitch',
}),
custom_events: _.extend({}, BodyManager.prototype.custom_events || {}, {
animation_start_demand: '_onAnimationStartDemand',
@@ -279,6 +280,23 @@ var WebsiteRoot = BodyManager.extend({
_onDisableOnClick: function (ev) {
$(ev.currentTarget).addClass('disabled');
},
+
+ /**
+ * Called when clicking on the multi-website switcher.
+ *
+ * @param {OdooEvent} ev
+ */
+ _multiWebsiteSwitch: function (ev) {
+ var website_id_to_switch_to = ev.target.getAttribute('website-id');
+ this._rpc({
+ route: '/website/set_session_website',
+ params: {
+ website_id: website_id_to_switch_to || false,
+ },
+ }).then(function () {
+ window.location.reload(true);
+ });
+ },
});
return {
diff --git a/addons/website/static/src/js/menu/content.js b/addons/website/static/src/js/menu/content.js
index 66679b5d20d..df4a2d0fe0d 100644
--- a/addons/website/static/src/js/menu/content.js
+++ b/addons/website/static/src/js/menu/content.js
@@ -145,6 +145,16 @@ var PagePropertiesDialog = weWidgets.Dialog.extend({
});
}));
+ defs.push(this._rpc({model: 'res.users',
+ method: 'has_group',
+ args: ['website.group_multi_website'],
+ context: context})
+ .then(function (has_group) {
+ if (!has_group) {
+ self.$('#website_restriction').addClass('hidden');
+ }
+ }));
+
var datepickersOptions = {
minDate: moment({y: 1900}),
maxDate: moment().add(200, 'y'),
@@ -210,6 +220,7 @@ var PagePropertiesDialog = weWidgets.Dialog.extend({
is_menu: this.$('#is_menu').prop('checked'),
is_homepage: this.$('#is_homepage').prop('checked'),
website_published: this.$('#is_published').prop('checked'),
+ restrict_to_current_website: this.$('#restrict_to_current_website').prop('checked'),
create_redirect: this.$('#create_redirect').prop('checked'),
redirect_type: this.$('#redirect_type').val(),
website_indexed: this.$('#is_indexed').prop('checked'),
@@ -954,7 +965,7 @@ function _deletePage(pageId, fromPageManagement) {
// Delete the page if the user confirmed
return self._rpc({
model: 'website.page',
- method: 'delete_page',
+ method: 'unlink',
args: [pageId],
context: context,
});