Fix for tests

This commit is contained in:
Hillel Coren 2017-11-18 20:12:52 +02:00
parent 57757cdb00
commit 04ed72c5c5

View File

@ -158,6 +158,20 @@
$(function() { $(function() {
@if (Input::old('data'))
// this means we failed so we'll reload the previous state
window.model = new ViewModel({!! $data !!});
@else
// otherwise create blank model
window.model = new ViewModel({!! $payment !!});
@endif
ko.applyBindings(model);
$('#amount').change(function() {
var amount = $('#amount').val();
model.amount(NINJA.parseFloat(amount));
})
@if ($payment) @if ($payment)
$('#payment_date').datepicker('update', '{{ $payment->payment_date }}') $('#payment_date').datepicker('update', '{{ $payment->payment_date }}')
@if ($payment->payment_type_id != PAYMENT_TYPE_CREDIT) @if ($payment->payment_type_id != PAYMENT_TYPE_CREDIT)
@ -187,20 +201,6 @@
$('#email_receipt').prop('checked', true); $('#email_receipt').prop('checked', true);
} }
} }
@if (Input::old('data'))
// this means we failed so we'll reload the previous state
window.model = new ViewModel({!! $data !!});
@else
// otherwise create blank model
window.model = new ViewModel({!! $payment !!});
@endif
ko.applyBindings(model);
$('#amount').change(function() {
var amount = $('#amount').val();
model.amount(NINJA.parseFloat(amount));
})
}); });
function onFormSubmit(event) { function onFormSubmit(event) {
@ -257,11 +257,6 @@
} }
}, self); }, self);
self.payment_currency_id = ko.computed(function() {
//return
});
self.getCurrency = function(currencyId) { self.getCurrency = function(currencyId) {
return currencyMap[currencyId || self.account_currency_id()]; return currencyMap[currencyId || self.account_currency_id()];
}; };
@ -339,6 +334,10 @@
} }
}); });
if (clientId) {
$clientSelect.trigger('change');
}
var $invoiceSelect = $('select#invoice').on('change', function(e) { var $invoiceSelect = $('select#invoice').on('change', function(e) {
$clientCombobox = $('select#client'); $clientCombobox = $('select#client');
var invoiceId = $('input[name=invoice]').val(); var invoiceId = $('input[name=invoice]').val();
@ -353,9 +352,7 @@
model.amount(amount); model.amount(amount);
} }
} }
if (window.model) { model.client_id(client ? client.public_id : 0);
model.client_id(client ? client.public_id : 0);
}
}); });
$invoiceSelect.combobox({highlighter: comboboxHighlighter}); $invoiceSelect.combobox({highlighter: comboboxHighlighter});