Skip to content

Commit

Permalink
Merge pull request PrestaShop#5205 from cocoweb94/previewAndSave
Browse files Browse the repository at this point in the history
[-] BO :  click btn preview save product and redirect in window.open …
  • Loading branch information
julienbourdeau committed Mar 18, 2016
2 parents d917377 + 99d9370 commit 038b7d8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
16 changes: 12 additions & 4 deletions admin-dev/themes/default/js/bundle/product/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,11 @@ var warehouseCombinations = (function() {
var form = (function() {
var elem = $('#form');

function send(redirect) {
function send(redirect, target) {
// target value by default
if (typeof(target) == 'undefined') {
target = false;
}
var data = $('input, textarea, select', elem).not(':input[type=button], :input[type=submit], :input[type=reset]').serialize();
$.ajax({
type: 'POST',
Expand All @@ -1112,8 +1116,12 @@ var form = (function() {
$('*.has-danger').removeClass('has-danger');
},
success: function(response){
if(redirect){
window.location = redirect;
if (redirect) {
if (target) {
window.open(redirect, target);
} else {
window.location = redirect;
}
}
showSuccessMessage(translate_javascripts['Form update success']);
},
Expand Down Expand Up @@ -1198,7 +1206,7 @@ var form = (function() {

/** on save with duplicate|new */
$('.btn-submit', elem).click(function(){
send($(this).attr('data-redirect'));
send($(this).attr('data-redirect'), $(this).attr('target'));
});

/** on active field change, send form */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1007,13 +1007,13 @@
<i class="material-icons">delete</i>
</a>
<a
href="{{ preview_link }}"
data-redirect="{{ preview_link }}"
target="_blank"
class="btn btn-tertiary btn-lg hidden-xs"
class="btn btn-default btn-submit hidden-xs"
data-toggle="tooltip"
id="product_form_preview_btn"
title="{{ trans('View the product draft on the site.', {}, 'AdminProducts') }}"
>
>
{{ trans('Preview', {}, 'AdminProducts') }}
</a>

Expand Down

0 comments on commit 038b7d8

Please sign in to comment.