mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 12:12:48 +01:00
Improved client combobox
This commit is contained in:
parent
2ee11654d5
commit
b86bf323f7
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
public/css/built.css
vendored
2
public/css/built.css
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
12
resources/assets/css/style.css
vendored
12
resources/assets/css/style.css
vendored
@ -424,6 +424,18 @@ ul.dropdown-menu,
|
|||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ul.typeahead li:first-child {
|
||||||
|
border-top: solid 1px #EEE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.typeahead li {
|
||||||
|
border-bottom: solid 1px #EEE;
|
||||||
|
}
|
||||||
|
|
||||||
|
.combobox-container .active {
|
||||||
|
border-color: #EEE !important;
|
||||||
|
}
|
||||||
|
|
||||||
.panel-default,
|
.panel-default,
|
||||||
canvas {
|
canvas {
|
||||||
border: 1px solid;
|
border: 1px solid;
|
||||||
|
@ -447,6 +447,13 @@ if (window.ko) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function comboboxHighlighter(item) {
|
||||||
|
var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&');
|
||||||
|
return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
|
||||||
|
return match ? '<strong>' + match + '</strong>' : query;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function getContactDisplayName(contact)
|
function getContactDisplayName(contact)
|
||||||
{
|
{
|
||||||
if (contact.first_name || contact.last_name) {
|
if (contact.first_name || contact.last_name) {
|
||||||
@ -456,6 +463,21 @@ function getContactDisplayName(contact)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getContactDisplayNameWithEmail(contact)
|
||||||
|
{
|
||||||
|
var str = '';
|
||||||
|
|
||||||
|
if (contact.first_name || contact.last_name) {
|
||||||
|
str += $.trim((contact.first_name || '') + ' ' + (contact.last_name || ''));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (contact.email) {
|
||||||
|
str += ' <' + contact.email + '>';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $.trim(str);
|
||||||
|
}
|
||||||
|
|
||||||
function getClientDisplayName(client)
|
function getClientDisplayName(client)
|
||||||
{
|
{
|
||||||
var contact = client.contacts ? client.contacts[0] : false;
|
var contact = client.contacts ? client.contacts[0] : false;
|
||||||
|
@ -101,7 +101,11 @@
|
|||||||
<div style="display:none">
|
<div style="display:none">
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
{!! Former::select('client')->addOption('', '')->data_bind("dropdown: client")->addClass('client-input')->addGroupClass('client_select closer-row') !!}
|
{!! Former::select('client')
|
||||||
|
->addOption('', '')
|
||||||
|
->data_bind("dropdown: client, dropdownOptions: {highlighter: comboboxHighlighter}")
|
||||||
|
->addClass('client-input')
|
||||||
|
->addGroupClass('client_select closer-row') !!}
|
||||||
|
|
||||||
<div class="form-group" style="margin-bottom: 8px">
|
<div class="form-group" style="margin-bottom: 8px">
|
||||||
<div class="col-lg-8 col-sm-8 col-lg-offset-4 col-sm-offset-4">
|
<div class="col-lg-8 col-sm-8 col-lg-offset-4 col-sm-offset-4">
|
||||||
@ -838,21 +842,21 @@
|
|||||||
for (var i=0; i<clients.length; i++) {
|
for (var i=0; i<clients.length; i++) {
|
||||||
var client = clients[i];
|
var client = clients[i];
|
||||||
clientMap[client.public_id] = client;
|
clientMap[client.public_id] = client;
|
||||||
var clientName = getClientDisplayName(client);
|
|
||||||
@if (! $invoice->id)
|
@if (! $invoice->id)
|
||||||
if (!clientName) {
|
if (!getClientDisplayName(client)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@endif
|
@endif
|
||||||
for (var j=0; j<client.contacts.length; j++) {
|
var clientName = client.name;
|
||||||
|
for (var j=0; j<client.contacts.length; j++) {
|
||||||
var contact = client.contacts[j];
|
var contact = client.contacts[j];
|
||||||
var contactName = getContactDisplayName(contact);
|
var contactName = getContactDisplayNameWithEmail(contact);
|
||||||
if (contact.is_primary === '1') {
|
if (clientName && contactName) {
|
||||||
contact.send_invoice = true;
|
clientName += '<br/> • ';
|
||||||
}
|
}
|
||||||
if (contactName && clientName != contactName) {
|
if (contactName) {
|
||||||
$clientSelect.append(new Option(contactName, client.public_id));
|
clientName += contactName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$clientSelect.append(new Option(clientName, client.public_id));
|
$clientSelect.append(new Option(clientName, client.public_id));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user