diff options
| author | Goffin Simon <simon.goffin@outlook.com> | 2014-12-16 13:40:23 +0100 |
|---|---|---|
| committer | Goffin Simon <simon.goffin@outlook.com> | 2015-01-07 18:17:13 +0100 |
| commit | 421a76dabb2e39116fbd93c0a3b7751f723ac8d6 (patch) | |
| tree | 32c419b21806cb182e948e01fc1281f5f4d60a59 /addons/website_version/static/src | |
| parent | e5ac65de59f45f2d15ae6f6b840b02cac78afd03 (diff) | |
[ADD] Versioning Module.
Diffstat (limited to 'addons/website_version/static/src')
38 files changed, 963 insertions, 0 deletions
diff --git a/addons/website_version/static/src/css/google_analytics.css b/addons/website_version/static/src/css/google_analytics.css new file mode 100644 index 00000000000..55697370e03 --- /dev/null +++ b/addons/website_version/static/src/css/google_analytics.css @@ -0,0 +1,7 @@ +@charset "utf-8"; + +img.analytics_img_tuto { + margin-left : 50px; + margin-bottom : 10px; + border: 2px solid grey; +}
\ No newline at end of file diff --git a/addons/website_version/static/src/css/menu_version.css b/addons/website_version/static/src/css/menu_version.css new file mode 100644 index 00000000000..79cf3616c98 --- /dev/null +++ b/addons/website_version/static/src/css/menu_version.css @@ -0,0 +1,16 @@ +.dropdown-menu .o_version > a:after { + margin-right: 10px; +} + +.navbar-inverse .btn-link.o_version:hover { + color: #000; + +} + +.btn.o_version { + text-align: left; +} + +.o_required_field{ + background-color: #d2d2ff; +}
\ No newline at end of file diff --git a/addons/website_version/static/src/img/Admin.png b/addons/website_version/static/src/img/Admin.png Binary files differnew file mode 100644 index 00000000000..eb905dec70f --- /dev/null +++ b/addons/website_version/static/src/img/Admin.png diff --git a/addons/website_version/static/src/img/GA/GA_Save.png b/addons/website_version/static/src/img/GA/GA_Save.png Binary files differnew file mode 100644 index 00000000000..1a3e8ff8231 --- /dev/null +++ b/addons/website_version/static/src/img/GA/GA_Save.png diff --git a/addons/website_version/static/src/img/GA/GA_admin.png b/addons/website_version/static/src/img/GA/GA_admin.png Binary files differnew file mode 100644 index 00000000000..63405513001 --- /dev/null +++ b/addons/website_version/static/src/img/GA/GA_admin.png diff --git a/addons/website_version/static/src/img/GA/GA_authorize.png b/addons/website_version/static/src/img/GA/GA_authorize.png Binary files differnew file mode 100644 index 00000000000..291ac68f7b2 --- /dev/null +++ b/addons/website_version/static/src/img/GA/GA_authorize.png diff --git a/addons/website_version/static/src/img/GA/GA_login.png b/addons/website_version/static/src/img/GA/GA_login.png Binary files differnew file mode 100644 index 00000000000..4df15e3821e --- /dev/null +++ b/addons/website_version/static/src/img/GA/GA_login.png diff --git a/addons/website_version/static/src/img/GA/GA_tracking_code.png b/addons/website_version/static/src/img/GA/GA_tracking_code.png Binary files differnew file mode 100644 index 00000000000..f54e68f0464 --- /dev/null +++ b/addons/website_version/static/src/img/GA/GA_tracking_code.png diff --git a/addons/website_version/static/src/img/GA/GA_tracking_id.png b/addons/website_version/static/src/img/GA/GA_tracking_id.png Binary files differnew file mode 100644 index 00000000000..6844b474787 --- /dev/null +++ b/addons/website_version/static/src/img/GA/GA_tracking_id.png diff --git a/addons/website_version/static/src/img/GA/GA_view_id.png b/addons/website_version/static/src/img/GA/GA_view_id.png Binary files differnew file mode 100644 index 00000000000..d3cdf05484e --- /dev/null +++ b/addons/website_version/static/src/img/GA/GA_view_id.png diff --git a/addons/website_version/static/src/img/GA/GA_view_settings.png b/addons/website_version/static/src/img/GA/GA_view_settings.png Binary files differnew file mode 100644 index 00000000000..78faeb64878 --- /dev/null +++ b/addons/website_version/static/src/img/GA/GA_view_settings.png diff --git a/addons/website_version/static/src/img/GC/GC_API.png b/addons/website_version/static/src/img/GC/GC_API.png Binary files differnew file mode 100644 index 00000000000..c882baf2494 --- /dev/null +++ b/addons/website_version/static/src/img/GC/GC_API.png diff --git a/addons/website_version/static/src/img/GC/GC_Apply.png b/addons/website_version/static/src/img/GC/GC_Apply.png Binary files differnew file mode 100644 index 00000000000..b868c0622e9 --- /dev/null +++ b/addons/website_version/static/src/img/GC/GC_Apply.png diff --git a/addons/website_version/static/src/img/GC/GC_Project.png b/addons/website_version/static/src/img/GC/GC_Project.png Binary files differnew file mode 100644 index 00000000000..eddafe80008 --- /dev/null +++ b/addons/website_version/static/src/img/GC/GC_Project.png diff --git a/addons/website_version/static/src/img/GC/GC_client_id.png b/addons/website_version/static/src/img/GC/GC_client_id.png Binary files differnew file mode 100644 index 00000000000..14c661ecab5 --- /dev/null +++ b/addons/website_version/static/src/img/GC/GC_client_id.png diff --git a/addons/website_version/static/src/img/GC/GC_copy.png b/addons/website_version/static/src/img/GC/GC_copy.png Binary files differnew file mode 100644 index 00000000000..40c2d812b0d --- /dev/null +++ b/addons/website_version/static/src/img/GC/GC_copy.png diff --git a/addons/website_version/static/src/img/GC/GC_create_new_client_id.png b/addons/website_version/static/src/img/GC/GC_create_new_client_id.png Binary files differnew file mode 100644 index 00000000000..e87deb78362 --- /dev/null +++ b/addons/website_version/static/src/img/GC/GC_create_new_client_id.png diff --git a/addons/website_version/static/src/img/GC/GC_create_project.png b/addons/website_version/static/src/img/GC/GC_create_project.png Binary files differnew file mode 100644 index 00000000000..1ec1ae0a64f --- /dev/null +++ b/addons/website_version/static/src/img/GC/GC_create_project.png diff --git a/addons/website_version/static/src/img/GC/GC_credentials.png b/addons/website_version/static/src/img/GC/GC_credentials.png Binary files differnew file mode 100644 index 00000000000..7e524335d4c --- /dev/null +++ b/addons/website_version/static/src/img/GC/GC_credentials.png diff --git a/addons/website_version/static/src/img/GC/GC_enable_api.png b/addons/website_version/static/src/img/GC/GC_enable_api.png Binary files differnew file mode 100644 index 00000000000..cd538cc98c9 --- /dev/null +++ b/addons/website_version/static/src/img/GC/GC_enable_api.png diff --git a/addons/website_version/static/src/img/GC/GC_new_project.png b/addons/website_version/static/src/img/GC/GC_new_project.png Binary files differnew file mode 100644 index 00000000000..20cc99edb88 --- /dev/null +++ b/addons/website_version/static/src/img/GC/GC_new_project.png diff --git a/addons/website_version/static/src/img/GC/GC_off_api.png b/addons/website_version/static/src/img/GC/GC_off_api.png Binary files differnew file mode 100644 index 00000000000..440ceb64076 --- /dev/null +++ b/addons/website_version/static/src/img/GC/GC_off_api.png diff --git a/addons/website_version/static/src/img/GC/GC_on_api.png b/addons/website_version/static/src/img/GC/GC_on_api.png Binary files differnew file mode 100644 index 00000000000..f9caa7fb1ad --- /dev/null +++ b/addons/website_version/static/src/img/GC/GC_on_api.png diff --git a/addons/website_version/static/src/img/Home.png b/addons/website_version/static/src/img/Home.png Binary files differnew file mode 100644 index 00000000000..18caa6e1358 --- /dev/null +++ b/addons/website_version/static/src/img/Home.png diff --git a/addons/website_version/static/src/img/Login.png b/addons/website_version/static/src/img/Login.png Binary files differnew file mode 100644 index 00000000000..fe921cb67da --- /dev/null +++ b/addons/website_version/static/src/img/Login.png diff --git a/addons/website_version/static/src/img/ODOO/ODOO_authorize.png b/addons/website_version/static/src/img/ODOO/ODOO_authorize.png Binary files differnew file mode 100644 index 00000000000..5850c0434b7 --- /dev/null +++ b/addons/website_version/static/src/img/ODOO/ODOO_authorize.png diff --git a/addons/website_version/static/src/img/ODOO/ODOO_client.png b/addons/website_version/static/src/img/ODOO/ODOO_client.png Binary files differnew file mode 100644 index 00000000000..46ed511edf4 --- /dev/null +++ b/addons/website_version/static/src/img/ODOO/ODOO_client.png diff --git a/addons/website_version/static/src/img/ODOO/ODOO_key.png b/addons/website_version/static/src/img/ODOO/ODOO_key.png Binary files differnew file mode 100644 index 00000000000..db966c0116a --- /dev/null +++ b/addons/website_version/static/src/img/ODOO/ODOO_key.png diff --git a/addons/website_version/static/src/img/ODOO/ODOO_login.png b/addons/website_version/static/src/img/ODOO/ODOO_login.png Binary files differnew file mode 100644 index 00000000000..4df15e3821e --- /dev/null +++ b/addons/website_version/static/src/img/ODOO/ODOO_login.png diff --git a/addons/website_version/static/src/img/Property.png b/addons/website_version/static/src/img/Property.png Binary files differnew file mode 100644 index 00000000000..447fcab84df --- /dev/null +++ b/addons/website_version/static/src/img/Property.png diff --git a/addons/website_version/static/src/img/Tracking_ID.png b/addons/website_version/static/src/img/Tracking_ID.png Binary files differnew file mode 100644 index 00000000000..4c136d2a3c5 --- /dev/null +++ b/addons/website_version/static/src/img/Tracking_ID.png diff --git a/addons/website_version/static/src/img/View.png b/addons/website_version/static/src/img/View.png Binary files differnew file mode 100644 index 00000000000..bdf19cea9a0 --- /dev/null +++ b/addons/website_version/static/src/img/View.png diff --git a/addons/website_version/static/src/img/View_ID.png b/addons/website_version/static/src/img/View_ID.png Binary files differnew file mode 100644 index 00000000000..b9352566a7f --- /dev/null +++ b/addons/website_version/static/src/img/View_ID.png diff --git a/addons/website_version/static/src/js/edit_version.js b/addons/website_version/static/src/js/edit_version.js new file mode 100644 index 00000000000..61f88816c8a --- /dev/null +++ b/addons/website_version/static/src/js/edit_version.js @@ -0,0 +1,82 @@ +(function() { + 'use strict'; + var hash = "#advanced-view-editor"; + var _t = openerp._t; + + var website=openerp.website; + + website.action= {}; + + website.EditorBar.include({ + start: function() { + var self = this; + var m_names = new Array("jan", "feb", "mar", + "apr", "may", "jun", "jul", "aug", "sep", + "oct", "nov", "dec"); + this.$el.on('click', '#save_as_new_version', function() { + var d = new Date(); + var curr_date = d.getDate(); + var curr_month = d.getMonth(); + var curr_year = d.getFullYear(); + + website.prompt({ + id: "editor_new_version", + window_title: _t("New version"), + input: "Version name" , + default :(curr_date + " " + m_names[curr_month] + " " + curr_year), + }).then(function (name) { + var context = website.get_context(); + openerp.jsonRpc( '/website_version/create_version', 'call', { 'name': name, 'version_id': 0 }).then(function (result) { + $('html').data('version_id', result); + + var wizard = $(openerp.qweb.render("website_version.message",{message:_.str.sprintf("You are actually working on %s version.", name)})); + wizard.appendTo($('body')).modal({"keyboard" :true}); + wizard.on('click','.o_confirm', function(){ + self.save(); + }); + wizard.on('hidden.bs.modal', function () {$(this).remove();}); + }).fail(function(){ + var wizard = $(openerp.qweb.render("website_version.message",{message:_t("This name already exists.")})); + wizard.appendTo($('body')).modal({"keyboard" :true}); + wizard.on('hidden.bs.modal', function () {$(this).remove();}); + }); + + }); + + }); + this.$el.on('click', '#save_and_publish', function() { + var version_id = $('html').data('version_id'); + if(version_id) + { + self.save(); + } + else + { + var wizard = $(openerp.qweb.render("website_version.delete_message",{message:_t("Are you sure you want to publish your modifications.")})); + wizard.appendTo($('body')).modal({"keyboard" :true}); + wizard.on('click','.o_confirm', function(){ + self.save(); + }); + wizard.on('hidden.bs.modal', function () {$(this).remove();}); + } + + }); + + $('.option_choice').click(function() { + self.$el.find(".o_second_choice").remove(); + var name = $('#version-menu-button').data('version_name'); + if(name){ + self.$el.find(".o_first_choice").before(openerp.qweb.render("all_options", {version:'Save on '+name})); + } + else{ + self.$el.find(".o_first_choice").before(openerp.qweb.render("all_options", {version:'Save and Publish'})); + } + + }); + + return this._super(); + } + }); + + +})();
\ No newline at end of file diff --git a/addons/website_version/static/src/js/menu_version.js b/addons/website_version/static/src/js/menu_version.js new file mode 100644 index 00000000000..1d0cbd585d7 --- /dev/null +++ b/addons/website_version/static/src/js/menu_version.js @@ -0,0 +1,287 @@ +(function() { + 'use strict'; + var _t = openerp._t; + + var website=openerp.website; + var QWeb = openerp.qweb; + website.add_template_file('/website_version/static/src/xml/version_templates.xml'); + + website.EditorVersion = openerp.Widget.extend({ + start: function() { + var self = this; + + $('html').data('version_id', this.$el.find("#version-menu-button").data("version_id")); + var _get_context = website.get_context; + website.get_context = function (dict) { + return _.extend({ 'version_id': $('html').data('version_id') }, _get_context(dict)); + }; + + self.$el.on('click', 'a[data-action]', function(ev) { + ev.preventDefault(); + self[$(this).data('action')](ev); + }); + + this.$el.find('#version-menu-button').click(function() { + var view_id = $('html').attr('data-view-xmlid'); + openerp.jsonRpc( '/website_version/all_versions', 'call', { 'view_id': view_id }).then(function (result) { + self.$el.find(".o_version_choice").remove(); + self.$el.find(".first_divider").before(QWeb.render("all_versions", {versions:result})); + + }); + openerp.jsonRpc( '/website_version/has_experiments', 'call', { 'view_id': view_id }).then(function (result) { + self.$el.find(".o_experiment").remove(); + if(result){ + self.$el.find(".create_experiment").after(QWeb.render("experiment_menu")); + } + }); + + }); + return this._super(); + }, + + duplicate_version: function(event) { + var version_id = $('html').data('version_id'); + if(!version_id){ + version_id = 0; + } + var m_names = new Array("jan", "feb", "mar", + "apr", "may", "jun", "jul", "aug", "sep", + "oct", "nov", "dec"); + var d = new Date(); + var curr_date = d.getDate(); + var curr_month = d.getMonth(); + var curr_year = d.getFullYear(); + website.prompt({ + id: "editor_new_version", + window_title: _t("New version"), + input: "Version name" , + default :(curr_date + " " + m_names[curr_month] + " " + curr_year), + }).then(function (name) { + openerp.jsonRpc( '/website_version/create_version', 'call', { 'name': name, 'version_id': version_id}).then(function (result) { + + var wizard = $(openerp.qweb.render("website_version.message",{message:_.str.sprintf("You are actually working on %s version.", name)})); + wizard.appendTo($('body')).modal({"keyboard" :true}); + wizard.on('click','.o_confirm', function(){ + window.location.href = '\?enable_editor'; + }); + wizard.on('hidden.bs.modal', function () {$(this).remove();}); + }).fail(function(){ + var wizard = $(openerp.qweb.render("website_version.message",{message:_t("This name already exists.")})); + wizard.appendTo($('body')).modal({"keyboard" :true}); + wizard.on('hidden.bs.modal', function () {$(this).remove();}); + + }); + }); + }, + + change_version: function(event) { + var version_id = $(event.target).parent().data("version_id"); + if(! version_id){ + version_id = 0;//By default master + } + openerp.jsonRpc( '/website_version/change_version', 'call', { 'version_id':version_id }).then(function (result) { + location.reload(); + }); + }, + + delete_version: function(event) { + var version_id = $(event.currentTarget).parent().data("version_id"); + var name = $(event.currentTarget).parent().children(':last-child').text(); + openerp.jsonRpc( '/website_version/check_version', 'call', { 'version_id':version_id }).then(function (result) { + if (result){ + var wizard = $(openerp.qweb.render("website_version.message",{message:_.str.sprintf("You cannot delete the %s version because it is in a running or paused experiment", name)})); + wizard.appendTo($('body')).modal({"keyboard" :true}); + wizard.on('hidden.bs.modal', function () {$(this).remove();}); + } + else{ + var wizardA = $(openerp.qweb.render("website_version.delete_message",{message:_.str.sprintf("Are you sure you want to delete the %s version ?", name)})); + wizardA.appendTo($('body')).modal({"keyboard" :true}); + wizardA.on('click','.o_confirm', function(){ + openerp.jsonRpc( '/website_version/delete_version', 'call', { 'version_id':version_id }).then(function (result) { + var wizardB = $(openerp.qweb.render("website_version.message",{message:_.str.sprintf("The %s version has been deleted.", result)})); + wizardB.appendTo($('body')).modal({"keyboard" :true}); + wizardB.on('click','.o_confirm', function(){ + location.reload(); + wizardB.on('hidden.bs.modal', function () {$(this).remove();}); + }); + }); + }); + wizardA.on('hidden.bs.modal', function () {$(this).remove();}); + } + }); + }, + + publish_version: function(event) { + var version_id = $('html').data('version_id'); + var name = $(event.currentTarget).parent().parent().parent().children().children(':first-child').text(); + openerp.jsonRpc( '/website_version/diff_version', 'call', { 'version_id':version_id}).then(function (result) { + var wizardA = $(openerp.qweb.render("website_version.publish_message",{message:_.str.sprintf("Are you sure you want to publish the %s version ?", name), list:result})); + wizardA.appendTo($('body')).modal({"keyboard" :true}); + wizardA.on('click','.o_confirm', function(){ + wizardA.find('.o_message').remove(); + var check = wizardA.find('.o_check').is(':checked'); + var copy_master_name = wizardA.find('.o_name').val(); + if(check){ + if(copy_master_name.length == 0){ + wizardA.find(".o_name").after("<p class='o_message' style='color : red'> *"+_t("This field is required")+"</p>"); + } + else{ + openerp.jsonRpc( '/website_version/publish_version', 'call', { 'version_id':version_id, 'save_master':true, 'copy_master_name':copy_master_name}).then(function (result) { + var wizardB = $(openerp.qweb.render("website_version.dialogue",{message:_.str.sprintf("The %s version has been published", result), dialogue:_.str.sprintf("The master has been saved on a new version called %s.",copy_master_name)})); + wizardB.appendTo($('body')).modal({"keyboard" :true}); + wizardB.on('click','.o_confirm', function(){ + location.reload(); + }); + wizardB.on('hidden.bs.modal', function () {$(this).remove();}); + }); + } + } + else{ + openerp.jsonRpc( '/website_version/publish_version', 'call', { 'version_id':version_id, 'save_master':false, 'copy_master_name':""}).then(function (result) { + var wizardC = $(openerp.qweb.render("website_version.message",{message:_.str.sprintf("The %s version has been published.", result)})); + wizardC.appendTo($('body')).modal({"keyboard" :true}); + wizardC.on('click','.o_confirm', function(){ + location.reload(); + }); + wizardC.on('hidden.bs.modal', function () {$(this).remove();}); + }); + } + }); + wizardA.on('click','input[name="optionsRadios"]', function(){ + wizardA.find('.o_message').remove(); + wizardA.find('.o_name').toggle( wizardA.find('.o_check').is(':checked') ); + }); + wizardA.on('hidden.bs.modal', function () {$(this).remove();}); + }); + }, + + diff_version: function(event) { + var version_id = $('html').data('version_id'); + var name = $('#version-menu-button').data('version_name'); + openerp.jsonRpc( '/website_version/diff_version', 'call', { 'version_id':version_id}).then(function (result) { + var wizard = $(openerp.qweb.render("website_version.diff",{list:result, version_name:name})); + wizard.appendTo($('body')).modal({"keyboard" :true}); + wizard.on('click','.o_confirm', function(){}); + wizard.on('hidden.bs.modal', function () {$(this).remove();}); + }); + }, + + google_analytics: function(event){ + window.location.href = 'https://www.google.com/analytics/web'; + + }, + + create_experiment: function() { + var self = this; + var view_id = $('html').attr('data-view-xmlid'); + openerp.jsonRpc( '/website_version/all_versions_all_goals', 'call', { 'view_id': view_id }).then(function (result) { + var wizardA = $(openerp.qweb.render("website_version.create_experiment",{versions:result.tab_version, goals:result.tab_goal, config:result.check_conf})); + wizardA.appendTo($('body')).modal({"keyboard" :true}); + + wizardA.on('click','.o_launch', function(){ + wizardA.find('.o_message').remove(); + var name = wizardA.find('.o_name').val(); + var tab = wizardA.find('.o_version'); + var result = []; + var i; + for (var i = 0; i < tab.length; i++){ + if ($(tab[i]).is(':checked')) { + result.push(parseInt($(tab[i]).attr('data-version_id'))); + } + } + var objectives = wizardA.find('.box').val(); + var check = true; + if (name.length == 0){ + wizardA.find(".o_name").after("<p class='o_message' style='color : red'> *"+_t("This field is required")+"</p>"); + check = false; + } + if (result.length == 0 && check){ + wizardA.find(".o_versions").after("<p class='o_message' style='color : red'> *"+_t("You must select at least one version which is not Master.")+"</p>"); + check = false; + } + if(check){ + openerp.jsonRpc( '/website_version/launch_experiment', 'call', { 'name':name, 'version_ids':result, 'objectives':objectives }).then(function (result) { + if (result[0]){ + var wizardB = $(openerp.qweb.render("website_version.dialogue",{message:_.str.sprintf("Your %s experiment is created.", name), dialogue:_t(" Now you can manage this experiment by clicking on Manage A/B tests.")})); + wizardB.appendTo($('body')).modal({"keyboard" :true}); + wizardB.on('click','.o_confirm', function(){ + location.reload(); + }); + wizardB.on('hidden.bs.modal', function () {$(this).remove();}); + + } + else{ + wizardA.find(".o_versions").after("<p class='o_message' style='color : red'> *"+_.str.sprintf("Your %s experiment cannot be launched because this experiment contains a view which is already used in the running %s experiment.", name, result[1])+"</p>"); + } + }); + } + }); + wizardA.on('click','.o_configure', function(){ + var website_id = $('html').attr('data-website-id'); + window.location.href ='/web#id='+website_id+'&view_type=form&model=website&action=website_version.action_website_view'; + }); + wizardA.on('click','.o_validate_0', function(){ + var website_id = $('html').attr('data-website-id'); + var ga_key = wizardA.find('.o_ga_key').val(); + var view_id = wizardA.find('.o_view_id').val(); + var client_id = wizardA.find('.o_client_id').val(); + var client_secret = wizardA.find('.o_client_secret').val(); + if(ga_key.length == 0 || view_id.length == 0 || client_id.length == 0 || client_secret.length == 0){ + wizardA.find(".o_configure_ab").after("<p class='o_message' style='color : red'> *"+_t("You must fill all the fields.")+"</p>"); + } + else{ + openerp.jsonRpc( '/website_version/set_google_access', 'call', {'ga_key':ga_key, 'view_id':view_id, 'client_id':client_id, 'client_secret':client_secret}).then(function (result) { + var context = website.get_context(); + openerp.jsonRpc( '/website_version/google_access', 'call', { + fromurl: window.location.href, + local_context: context + }).done(function(o) { + if (o.status === "need_auth") { + var wizardC = $(openerp.qweb.render("website_version.message",{message:_t("You will be redirected to Google to authorize access to your Analytics Account!")})); + wizardC.appendTo($('body')).modal({"keyboard" :true}); + wizardC.on('click','.o_confirm', function(){ + window.location.href = o.url; + }); + wizardC.on('hidden.bs.modal', function () {$(this).remove();}); + } + else if (o.status === "need_config_from_admin"){ + if (confirm(_t("The Google Management API key needs to be configured before you can use it, do you want to do it now?"))) { + window.location.href = o.action; + } + } + }).always(function(o) { $('button.GoogleAccess').prop('disabled', false); }); + }); + } + }); + wizardA.on('click','.o_validate_2', function(){ + var website_id = $('html').attr('data-website-id'); + var ga_key = wizardA.find('.o_ga_key').val(); + var view_id = wizardA.find('.o_view_id').val(); + if(ga_key.length == 0 || view_id.length == 0){ + wizardA.find(".o_configure_ab").after("<p class='o_message' style='color : red'> *"+_t("You must fill all the fields.")+"</p>"); + } + else{ + openerp.jsonRpc( '/website_version/set_google_access', 'call', {'ga_key':ga_key, 'view_id':view_id, 'client_id':0, 'client_secret':0}); + } + }); + wizardA.on('hidden.bs.modal', function () {$(this).remove();}); + }); + }, + + manage_experiment: function() { + window.location.href = '/web#return_label=Website&action=website_version.action_experiment'; + }, + + statistics: function() { + window.open('https://www.google.com/analytics/web/?authuser=0#report/siteopt-experiments/','_blank'); + } + + }); + + $(document).ready(function() { + var version = new website.EditorVersion(); + version.setElement($("#version-menu")); + version.start(); + }); + +})(); diff --git a/addons/website_version/static/src/js/website_version.tour.versioning.js b/addons/website_version/static/src/js/website_version.tour.versioning.js new file mode 100644 index 00000000000..0e9c7d18f61 --- /dev/null +++ b/addons/website_version/static/src/js/website_version.tour.versioning.js @@ -0,0 +1,212 @@ +(function () { + 'use strict'; + + var _t = openerp._t; + + openerp.Tour.register({ + id: 'versioning', + name: "Tutorial versioning", + path: '/', + mode: 'tutorial', + steps: [ + //1. + + { + title: _t("Welcome to the tutorial"), + content: _t("This tutorial will guide you to build a version of your home page."), + popover: { next: _t("Start Tutorial"), end: _t("Skip It") }, + }, + { + title: _t("Click on Version"), + content: _t("You can create a version for every page of your website."), + popover: { fixed: true }, + element: 'a[id="version-menu-button"]:contains("Version"):first', + }, + { + title: _t("Click on New version"), + popover: { fixed: true }, + element: 'a[data-action="duplicate_version"]:contains("New Version"):first', + }, + { + title: _t("Give a version name"), + content: _t("Give a clever name to retrieve it easily."), + popover: { fixed: true }, + waitFor: '.modal button[type="button"]:contains("Continue")', + element: '.modal input[type="text"]', + sampleText: 'Test', + }, + { + title: _t("Validate the version name"), + popover: { fixed: true }, + element: '.modal button[type="button"]:contains("Continue")', + }, + { + title: _t("Confirm"), + popover: { fixed: true }, + waitNot: '.modal button[type="button"]:contains("Continue")', + element: '.modal button[type="button"]:contains("Ok")', + }, + { + title: _t("You are on your new version"), + content: _t("All the modifications you will do, will be saved in this version."), + waitNot: '.modal button[type="button"]:contains("Ok")', + }, + { + title: _t("Click on Edit"), + content: _t("Every page of your website can be modified through the <i>Edit</i> button."), + waitFor: 'button[data-action="edit"]:contains("Edit")', + element: 'button[data-action="edit"]:contains("Edit")', + }, + { + element: 'button[data-action=snippet]', + placement: 'bottom', + title: _t("Insert building blocks"), + content: _t("Click here to insert blocks of content in the page."), + popover: { fixed: true }, + }, + { + snippet: '#snippet_structure .oe_snippet:first', + placement: 'bottom', + title: _t("Drag & Drop a Banner"), + content: _t("Drag the Banner block and drop it in your page."), + popover: { fixed: true }, + }, + { + waitFor: '.oe_overlay_options .oe_options:visible', + element: '#wrapwrap .carousel:first div.carousel-content', + placement: 'top', + title: _t("Customize banner's text"), + content: _t("Click in the text and start editing it."), + sampleText: 'Here, a customized text', + popover: { next: _t("Continue") }, + }, + { + waitNot: '#wrap .carousel:first div.carousel-content:has(h2:'+ + 'containsExact('+_t('Your Banner Title')+')):has(h3:'+ + 'containsExact('+_t('Click to customize this text')+'))', + element: '.oe_snippet_parent:visible', + placement: 'bottom', + title: _t("Get banner properties"), + content: _t("Select the parent container to get the global options of the banner."), + popover: { fixed: true }, + }, + { + element: '.oe_overlay_options .oe_options:visible', + placement: 'left', + title: _t("Customize the banner"), + content: _t("Customize any block through this menu. Try to change the background of the banner."), + popover: { next: _t("Continue") }, + }, + { + waitNot: '.popover.tour', + element: 'button[data-action=snippet]', + placement: 'bottom', + title: _t("Add Another Block"), + content: _t("Let's add another building block to your page."), + popover: { fixed: true }, + }, + { + snippet: '#snippet_structure .oe_snippet:eq(6)', + placement: 'bottom', + title: _t("Drag & Drop This Block"), + content: _t("Drag the <em>'Features'</em> block and drop it below the banner."), + popover: { fixed: true }, + }, + { + waitFor: '.oe_overlay_options .oe_options:visible', + element: 'button[data-action=save]', + placement: 'right', + title: _t("Save your modifications"), + content: _t("Publish your page by clicking on the <em>'Save'</em> button."), + popover: { fixed: true }, + }, + { + waitFor: 'button[data-action=save]:not(:visible)', + title: _t("Good Job!"), + content: _t("Well done, you created a version of your homepage."), + popover: { next: _t("Continue") }, + }, + + //2. + + { + title: _t("Publish the version"), + content: _t("Now we will publish your version in production."), + popover: { next: _t("Start Tutorial"), end: _t("Skip It") }, + }, + + { + title: _t("Click on Version"), + element: 'a[id="version-menu-button"]:contains("Version"):first', + popover: { fixed: true }, + }, + + { + title: _t("Click on Publish Version"), + element: 'a[data-action="publish_version"]:contains("Publish Version"):first', + popover: { fixed: true }, + }, + + { + title: _t("Click on Publish button"), + //waitFor: '.modal button[type="button"]:contains("Publish")', + element: '.modal button[type="button"]:contains("Publish")', + placement: 'left', + }, + + { + title: _t("Confirm"), + waitFor: '.modal button[type="button"]:contains("Ok")', + element: '.modal button[type="button"]:contains("Ok")', + popover: { fixed: true }, + }, + + + //3. + { + title: _t("Delete the version"), + content: _t("Now we will delete the version you have just published."), + waitNot: '.modal button[type="button"]:contains("Ok")', + popover: { next: _t("Start Tutorial"), end: _t("Skip It") }, + }, + + { + title: _t("Click on Version"), + element: 'a[id="version-menu-button"]:contains("Version"):first', + popover: { fixed: true }, + }, + + { + title: _t("Delete Version Test"), + element: 'li > a[data-action="delete_version"]:last', + popover: { fixed: true }, + }, + + { + title: _t("Click on delete version button"), + waitFor: '.modal button[type="button"]:contains("Delete Version")', + element: '.modal button[type="button"]:contains("Delete Version")', + popover: { fixed: true }, + }, + + { + title: _t("Confirm"), + waitFor: '.modal button[type="button"]:contains("Ok")', + element: '.modal button[type="button"]:contains("Ok")', + popover: { fixed: true }, + }, + + { + title: _t("Finish"), + content: _t("Felicitation, now you are able to edit and manage your versions."), + waitNot: '.modal button[type="button"]:contains("Ok")', + }, + + ] + }); + +}()); + + + + diff --git a/addons/website_version/static/src/js/widget.js b/addons/website_version/static/src/js/widget.js new file mode 100644 index 00000000000..350591ddb58 --- /dev/null +++ b/addons/website_version/static/src/js/widget.js @@ -0,0 +1,45 @@ +(function() { + "use strict"; + + var instance = openerp; + openerp.website_version = instance.website_version || {}; + + var module = instance.website_version; + var QWeb = instance.web.qweb; + var _t = openerp._t; + + + instance.website_version.rtoken = instance.web.form.AbstractField.extend({ + template: 'website_version.GoogleAccess', + start: function() { + var self = this; + this.$el.on('click', 'button.GoogleAccess', function() { + self.allow_google(); + }); + }, + allow_google: function() { + var self = this; + $('button.GoogleAccess').prop('disabled', true); + var context = instance.web.pyeval.eval('context'); + self.rpc('/website_version/google_access', { + fromurl: window.location.href, + local_context: context + }).done(function(o) { + if (o.status === "need_auth") { + alert(_t("You will be redirected to Google to authorize access to your Analytics Account!")); + instance.web.redirect(o.url); + } + else if (o.status === "need_config_from_admin"){ + if (confirm(_t("The Google Management API key needs to be configured before you can use it, do you want to do it now?"))) { + self.do_action(o.action); + } + } + }).always(function(o) { $('button.GoogleAccess').prop('disabled', false); }); + } + + }); + instance.web.form.widgets.add('rtoken', 'openerp.website_version.rtoken'); + + +})(); + diff --git a/addons/website_version/static/src/xml/version_templates.xml b/addons/website_version/static/src/xml/version_templates.xml new file mode 100644 index 00000000000..66c89b24ea3 --- /dev/null +++ b/addons/website_version/static/src/xml/version_templates.xml @@ -0,0 +1,314 @@ +<?xml version="1.0" encoding="UTF-8"?> +<templates id="template" xml:space="preserve"> + + <t t-name="all_versions"> + <t t-foreach="versions" t-as="item"> + <li class="o_version_choice" t-att-data-version_id="item.id"> + <a href="#" data-action="delete_version" style="position: absolute; right: 0px;" class="pull-right"><i class="fa fa-trash-o fa-fw"></i></a> + <t t-if="item.bold == 0 "> + <a href="#" data-action="change_version" t-att-data-version_id="item.id"><t t-esc="item.name"></t> </a> + </t> + <t t-if="item.bold == 1 "> + <a href="#" data-action="change_version" t-att-data-version_id="item.id"> <b><t t-esc="item.name"></t></b> </a> + </t> + </li> + </t> + </t> + + <t t-extend="website.editorbar"> + <t t-jquery=".navbar-header form button" t-operation="replace"> + <div class="btn-group"> + <button type="button" data-action="save" class="btn btn-primary btn-xs">Save</button> + <button type="button" class="btn btn-primary btn-xs dropdown-toggle option_choice" data-toggle="dropdown"> + <span class="caret"></span> + <span class="sr-only">Toggle Dropdown</span> + </button> + <ul class="dropdown-menu" role="menu"> + <li class="o_first_choice"><a href="#" id="save_as_new_version" data-action="save_as_new_version" + class="btn btn-link btn-xs o_version">Save as New Version</a> + </li> + </ul> + </div> + + </t> + </t> + + <t t-name="all_options"> + <li class="o_second_choice"> + <a href="#" id="save_and_publish" data-action="save_and_publish" + class="btn btn-link btn-xs o_version"><t t-esc="version"></t></a> + </li> + </t> + + <t t-name="experiment_menu"> + <li class="o_experiment"><a href="#" data-action="manage_experiment">Manage A/B tests</a></li> + <li class="o_experiment"><a href="#" data-action="statistics">Statistics</a></li> + </t> + + <t t-name="website_version.GoogleAccess"> + <div id="CheckGoogleAccess" class="odoo_google_token" > + <button class="GoogleAccess"> Authorize google </button> + </div> + </t> + + <t t-name="website_version.create_experiment"> + <div class="modal fade"> + <div class="modal-dialog"> + <div class="modal-content"> + <div class="modal-header"> + <h4 class="modal-title">Launch A/B tests</h4> + </div> + <div class="modal-body"> + <t t-if="versions.length != 0 and config == 1"> + <form id="productForm" class="form-horizontal" role="form"> + <div class="form-group form-group"> + <label class="col-sm-3 control-label">Experiment Name</label> + <div class="col-sm-8"> + <input type="text" class="form-control form-field-label o_name o_required_field"/> + </div> + + </div> + + <div class="form-group form-group"> + <label class="col-sm-3 control-label">Objective: </label> + <div class="col-sm-8 "> + <select class="form-control col-sm-2 box"> + <t t-foreach="goals" t-as="item"> + <option t-att-value="item.id"><t t-esc="item.name"></t></option> + </t> + </select> + </div> + </div> + + <div class="form-group form-group"> + <div class="col-sm-3"></div> + <div class="checkbox col-sm-8"> + <label> + <input type="checkbox" checked="checked" disabled="disabled"/> Master + </label> + </div> + </div> + + <div class="o_versions"> + <t t-foreach="versions" t-as="item"> + <div class="form-group form-group-lg"> + <div class="col-sm-3"></div> + <div class="checkbox col-sm-8"> + <label> + <input type="checkbox" class="o_version" t-att-data-version_id="item.id"/> <t t-esc="item.name"></t> + </label> + </div> + </div> + </t> + </div> + </form> + </t> + <t t-if="versions.length == 0 and config == 1"> + <div> + <p>You must have at least one version for this page to create a new experiment.</p> + </div> + </t> + + <t t-if= "config == 0"> + <form id="productForm" class="form-horizontal" role="form"> + <div class="form-group form-group"> + <label class="col-sm-3 control-label">GA Key</label> + <div class="col-sm-8"> + <input type="text" class="form-control form-field-label o_ga_key o_required_field"/> + </div> + </div> + <div class="form-group form-group"> + <label class="col-sm-3 control-label">View ID</label> + <div class="col-sm-8"> + <input type="text" class="form-control form-field-label o_view_id o_required_field"/> + </div> + </div> + <div class="form-group form-group"> + <label class="col-sm-3 control-label">Client ID</label> + <div class="col-sm-8"> + <input type="text" class="form-control form-field-label o_client_id o_required_field"/> + </div> + </div> + <div class="form-group form-group"> + <label class="col-sm-3 control-label">Client Secret</label> + <div class="col-sm-8"> + <input type="text" class="form-control form-field-label o_client_secret o_required_field"/> + </div> + </div> + </form> + <div class="o_configure_ab"> + <p>You must configure your account.</p> + <p>To configure your account, you must have a google analytics account.</p> + </div> + </t> + + <t t-if= "config == 2"> + <form id="productForm" class="form-horizontal" role="form"> + <div class="form-group form-group"> + <label class="col-sm-3 control-label">GA Key</label> + <div class="col-sm-8"> + <input type="text" class="form-control form-field-label o_ga_key o_required_field"/> + </div> + </div> + <div class="form-group form-group"> + <label class="col-sm-3 control-label">View ID</label> + <div class="col-sm-8"> + <input type="text" class="form-control form-field-label o_view_id o_required_field"/> + </div> + </div> + </form> + <div class="o_configure_ab"> + <p>You must configure your account.</p> + <p>To configure your account, you must have a google analytics account.</p> + </div> + </t> + + </div> + <div class="modal-footer"> + <t t-if="versions.length != 0 and config == 1"> + <div class="btn-group"> + <button type="button" class="btn btn-primary o_launch">Launch</button> + </div> + </t> + <t t-if= "config == 0 or config == 2"> + <div class="btn-group"> + <t t-if= "config == 0"> + <button type="button" class="btn btn-primary o_validate_0">Validate</button> + </t> + <t t-if= "config == 2"> + <button type="button" class="btn btn-primary o_validate_2" data-dismiss="modal">Validate</button> + </t> + <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown"> + <span class="caret"></span> + <span class="sr-only">Toggle Dropdown</span> + </button> + <ul class="dropdown-menu" role="menu"> + <li><a href="#" class="btn btn-link btn-xs o_configure">Configure</a></li> + </ul> + </div> + </t> + <a href="#" class="btn btn-link btn-xs" data-dismiss="modal">Cancel</a> + </div> + </div><!-- /.modal-content --> + </div><!-- /.modal-dialog --> + </div><!-- /.modal --> + </t> + <t t-name="website_version.message"> + <div class="modal fade"> + <div class="modal-dialog"> + <div class="modal-content"> + <div class="modal-header"> + <h4 class="modal-title"><t t-esc="message"></t></h4> + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-primary o_confirm" data-dismiss="modal">Ok</button> + </div> + </div><!-- /.modal-content --> + </div><!-- /.modal-dialog --> + </div><!-- /.modal --> + </t> + <t t-name="website_version.dialogue"> + <div class="modal fade"> + <div class="modal-dialog"> + <div class="modal-content"> + <div class="modal-header"> + <h4 class="modal-title"><t t-esc="message"></t></h4> + </div> + <div class="modal-body"> + <p><t t-esc="dialogue"></t></p> + </div> + + <div class="modal-footer"> + <button type="button" class="btn btn-primary o_confirm" data-dismiss="modal">Ok</button> + </div> + </div><!-- /.modal-content --> + </div><!-- /.modal-dialog --> + </div><!-- /.modal --> + </t> + <t t-name="website_version.diff"> + <div class="modal fade"> + <div class="modal-dialog"> + <div class="modal-content"> + <div class="modal-header"> + <h4 class="modal-title">Diff between Master and <t t-esc="version_name"></t></h4> + </div> + <div class="modal-body"> + <t t-if="list.length != 0"> + <ul> + <t t-foreach="list" t-as="item"> + <li><t t-esc="item"></t> </li> + </t> + </ul> + </t> + <t t-if="list.length == 0"> + <p>There is no difference with Master</p> + </t> + </div> + + <div class="modal-footer"> + <button type="button" class="btn btn-primary o_confirm" data-dismiss="modal">Ok</button> + </div> + </div><!-- /.modal-content --> + </div><!-- /.modal-dialog --> + </div><!-- /.modal --> + </t> + <t t-name="website_version.delete_message"> + <div class="modal fade"> + <div class="modal-dialog"> + <div class="modal-content"> + <div class="modal-header"> + <h4 class="modal-title"><t t-esc="message"></t></h4> + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-primary o_confirm" data-dismiss="modal">Delete Version</button> + <a href="#" class="btn btn-link btn-xs cancel" data-dismiss="modal">Cancel</a> + </div> + </div><!-- /.modal-content --> + </div><!-- /.modal-dialog --> + </div><!-- /.modal --> + </t> + <t t-name="website_version.publish_message"> + <div class="modal fade"> + <div class="modal-dialog"> + <div class="modal-content"> + <div class="modal-header"> + <h4 class="modal-title"><t t-esc="message"></t></h4> + </div> + <div class="modal-body"> + <p>When you publish a version, you erase some views in master. If you want to save the views that will be erased, you can save these views in a new version. Here is the list of master views which will be erased:</p> + <t t-if="list.length != 0"> + <ul> + <t t-foreach="list" t-as="item"> + <li><t t-esc="item"></t> </li> + </t> + </ul> + </t> + <t t-if="list.length == 0"> + <p>There is no difference with Master</p> + </t> + <form id="productForm" class="form-horizontal" role="form"> + + <div class="radio"> + <label> + <input type="radio" name="optionsRadios" id="optionsRadios1" value="option1" checked="checked"/> + Don't save Master + </label> + </div> + <div class="radio"> + <label> + <input type="radio" name="optionsRadios" id="optionsRadios2" value="option2" class="o_check"/> + Save Master + <input type="text" class="form-control o_name o_required_field" style="display: none;"/> + </label> + </div> + </form> + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-primary o_confirm">Publish</button> + <a href="#" class="btn btn-link btn-xs" data-dismiss="modal">Cancel</a> + </div> + </div><!-- /.modal-content --> + </div><!-- /.modal-dialog --> + </div><!-- /.modal --> + </t> +</templates>
\ No newline at end of file |
