From 9aa35efdc9b26d356d94aa05f8c846d62f5eeff2 Mon Sep 17 00:00:00 2001 From: Irina Peshinskaya Date: Thu, 3 Apr 2014 18:05:08 +0300 Subject: [PATCH] MT#5879 Save state before new default template. Template form shown on click. Fix accordion intialization after ajax list refresh Add confirmation on default template applying --- lib/NGCP/Panel/Controller/Reseller.pm | 8 ++--- share/layout/body.tt | 36 ++++++++++++------- share/static/js/invoice_template.js | 18 ++++++---- share/templates/invoice/invoice.tt | 4 ++- .../invoice/invoice_template_form.tt | 36 ++++++------------- .../invoice/invoice_template_list.tt | 6 ++-- 6 files changed, 51 insertions(+), 57 deletions(-) diff --git a/lib/NGCP/Panel/Controller/Reseller.pm b/lib/NGCP/Panel/Controller/Reseller.pm index 6854660943..44405110c3 100644 --- a/lib/NGCP/Panel/Controller/Reseller.pm +++ b/lib/NGCP/Panel/Controller/Reseller.pm @@ -683,11 +683,7 @@ sub invoice :Chained('invoice_template_list_data') :PathPart('') :Args(0) { $c->stash(template => 'invoice/invoice.tt'); } -sub invoice_template_info :Chained('invoice_details') :PathPart('template') :CaptureArgs(0) { - - -} -sub invoice_template :Chained('invoice_template_info') :PathPart('template') :Args { +sub invoice_template :Chained('invoice_details') :PathPart('template') :Args { my ($self, $c) = @_; $c->log->debug('invoice_template'); no warnings 'uninitialized'; @@ -725,7 +721,7 @@ sub invoice_template :Chained('invoice_template_info') :PathPart('template') :Ar #multi return... $c->log->debug("validated=".$validator->validated.";\n"); if(!$validator->validated){ - return; + #return; } my $in_validated = $validator->fif; diff --git a/share/layout/body.tt b/share/layout/body.tt index 1fb7919bb7..9a16bcf443 100644 --- a/share/layout/body.tt +++ b/share/layout/body.tt @@ -92,8 +92,8 @@ [% # vim: set tabstop=4 syntax=html expandtab: -%] diff --git a/share/static/js/invoice_template.js b/share/static/js/invoice_template.js index dff5bb2584..ac375c56c9 100644 --- a/share/static/js/invoice_template.js +++ b/share/static/js/invoice_template.js @@ -56,12 +56,15 @@ function fetchSvgToEditor( data ) { } function refreshAccordionAjaxList ( item, data ){ alert('refreshAccordionAjaxList: q='+uriForAction( data, item + '_list' )+';item='+item); - fetch_into( - 'collapse_' +item + '_list', - uriForAction( data, item + '_list' ), - '', - function(){ mainWrapperInit(); } - ); + var target = $('#'+ item + '_list'); + if(target){ + fetch_into( + item + '_list', + uriForAction( data, item + '_list' ), + '', + function(){ mainWrapperInit(); } + ); + } } function refreshMessagesAjax ( ){ alert('refreshMessagesAjax: q='+uriForAction( {}, 'messages' )); @@ -76,7 +79,7 @@ function fetchInvoiceTemplateData( data ){ //tt_output_type=svg really outputs text/html mimetype. But it will be couple of tags ( 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", @@ -92,6 +95,7 @@ function fetchInvoiceTemplateData( data ){ if( templatedata.aaData.form ){ $('form[name=invoice_template]').loadJSON(templatedata.aaData.form); } + $('#invoice_template_form').css('display','block');//document.getElementById('invoice_template_form');; } }); } diff --git a/share/templates/invoice/invoice.tt b/share/templates/invoice/invoice.tt index 077ca56073..98f5bb915b 100644 --- a/share/templates/invoice/invoice.tt +++ b/share/templates/invoice/invoice.tt @@ -121,13 +121,15 @@ var uriForAction = function( data, type ){ [% c.loc('Invoice Templates') %]
+
[%PROCESS 'invoice/invoice_template_list.tt' %]
+
-
+ diff --git a/share/templates/invoice/invoice_template_form.tt b/share/templates/invoice/invoice_template_form.tt index 9833e5dc34..9928018f39 100644 --- a/share/templates/invoice/invoice_template_form.tt +++ b/share/templates/invoice/invoice_template_form.tt @@ -3,13 +3,13 @@ [%# USE FillInForm %]
-
-[% IF write_access -%] - -
-[% END -%] -
- -
- -
-
-
-
- -
- -
-
+ });void(0);">[% c.loc('Load default')%] + - [% c.loc('Refresh Preview')%] - [%IF invoice_template_list.size %] @@ -41,11 +40,11 @@ [% c.loc('Edit template') %] + href="javascript:fetch_into('invoice_template_list', '[%- c.uri_for_action("/reseller/invoice_template_activate", [contract.id, template.get_column('id'),template.get_column('is_active')]) -%]','',function(){ refreshMessagesAjax();mainWrapperInit(); });void(0);"> [%IF template.get_column('is_active'); c.loc('Deactivate'); ELSE; c.loc('Activate'); END%] + href="javascript:fetch_into('invoice_template_list', '[%- c.uri_for_action("/reseller/invoice_template_delete", [contract.id, template.get_column('id')]) -%]','',function(){ refreshMessagesAjax();mainWrapperInit(); });void(0);"> [% c.loc('Delete') %] [%END%] @@ -56,5 +55,4 @@
[%END%] -