mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Enhance Product Drop Down Selector on Invoices #1975
This commit is contained in:
parent
2b7b9f83e4
commit
a678044b4b
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1158,7 +1158,7 @@ function prettyJson(json) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function searchData(data, key, fuzzy) {
|
function searchData(data, key, fuzzy, secondKey) {
|
||||||
return function findMatches(q, cb) {
|
return function findMatches(q, cb) {
|
||||||
var matches, substringRegex;
|
var matches, substringRegex;
|
||||||
if (fuzzy) {
|
if (fuzzy) {
|
||||||
@ -1173,7 +1173,8 @@ function searchData(data, key, fuzzy) {
|
|||||||
$.each(data, function(i, obj) {
|
$.each(data, function(i, obj) {
|
||||||
if (substrRegex.test(obj[key])) {
|
if (substrRegex.test(obj[key])) {
|
||||||
matches.push(obj);
|
matches.push(obj);
|
||||||
}
|
} else if (secondKey && substrRegex.test(obj[secondKey]))
|
||||||
|
matches.push(obj);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
cb(matches);
|
cb(matches);
|
||||||
|
@ -1039,13 +1039,12 @@ ko.bindingHandlers.productTypeahead = {
|
|||||||
display: allBindings.key,
|
display: allBindings.key,
|
||||||
limit: 50,
|
limit: 50,
|
||||||
templates: {
|
templates: {
|
||||||
suggestion: function(item) { return '<div title="'
|
suggestion: function(item) { return '<div title="' + _.escape(item.notes) + '" style="border-bottom: solid 1px #CCC">'
|
||||||
+ _.escape(item.product_key) + ': '
|
+ _.escape(item.product_key) + ': '
|
||||||
+ item.cost + "\n"
|
+ roundToTwo(item.cost, true) + "<br/>"
|
||||||
+ item.notes.substring(0, 60) + '">'
|
+ _.escape(item.notes.substring(0, 100)) + '</div>' }
|
||||||
+ _.escape(item.product_key) + '</div>' }
|
|
||||||
},
|
},
|
||||||
source: searchData(allBindings.items, allBindings.key)
|
source: searchData(allBindings.items, allBindings.key, false, 'notes')
|
||||||
}).on('typeahead:select', function(element, datum, name) {
|
}).on('typeahead:select', function(element, datum, name) {
|
||||||
@if (Auth::user()->account->fill_products)
|
@if (Auth::user()->account->fill_products)
|
||||||
var model = ko.dataFor(this);
|
var model = ko.dataFor(this);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user