diff options
| author | Goffin Simon <simon.goffin@outlook.com> | 2015-02-16 11:04:42 +0100 |
|---|---|---|
| committer | Goffin Simon <sig@odoo.com> | 2015-02-19 12:15:16 +0100 |
| commit | 8e7c59f171c91485f193c78dbedde35a433bb03a (patch) | |
| tree | d2938d61254b04e150914c90ab5f67c5f2c044f8 /addons/website_version/static/src/js | |
| parent | 194d95cd475b7e34ba7057ebdfc682624adac07f (diff) | |
[IMP] website_version: ergonomic improvements of the modals.
Diffstat (limited to 'addons/website_version/static/src/js')
| -rw-r--r-- | addons/website_version/static/src/js/edit_version.js | 48 | ||||
| -rw-r--r-- | addons/website_version/static/src/js/menu_version.js | 47 |
2 files changed, 53 insertions, 42 deletions
diff --git a/addons/website_version/static/src/js/edit_version.js b/addons/website_version/static/src/js/edit_version.js index d5e49cf3ce9..f4efd964265 100644 --- a/addons/website_version/static/src/js/edit_version.js +++ b/addons/website_version/static/src/js/edit_version.js @@ -12,29 +12,33 @@ var self = this; this.$el.on('click', '#save_as_new_version', function() { - website.prompt({ - id: "editor_new_version", - window_title: _t("New version"), - input: "Version name" , - default :(moment().format('L')), - }).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(); + var wizardA = $(openerp.qweb.render("website_version.new_version",{'default_name': moment().format('L')})); + wizardA.appendTo($('body')).modal({"keyboard" :true}); + wizardA.on('click','.o_create', function(){ + wizardA.find('.o_message').remove(); + var version_name = wizardA.find('.o_version_name').val(); + if(version_name.length == 0){ + wizardA.find(".o_version_name").after("<p class='o_message' style='color : red'> *"+_t("This field is required")+"</p>"); + } + else{ + wizardA.modal("hide"); + openerp.jsonRpc( '/website_version/create_version', 'call', { 'name': version_name, 'version_id': 0}).then(function (result) { + $('html').data('version_id', result); + var wizard = $(openerp.qweb.render("website_version.dialogue",{message:_.str.sprintf("You are now working on version: %s.", version_name), + dialogue:_.str.sprintf("If you edit this page or others, all changes will be recorded in the version. It will not be visible by visitors until you publish the version.")})); + 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();}); }); - 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();}); - }); - + } }); + wizardA.on('hidden.bs.modal', function () {$(this).remove();}); }); this.$el.on('click', '#save_and_publish', function() { @@ -45,7 +49,7 @@ } else { - var wizard = $(openerp.qweb.render("website_version.delete_message",{message:_t("Are you sure you want to publish your modifications.")})); + var wizard = $(openerp.qweb.render("website_version.publish",{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(); diff --git a/addons/website_version/static/src/js/menu_version.js b/addons/website_version/static/src/js/menu_version.js index 2817f692c9b..9d30a393f58 100644 --- a/addons/website_version/static/src/js/menu_version.js +++ b/addons/website_version/static/src/js/menu_version.js @@ -41,27 +41,33 @@ duplicate_version: function(event) { var version_id = $('html').data('version_id'); - website.prompt({ - id: "editor_new_version", - window_title: _t("New version"), - input: "Version name" , - default :(moment().format('L')), - }).then(function (name) { - openerp.jsonRpc( '/website_version/create_version', 'call', { 'name': name, 'version_id': version_id}).then(function (result) { + var wizardA = $(openerp.qweb.render("website_version.new_version",{'default_name': moment().format('L')})); + wizardA.appendTo($('body')).modal({"keyboard" :true}); + wizardA.on('click','.o_create', function(){ + wizardA.find('.o_message').remove(); + var version_name = wizardA.find('.o_version_name').val(); + if(version_name.length == 0){ + wizardA.find(".o_version_name").after("<p class='o_message' style='color : red'> *"+_t("This field is required")+"</p>"); + } + else{ + wizardA.modal("hide"); + openerp.jsonRpc( '/website_version/create_version', 'call', { 'name': version_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'; + var wizard = $(openerp.qweb.render("website_version.dialogue",{message:_.str.sprintf("You are now working on version: %s.", version_name), + dialogue:_.str.sprintf("If you edit this page or others, all changes will be recorded in the version. It will not be visible by visitors until you publish the version.")})); + 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();}); }); - 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();}); - - }); + } }); + wizardA.on('hidden.bs.modal', function () {$(this).remove();}); }, change_version: function(event) { @@ -104,9 +110,10 @@ publish_version: function(event) { var version_id = parseInt($('html').data('version_id')); - var name = $(event.currentTarget).parent().parent().parent().children().children(':first-child').text(); + var name = $('#version-menu-button').attr('data-version_name'); 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})); + console.log(result); + var wizardA = $(openerp.qweb.render("website_version.publish_message",{message:_.str.sprintf("Publish Version %s", name), list:result})); wizardA.appendTo($('body')).modal({"keyboard" :true}); wizardA.on('click','.o_confirm', function(){ wizardA.find('.o_message').remove(); |
