MT#5879 Clear Alerts

Attempt to enable edit spans or grouped texts. Seems like all texts should be ungrouped, to be ditable
ipeshinskaya/InvoiceTemplate5
Irina Peshinskaya 12 years ago committed by Victor Seva
parent f877c908a6
commit 760e07c8ec

@ -14,6 +14,7 @@ use NGCP::Panel::Utils::Navigation;
use NGCP::Panel::Form::InvoiceTemplate::Basic;
use NGCP::Panel::Model::DB::InvoiceTemplate;
use NGCP::Panel::Utils::InvoiceTemplate;
use JSON;
sub auto {
my ($self, $c) = @_;
@ -456,7 +457,6 @@ sub invoice_details :Chained('base') :PathPart('invoice') :CaptureArgs(0) {
sub invoice_details_ajax :Chained('base') :PathPart('invoice/details/ajax') :Args(0) {
my ($self, $c) = @_;
my $dt_columns_json = $c->request->parameters->{dt_columns};
use JSON;
#use irka;
#use Data::Dumper;
#irka::loglong(Dumper($dt_columns));
@ -812,7 +812,10 @@ sub invoice_template :Chained('invoice_details') :PathPart('template') :Args {
}elsif($in->{tt_output_type} eq 'html'){
$c->response->content_type('text/html');
}elsif($in->{tt_output_type} eq 'json'){
$c->response->content_type('application/json');
#$c->response->content_type('application/json');
#IE prompts to save json file.
$c->response->content_type('text/html');
#$c->response->content_type('text/javascript');
}elsif($in->{tt_output_type}=~m'zip'){
$c->response->content_type('application/zip');
}
@ -858,8 +861,10 @@ sub invoice_template :Chained('invoice_details') :PathPart('template') :Args {
#if we didn't have tt_data - then we have empty form fields with applied defaults
$aaData->{form} = $in;
}
$c->stash( aaData => $aaData );
$c->detach( $c->view('JSON') );
#$c->stash( to_json( { aaData => $aaData} ) );
#$c->detach( $c->view('SVG') );#ie doesn't serve correctly json
$c->response->body( to_json( { aaData => $aaData} ) );
#$c->detach( $c->view('SVG') );#ie doesn't serve correctly json
}elsif($in->{tt_output_type} eq 'pdf'){
#method
$c->response->content_type('application/pdf');

@ -30,15 +30,17 @@ function setSvgStringToEditor( svgParsedString ){
}
function setSvgStringToPreview( svgParsedString, q, data ) {
var previewIframe = document.getElementById('svgpreview');
//alert('setSvgStringToPreview: svgParsedString='+svgParsedString+';');
//alert('setSvgStringToPreview: svgParsedString='+svgParsedString+';data='+data+';');
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){
var dataPreview = data;
dataPreview.tt_viewmode = 'parsed';
dataPreview.tt_type = 'svg';
dataPreview.tt_output_type = 'svg';
dataPreview.tt_sourcestate = dataPreview.tt_sourcestate || 'saved';
q = uriForAction( dataPreview, 'invoice_template' );
//alert('setSvgStringToPreview: q='+q+';');
}
previewIframe.src = q;
}else{
@ -60,20 +62,31 @@ function fetchInvoiceTemplateData( data, noshowform ){
//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+';');
$.ajax({
//alert('fetchInvoiceTemplateData: q='+q+';');
var queryObj = {
url: q,
datatype: "json",
//}).done( function( jsonres ){
}).done( function( templatedata ){
//alert(templatedata);
type: 'POST',
};
//if (!$.browser.msie) {
//msie prompts to save
queryObj.dataType = "json";
//}
queryObj.contentType = 'application/x-www-form-urlencoded;charset=utf-8';
//alert('QQQ');
$.ajax( queryObj ).done( function( templatedata ){
//alert(templatedata.aaData);
//alert(templatedata.aaData);
if(templatedata.aaData){
//if ($.browser.msie) {
//alert(templatedata);
//templatedata = jQuery.parseJSON(templatedata);
//alert(templatedata);
//}
if(templatedata && templatedata.aaData){
if( templatedata.aaData.template ){
setSvgStringToEditor( templatedata.aaData.template.raw );
setSvgStringToPreview( templatedata.aaData.template.parsed );
setSvgStringToPreview( templatedata.aaData.template.parsed, '', data );
}
$('#load_previewed_control').css('display', 'none' );
$('#load_previewed_control').css('visibility', 'visible' );
if( templatedata.aaData.form ){
$('form[name=invoice_template_editor]').loadJSON(templatedata.aaData.form);
if(templatedata.aaData.form.base64_previewed){
@ -81,18 +94,19 @@ function fetchInvoiceTemplateData( data, noshowform ){
}
}
if( !noshowform ){
$('#invoice_template_editor_form').css('display','block');
$('#invoice_template_editor_form').css('visibility','visible');
}
}
});
}
function clearTemplateForm(data){
$('#invoice_template_editor_form').css('display','none');
$('#invoice_template_editor_form').css('visibility','hidden');
$('#load_previewed_control').css('display', 'none' );
if(!data){
data = {};
}
data.tt_sourcestate = 'default';
fetchInvoiceTemplateData(data, 1);
fetchInvoiceTemplateData(data, 1);//1 = no show form again, just clear it up to default state
}
function savePreviewedAndShowParsed( data ){
var svgString = getSvgString();
@ -105,7 +119,7 @@ function savePreviewedAndShowParsed( data ){
.done( function( httpResponse ){
// & show template
//alert('savePreviewedAndShowParsed: httpResponse='+httpResponse+';');
setSvgStringToPreview( httpResponse, q )
setSvgStringToPreview( httpResponse, q, data )
//refresh list after saving
refreshAjaxList( 'invoice_template', data );
} );
@ -116,11 +130,11 @@ function saveTemplate( data ) {
data.tt_output_type = 'json';
var q = uriForAction( data, 'invoice_template_saved' );
q=formToUri(q);
alert('saveTemplate: q='+q+';');
//alert('saveTemplate: q='+q+';');
$.ajax( {
url: q,
type: "POST",
datatype: 'json',
//datatype: 'json',
data: { template: svgString },
} ).done( function( jsonResponse ) {
if(jsonResponse.aaData && jsonResponse.aaData.form){
@ -129,3 +143,4 @@ function saveTemplate( data ) {
refreshAjaxList( 'invoice_template', data );
});
}

@ -27,19 +27,27 @@ if (!svgedit.coords) {
var pathMap = [0, 'z', 'M', 'm', 'L', 'l', 'C', 'c', 'Q', 'q', 'A', 'a',
'H', 'h', 'V', 'v', 'S', 's', 'T', 't'];
/**
* @typedef editorContext
* @type {?object}
* @property {function} getGridSnapping
* @property {function} getDrawing
*/
var editorContext_ = null;
/**
* @param {editorContext} editorContext
*/
svgedit.coords.init = function(editorContext) {
editorContext_ = editorContext;
};
// Function: remapElement
// Applies coordinate changes to an element based on the given matrix
//
// Parameters:
// selected - DOM element to be changed
// changes - Object with changes to be remapped
// m - Matrix object to use for remapping coordinates
/**
* Applies coordinate changes to an element based on the given matrix
* @param {Element} selected - DOM element to be changed
* @param {object} changes - Object with changes to be remapped
* @param {SVGMatrix} m - Matrix object to use for remapping coordinates
*/
svgedit.coords.remapElement = function(selected, changes, m) {
var i, type,
remap = function(x, y) { return svgedit.math.transformPoint(x, y, m); },
@ -200,7 +208,7 @@ svgedit.coords.remapElement = function(selected, changes, m) {
var seg;
var segList = selected.pathSegList;
len = segList.numberOfItems;
changes.d = new Array(len);
changes.d = [];
for (i = 0; i < len; ++i) {
seg = segList.getItem(i);
changes.d[i] = {
@ -305,4 +313,4 @@ svgedit.coords.remapElement = function(selected, changes, m) {
}
};
}());
}());

@ -184,16 +184,17 @@ svgedit.utilities.encodeUTF8 = function (argString) {
enc = String.fromCharCode(
(c1 >> 6) | 192, (c1 & 63) | 128
);
} else if (c1 & 0xF800 != 0xD800) {
} else if ((c1 & 0xF800) != 0xD800) {
enc = String.fromCharCode(
(c1 >> 12) | 224, ((c1 >> 6) & 63) | 128, (c1 & 63) | 128
);
} else { // surrogate pairs
if (c1 & 0xFC00 != 0xD800) {
} else {
// surrogate pairs
if ((c1 & 0xFC00) != 0xD800) {
throw new RangeError('Unmatched trail surrogate at ' + n);
}
var c2 = string.charCodeAt(++n);
if (c2 & 0xFC00 != 0xDC00) {
if ((c2 & 0xFC00) != 0xDC00) {
throw new RangeError('Unmatched lead surrogate at ' + (n - 1));
}
c1 = ((c1 & 0x3FF) << 10) + (c2 & 0x3FF) + 0x10000;
@ -396,7 +397,7 @@ svgedit.utilities.getPathBBox = function(path) {
for (i = 0; i < tot; i++) {
var seg = seglist.getItem(i);
if(typeof seg.x == 'undefined') {continue;}
if(typeof seg.x === 'undefined') {continue;}
// Add actual points to limits
bounds[0].push(P0[0]);

@ -1,5 +1,5 @@
function refreshAjaxList ( item, data ){
alert('refreshAjaxList: q='+uriForAction( data, item + '_list' )+';item='+item);
//alert('refreshAjaxList: q='+uriForAction( data, item + '_list' )+';item='+item);
var target = $('#'+ item + '_list');
if(target){
fetch_into(
@ -14,7 +14,7 @@ function refreshAjaxList ( item, data ){
}
}
function refreshMessagesAjax ( ){
alert('refreshMessagesAjax: q='+uriForAction( {}, 'messages' ));
//alert('refreshMessagesAjax: q='+uriForAction( {}, 'messages' ));
fetch_into(
'messages',
uriForAction( {}, 'messages' )
@ -22,7 +22,7 @@ function refreshMessagesAjax ( ){
}
function processModalFormAjax( form, callback ) {
//preventDefault();
alert(form.attr('action')+'?'+form.serialize());
//alert(form.attr('action')+'?'+form.serialize());
var item = form.attr('id');
$.ajax( {
url: form.attr('action'),
@ -73,7 +73,7 @@ function listRestoreCurrentEdit(staticContainer, staticContainerId){
}
if(staticContainer){
var id = getCurrentEditId(staticContainer, staticContainerId);
alert('listRestoreCurrentEdit:id='+id+';');
//alert('listRestoreCurrentEdit:id='+id+';');
if(id){
var tr = staticContainer.find('tr[data-id='+id+']');
if(tr){
@ -101,7 +101,7 @@ function setCurrentEditId(id, staticContainer, staticContainerId){
}
}
function listSetCurrentEdit( id, tr, staticContainer ) {
alert('listSetCurrentEdit: id='+id+';tr='+tr+';');
//alert('listSetCurrentEdit: id='+id+';tr='+tr+';');
var curclass = 'ngcp_current_edit';
if(!staticContainer){
staticContainer = tr.closest('.accordion-inner');

@ -93,20 +93,20 @@ var uriForAction = function( data, type ){
[%
clearHelper();
helper.name = c.loc('Invoice Details');
helper.dt_columns = [
{ name => 'zone', title => c.loc('Zone'), search=> 1 },
{ name => 'number', title => c.loc('Calls amount') },
{ name => 'duration', title => c.loc('Duration') },
{ name => 'free_time', title => c.loc('Free time') },
{ name => 'cost', title => c.loc('Cash') },
];
helper.name_single = c.loc('Invoice Record');
helper.identifier = 'invoice_details_raw';
helper.ajax_uri = c.uri_for_action( '/reseller/invoice_details_ajax', [ contract.id ] ) ;
initHelperAuto();
PROCESS 'helpers/datatables.tt';
#clearHelper();
#helper.name = c.loc('Invoice Details');
#helper.dt_columns = [
# { name => 'zone', title => c.loc('Zone'), search=> 1 },
# { name => 'number', title => c.loc('Calls amount') },
# { name => 'duration', title => c.loc('Duration') },
# { name => 'free_time', title => c.loc('Free time') },
# { name => 'cost', title => c.loc('Cash') },
#];
#helper.name_single = c.loc('Invoice Record');
#helper.identifier = 'invoice_details_raw';
#helper.ajax_uri = c.uri_for_action( '/reseller/invoice_details_ajax', [ contract.id ] ) ;
#initHelperAuto();
#PROCESS 'helpers/datatables.tt';
-%]
[%PROCESS 'invoice/invoice_details_list.tt' %]
@ -121,15 +121,15 @@ var uriForAction = function( data, type ){
<a class="accordion-toggle" data-toggle="collapse" data-parent="#customer_invoice_template" href="#collapse_invoice_template_list">[% c.loc('Invoice Templates') %]</a>
</div>
<div class="accordion-body collapse" id="collapse_invoice_template_list">
<div class="accordion-inner" style="overflow:auto; height: 300px;" id="invoice_template_list">
<div class="accordion-inner" style="overflow:auto; height:300px;" id="invoice_template_list">
[%PROCESS 'invoice/invoice_template_list.tt' %]
</div>
</div>
</div>
</span>
<div style="display:none;" id="invoice_template_editor_form">
<!--with display:none only the opera works with svg, others cant operate geometry on start and fail with a lot of svg related errors-->
<div style="visibility:hidden;" id="invoice_template_editor_form">
[%PROCESS 'invoice/invoice_template_editor_form.tt' %]
</div>

Loading…
Cancel
Save