1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

Working on product fields

This commit is contained in:
Hillel Coren 2017-10-29 10:02:17 +02:00
parent 97fd40c8d3
commit 817d7b83ad
3 changed files with 24 additions and 10 deletions

View File

@ -329,8 +329,6 @@ trait PresentsInvoice
'service',
'product_key',
'unit_cost',
'tax1',
'tax2',
'custom_value1',
'custom_value2',
];

View File

@ -254,7 +254,7 @@
<div class="pull-right" style="padding-right:14px">
{!! Button::normal(trans('texts.reset'))->small()
->withAttributes(['onclick' => 'sweetConfirm(function() {
resetFields();
resetInvoiceFields();
})']) !!}
</div>
</div>
@ -273,7 +273,7 @@
<div class="pull-right" style="padding-right:14px">
{!! Button::normal(trans('texts.reset'))->small()
->withAttributes(['onclick' => 'sweetConfirm(function() {
resetFields();
resetProductFields();
})']) !!}
</div>
</div>

View File

@ -17,11 +17,14 @@ function ViewModel(data) {
}
}
self.resetFields = function() {
self.resetInvoiceFields = function() {
self.invoice_fields.removeAll();
self.client_fields.removeAll();
self.account_fields1.removeAll();
self.account_fields2.removeAll();
}
self.resetProductFields = function() {
self.product_fields.removeAll();
self.task_fields.removeAll();
}
@ -113,10 +116,17 @@ $(function() {
ko.applyBindings(model);
})
function resetFields() {
function resetInvoiceFields() {
var defaultFields = {!! json_encode($account->getDefaultInvoiceFields()) !!};
window.model.resetFields();
loadFields(defaultFields);
window.model.resetInvoiceFields();
loadFields(defaultFields, 'invoice');
window.model.onChange();
}
function resetProductFields() {
var defaultFields = {!! json_encode($account->getDefaultInvoiceFields()) !!};
window.model.resetProductFields();
loadFields(defaultFields, 'product');
window.model.onChange();
}
@ -136,12 +146,18 @@ function loadMap(allFields) {
}
}
function loadFields(selectedFields)
{
function loadFields(selectedFields, filter) {
for (var section in selectedFields) {
if ( ! selectedFields.hasOwnProperty(section)) {
continue;
}
if (filter == 'invoice' && (section == 'product_fields' || section == 'task_fields')) {
continue;
} else if (filter == 'product' && (section != 'product_fields' && section != 'task_fields')) {
continue;
}
var fields = selectedFields[section];
for (var field in fields) {
if ( ! fields.hasOwnProperty(field)) {