Bug fixes

This commit is contained in:
Hillel Coren 2015-08-20 11:02:03 +03:00
parent 972e949035
commit 407af306a5
7 changed files with 35 additions and 9 deletions

View File

@ -306,7 +306,7 @@ class ClientController extends BaseController
Session::flash('message', $message); Session::flash('message', $message);
if ($action == 'restore' && $count == 1) { if ($action == 'restore' && $count == 1) {
return Redirect::to('clients/'.$ids[0]); return Redirect::to('clients/'.Utils::getFirst($ids));
} else { } else {
return Redirect::to('clients'); return Redirect::to('clients');
} }

View File

@ -594,7 +594,7 @@ class InvoiceController extends BaseController
} }
if ($action == 'restore' && $count == 1) { if ($action == 'restore' && $count == 1) {
return Redirect::to("{$entityType}s/".$ids[0]); return Redirect::to("{$entityType}s/".Utils::getFirst($ids));
} else { } else {
return Redirect::to("{$entityType}s"); return Redirect::to("{$entityType}s");
} }

View File

@ -185,7 +185,11 @@ class QuoteController extends BaseController
Session::flash('message', $message); Session::flash('message', $message);
} }
return Redirect::to('quotes'); if ($action == 'restore' && $count == 1) {
return Redirect::to("quotes/".Utils::getFirst($ids));
} else {
return Redirect::to("quotes");
}
} }
public function approve($invitationKey) public function approve($invitationKey)

View File

@ -735,4 +735,12 @@ class Utils
return $val; return $val;
} }
public static function getFirst($values) {
if (is_array($values)) {
return count($values) ? $values[0] : false;
} else {
return $values;
}
}
} }

View File

@ -31511,6 +31511,11 @@ function getDescendantProp(obj, desc) {
while(arr.length && (obj = obj[arr.shift()])); while(arr.length && (obj = obj[arr.shift()]));
return obj; return obj;
} }
function doubleDollarSign(str) {
if (!str) return '';
return str.replace(/\$/g, '\$\$\$');
}
var NINJA = NINJA || {}; var NINJA = NINJA || {};
NINJA.TEMPLATES = { NINJA.TEMPLATES = {
@ -31622,6 +31627,7 @@ NINJA.decodeJavascript = function(invoice, javascript)
for (var key in json) { for (var key in json) {
var regExp = new RegExp('"\\$'+key+'"', 'g'); var regExp = new RegExp('"\\$'+key+'"', 'g');
var val = JSON.stringify(json[key]); var val = JSON.stringify(json[key]);
val = doubleDollarSign(val);
javascript = javascript.replace(regExp, val); javascript = javascript.replace(regExp, val);
} }
@ -31664,6 +31670,7 @@ NINJA.decodeJavascript = function(invoice, javascript)
field = match.substring(2, match.indexOf('Value')); field = match.substring(2, match.indexOf('Value'));
field = toSnakeCase(field); field = toSnakeCase(field);
var value = getDescendantProp(invoice, field) || ' '; var value = getDescendantProp(invoice, field) || ' ';
value = doubleDollarSign(value);
if (field.toLowerCase().indexOf('date') >= 0 && value != ' ') { if (field.toLowerCase().indexOf('date') >= 0 && value != ' ') {
value = moment(value, 'YYYY-MM-DD').format('MMM D YYYY'); value = moment(value, 'YYYY-MM-DD').format('MMM D YYYY');
@ -31695,9 +31702,9 @@ NINJA.notesAndTerms = function(invoice)
NINJA.invoiceColumns = function(invoice) NINJA.invoiceColumns = function(invoice)
{ {
if (invoice.account.hide_quantity == '1') { if (invoice.account.hide_quantity == '1') {
return ["15%", "*", "auto", "15%"]; return ["15%", "*", "10%", "15%"];
} else { } else {
return ["15%", "*", "auto", "auto", "15%"]; return ["15%", "*", "10%", "auto", "15%"];
} }
} }

View File

@ -109,6 +109,7 @@ NINJA.decodeJavascript = function(invoice, javascript)
for (var key in json) { for (var key in json) {
var regExp = new RegExp('"\\$'+key+'"', 'g'); var regExp = new RegExp('"\\$'+key+'"', 'g');
var val = JSON.stringify(json[key]); var val = JSON.stringify(json[key]);
val = doubleDollarSign(val);
javascript = javascript.replace(regExp, val); javascript = javascript.replace(regExp, val);
} }
@ -151,6 +152,7 @@ NINJA.decodeJavascript = function(invoice, javascript)
field = match.substring(2, match.indexOf('Value')); field = match.substring(2, match.indexOf('Value'));
field = toSnakeCase(field); field = toSnakeCase(field);
var value = getDescendantProp(invoice, field) || ' '; var value = getDescendantProp(invoice, field) || ' ';
value = doubleDollarSign(value);
if (field.toLowerCase().indexOf('date') >= 0 && value != ' ') { if (field.toLowerCase().indexOf('date') >= 0 && value != ' ') {
value = moment(value, 'YYYY-MM-DD').format('MMM D YYYY'); value = moment(value, 'YYYY-MM-DD').format('MMM D YYYY');
@ -182,9 +184,9 @@ NINJA.notesAndTerms = function(invoice)
NINJA.invoiceColumns = function(invoice) NINJA.invoiceColumns = function(invoice)
{ {
if (invoice.account.hide_quantity == '1') { if (invoice.account.hide_quantity == '1') {
return ["15%", "*", "auto", "15%"]; return ["15%", "*", "10%", "15%"];
} else { } else {
return ["15%", "*", "auto", "auto", "15%"]; return ["15%", "*", "10%", "auto", "15%"];
} }
} }

View File

@ -1640,3 +1640,8 @@ function getDescendantProp(obj, desc) {
while(arr.length && (obj = obj[arr.shift()])); while(arr.length && (obj = obj[arr.shift()]));
return obj; return obj;
} }
function doubleDollarSign(str) {
if (!str) return '';
return str.replace(/\$/g, '\$\$\$');
}