MT#5879 Fix double encoded template string for saving, adapted deletion confirmation to ajax loaded listing

ipeshinskaya/InvoiceTemplate5
Irina Peshinskaya 11 years ago committed by Victor Seva
parent bc0ce4bee0
commit 4cdaa3199b

@ -916,6 +916,7 @@ sub invoice_template :Chained('invoice_data') :PathPart('template') :Args {
(undef,undef,@$in{qw/tt_type tt_viewmode tt_sourcestate tt_output_type tt_id/}) = @_ ;
$in->{contract_id} = $c->stash->{contract}->id;
$in->{tt_string} = $c->request->body_parameters->{template} || '';
foreach(qw/name is_active/){$in->{$_} = $c->request->parameters->{$_};}
#output
$out={};

@ -69,10 +69,12 @@ var uriForAction = function( data, type ){
q_template=q_template.replace(key,data[key]);
});
q_template=q_template.replace(/\/+$/,'');
q_template=q_template+'?'+$('form[name=invoice_template]').serialize();
//alert('q_template='+q_template);
return q_template;
}
function setSvgStringToEditor( svgParsedString ){
alert('setSvgStringToEditor: '+svgParsedString);
//alert('setSvgStringToEditor: '+svgParsedString);
svgCanvasEmbed.setSvgString( svgParsedString )(
function(data,error){
if(error){
@ -84,7 +86,7 @@ function setSvgStringToEditor( svgParsedString ){
}
function setSvgStringToPreview( svgParsedString, q, data ) {
var previewIframe = document.getElementById('svgpreview');
alert('setSvgStringToPreview: svgParsedString='+svgParsedString+';');
//alert('setSvgStringToPreview: svgParsedString='+svgParsedString+';');
if ($.browser.msie) {
//we need to repeat query to server for msie if we don't want send template string via GET method
if(!q){
@ -101,7 +103,7 @@ function setSvgStringToPreview( svgParsedString, q, data ) {
}
function fetchSvgToEditor( data ) {
var q = uriForAction( data, 'invoice_template' );
alert('fetchSvgToEditor: q='+q+';');
//alert('fetchSvgToEditor: q='+q+';');
$.ajax({
url: q,
}).done( function ( httpResponse ){
@ -122,7 +124,7 @@ function fetchInvoiceTemplateData( data ){
//tt_output_type=svg really outputs text/html mimetype. But it will be couple of <svg> tags (<svg> per page).
data.tt_output_type = 'json';
var q = uriForAction( data, 'invoice_template' );
alert('fetchInvoiceTemplateData: q='+q+';');
//alert('fetchInvoiceTemplateData: q='+q+';');
$.ajax({
url: q,
datatype: "json",
@ -137,13 +139,6 @@ function fetchInvoiceTemplateData( data ){
$('form[name=invoice_template]').loadJSON(templatedata.aaData.form);
}
}
//can use some plugin for jquery like populate for more complex forms
/*
$.each(templatedata.aaData.form, function( key, value ){
var field = $('form[name=invoice_template] input[name='+key+']');
field.val(value);
});
*/
});
}
function savePreviewedAndShowParsed( data ){
@ -165,8 +160,8 @@ function saveTemplate( data ) {
var svgString = getSvgString();
data.tt_sourcestate='saved';
var q = uriForAction( data, 'invoice_template_saved' );
alert('saveTemplate: q='+q+';');
$.post( q, { template: encodeURIComponent( svgString ) })
//alert('saveTemplate: q='+q+';');
$.post( q, { template: svgString })
.done( function( httpResponse ) {
refreshTemplateList( data.contract_id );
});
@ -290,7 +285,7 @@ function getTtIdVal(){
</span>
<span>
<a class="btn btn-primary btn-large" onclick="
alert('tt_id='+getTtIdVal()+';');
//alert('tt_id='+getTtIdVal()+';');
saveTemplate({
contract_id:'[%contract.id%]',
tt_id: getTtIdVal(),

@ -64,8 +64,8 @@
<i class="icon-edit"></i> [% c.loc('Make active') %]
</a>
[%END%]
<a class="btn btn-small btn-secondary" data-confirm="Delete"
onclick="fetch_into('collapse_invoice_template_list', '[%- c.uri_for_action("/customer/invoice_template_delete", [contract.id, template.get_column('id')]) -%]');void(0);">
<a class="btn btn-small btn-secondary ngcp-noback-button" data-confirm="Delete"
href="javascript:fetch_into('collapse_invoice_template_list', '[%- c.uri_for_action("/customer/invoice_template_delete", [contract.id, template.get_column('id')]) -%]','',function(){ mainWrapperInit(); });void(0);">
<i class="icon-trash"></i> [% c.loc('Delete') %]
</a>
[%END%]
@ -85,3 +85,4 @@
</table>
[%END%]
</div>

Loading…
Cancel
Save