mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 09:14:31 -04:00
Support creating inline vendors and categories
This commit is contained in:
parent
009de83e93
commit
25c89d11f9
28
resources/views/partials/entity_combobox.blade.php
Normal file
28
resources/views/partials/entity_combobox.blade.php
Normal file
@ -0,0 +1,28 @@
|
||||
var {{ $entityType }}Name = '';
|
||||
|
||||
${{ $entityType }}Select.combobox({
|
||||
highlighter: function (item) {
|
||||
if (item.indexOf("{{ trans("texts.create_{$entityType}") }}") == 0) {
|
||||
{{ $entityType }}Name = this.query;
|
||||
return "{{ trans("texts.create_{$entityType}") }}: " + this.query;
|
||||
} else {
|
||||
var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&');
|
||||
return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
|
||||
return '<strong>' + match + '</strong>';
|
||||
})
|
||||
}
|
||||
},
|
||||
template: '<div class="combobox-container"> <input type="hidden" /> <div class="input-group"> <input type="text" id="{{ $entityType }}_name" name="{{ $entityType }}_name" autocomplete="off" /> <span class="input-group-addon dropdown-toggle" data-dropdown="dropdown"> <span class="caret" /> <i class="fa fa-times"></i> </span> </div> </div> ',
|
||||
matcher: function (item) {
|
||||
// if the user has entered a value show the 'Create ...' option
|
||||
if (item.indexOf("{{ trans("texts.create_{$entityType}") }}") == 0) {
|
||||
return this.query.length;
|
||||
}
|
||||
return ~item.toLowerCase().indexOf(this.query.toLowerCase());
|
||||
}
|
||||
}).on('change', function(e) {
|
||||
var {{ $entityType }}Id = $('input[name={{ $entityType }}_id]').val();
|
||||
if ({{ $entityType }}Id == '-1') {
|
||||
$('#{{ $entityType }}_name').val({{ $entityType }}Name);
|
||||
}
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user