mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 02:47:34 -05:00 
			
		
		
		
	Show used options in invoice field selects
This commit is contained in:
		
							parent
							
								
									a8b606634d
								
							
						
					
					
						commit
						46a63e9854
					
				@ -16,7 +16,6 @@ function ViewModel(data) {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    self.resetFields = function() {
 | 
					    self.resetFields = function() {
 | 
				
			||||||
        console.log('herey');
 | 
					 | 
				
			||||||
        self.invoice_fields.removeAll();
 | 
					        self.invoice_fields.removeAll();
 | 
				
			||||||
        self.client_fields.removeAll();
 | 
					        self.client_fields.removeAll();
 | 
				
			||||||
        self.account_fields1.removeAll();
 | 
					        self.account_fields1.removeAll();
 | 
				
			||||||
@ -24,10 +23,29 @@ function ViewModel(data) {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    self.onChange = function() {
 | 
					    self.onChange = function() {
 | 
				
			||||||
 | 
					        self.updateSelects();
 | 
				
			||||||
        refreshPDF();
 | 
					        refreshPDF();
 | 
				
			||||||
        NINJA.formIsChanged = true;
 | 
					        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<selects.length; i++) {
 | 
				
			||||||
 | 
					            var select = selects[i];
 | 
				
			||||||
 | 
					            $('#' + select + '_select > option').each(function() {
 | 
				
			||||||
 | 
					                var isUsed = usedFields.indexOf(this.value) >= 0;
 | 
				
			||||||
 | 
					                $(this).css('color', isUsed ? '#888' : 'black');
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    self.onDragged = function() {
 | 
					    self.onDragged = function() {
 | 
				
			||||||
        self.onChange();
 | 
					        self.onChange();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -55,6 +73,7 @@ function addField(section) {
 | 
				
			|||||||
    var field = $select.val();
 | 
					    var field = $select.val();
 | 
				
			||||||
    var label = $select.find('option:selected').text();
 | 
					    var label = $select.find('option:selected').text();
 | 
				
			||||||
    window.model.addField(section, field, label);
 | 
					    window.model.addField(section, field, label);
 | 
				
			||||||
 | 
					    window.model.onChange();
 | 
				
			||||||
    $select.val(null).blur();
 | 
					    $select.val(null).blur();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -67,6 +86,7 @@ $(function() {
 | 
				
			|||||||
    loadFields(selectedFields);
 | 
					    loadFields(selectedFields);
 | 
				
			||||||
    loadMap(allFields);
 | 
					    loadMap(allFields);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    model.updateSelects();
 | 
				
			||||||
    ko.applyBindings(model);
 | 
					    ko.applyBindings(model);
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user