summaryrefslogtreecommitdiff
path: root/addons/website_version/static/src/js/menu_version.js
diff options
context:
space:
mode:
authorGoffin Simon <simon.goffin@outlook.com>2015-02-16 11:04:42 +0100
committerGoffin Simon <sig@odoo.com>2015-02-19 12:15:16 +0100
commit8e7c59f171c91485f193c78dbedde35a433bb03a (patch)
treed2938d61254b04e150914c90ab5f67c5f2c044f8 /addons/website_version/static/src/js/menu_version.js
parent194d95cd475b7e34ba7057ebdfc682624adac07f (diff)
[IMP] website_version: ergonomic improvements of the modals.
Diffstat (limited to 'addons/website_version/static/src/js/menu_version.js')
-rw-r--r--addons/website_version/static/src/js/menu_version.js47
1 files changed, 27 insertions, 20 deletions
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();