diff --git a/resources/views/accounts/partials/invoice_fields.blade.php b/resources/views/accounts/partials/invoice_fields.blade.php index 9a38a2105f36..5a142bf3458c 100644 --- a/resources/views/accounts/partials/invoice_fields.blade.php +++ b/resources/views/accounts/partials/invoice_fields.blade.php @@ -16,7 +16,6 @@ function ViewModel(data) { } self.resetFields = function() { - console.log('herey'); self.invoice_fields.removeAll(); self.client_fields.removeAll(); self.account_fields1.removeAll(); @@ -24,10 +23,29 @@ function ViewModel(data) { } self.onChange = function() { + self.updateSelects(); refreshPDF(); NINJA.formIsChanged = true; } + self.updateSelects = function() { + var usedFields = [].concat(self.invoice_fields(), self.client_fields(), self.account_fields1(), self.account_fields2()); + var selects = [ + 'invoice_fields', + 'client_fields', + 'account_fields1', + 'account_fields2', + ]; + + for (var i=0; i option').each(function() { + var isUsed = usedFields.indexOf(this.value) >= 0; + $(this).css('color', isUsed ? '#888' : 'black'); + }); + } + } + self.onDragged = function() { self.onChange(); } @@ -55,6 +73,7 @@ function addField(section) { var field = $select.val(); var label = $select.find('option:selected').text(); window.model.addField(section, field, label); + window.model.onChange(); $select.val(null).blur(); } @@ -67,6 +86,7 @@ $(function() { loadFields(selectedFields); loadMap(allFields); + model.updateSelects(); ko.applyBindings(model); })