mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 19:14:40 -04:00
Added navigation to search
This commit is contained in:
parent
c9f38699d2
commit
3ca89b2792
@ -5,6 +5,7 @@ use Request;
|
||||
use Session;
|
||||
use Utils;
|
||||
use DB;
|
||||
use URL;
|
||||
use stdClass;
|
||||
use Validator;
|
||||
use Schema;
|
||||
@ -70,6 +71,16 @@ class AccountRepository
|
||||
}
|
||||
|
||||
public function getSearchData()
|
||||
{
|
||||
$data = $this->getAccountSearchData();
|
||||
|
||||
$type = trans('texts.navigation');
|
||||
$data[$type] = $this->getNavigationSearchData();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function getAccountSearchData()
|
||||
{
|
||||
$clients = \DB::table('clients')
|
||||
->where('clients.deleted_at', '=', null)
|
||||
@ -109,9 +120,56 @@ class AccountRepository
|
||||
|
||||
$data[$type][] = [
|
||||
'value' => $row->name,
|
||||
'public_id' => $row->public_id,
|
||||
'tokens' => $tokens,
|
||||
'entity_type' => $row->type,
|
||||
'url' => URL::to("/{$row->type}/{$row->public_id}"),
|
||||
];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function getNavigationSearchData()
|
||||
{
|
||||
$features = [
|
||||
['dashboard', '/dashboard'],
|
||||
['customize_design', '/settings/customize_design'],
|
||||
];
|
||||
|
||||
$entityTypes = [
|
||||
ENTITY_INVOICE,
|
||||
ENTITY_CLIENT,
|
||||
ENTITY_QUOTE,
|
||||
ENTITY_TASK,
|
||||
ENTITY_EXPENSE,
|
||||
ENTITY_RECURRING_INVOICE,
|
||||
ENTITY_PAYMENT,
|
||||
ENTITY_CREDIT
|
||||
];
|
||||
|
||||
foreach ($entityTypes as $entityType) {
|
||||
$features[] = [
|
||||
"new_{$entityType}",
|
||||
"/{$entityType}s/create",
|
||||
];
|
||||
$features[] = [
|
||||
"list_{$entityType}s",
|
||||
"/{$entityType}s",
|
||||
];
|
||||
}
|
||||
|
||||
$settings = array_merge(Account::$basicSettings, Account::$advancedSettings);
|
||||
|
||||
foreach ($settings as $setting) {
|
||||
$features[] = [
|
||||
$setting,
|
||||
"/settings/{$setting}",
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($features as $feature) {
|
||||
$data[] = [
|
||||
'value' => trans('texts.' . $feature[0]),
|
||||
'url' => URL::to($feature[1])
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -122,8 +122,8 @@ $LANG = array(
|
||||
'filter' => 'Filter',
|
||||
'new_client' => 'New Client',
|
||||
'new_invoice' => 'New Invoice',
|
||||
'new_payment' => 'Enter Payment',
|
||||
'new_credit' => 'Enter Credit',
|
||||
'new_payment' => 'New Payment',
|
||||
'new_credit' => 'New Credit',
|
||||
'contact' => 'Contact',
|
||||
'date_created' => 'Date Created',
|
||||
'last_login' => 'Last Login',
|
||||
@ -868,7 +868,7 @@ $LANG = array(
|
||||
'white_label_purchase_link' => 'Purchase a white label license',
|
||||
'expense' => 'Expense',
|
||||
'expenses' => 'Expenses',
|
||||
'new_expense' => 'Enter Expense',
|
||||
'new_expense' => 'New Expense',
|
||||
'enter_expense' => 'Enter Expense',
|
||||
'vendors' => 'Vendors',
|
||||
'new_vendor' => 'New Vendor',
|
||||
@ -1028,6 +1028,16 @@ $LANG = array(
|
||||
'user_unconfirmed' => 'Please confirm your account to send emails',
|
||||
'invalid_contact_email' => 'Invalid contact email',
|
||||
],
|
||||
|
||||
'navigation' => 'Navigation',
|
||||
'list_invoices' => 'List Invoices',
|
||||
'list_clients' => 'List Clients',
|
||||
'list_quotes' => 'List Quotes',
|
||||
'list_tasks' => 'List Tasks',
|
||||
'list_expensess' => 'List Expenses',
|
||||
'list_recurring_invoices' => 'List Recurring Invoices',
|
||||
'list_payments' => 'List Payments',
|
||||
'list_credits' => 'List Credits',
|
||||
);
|
||||
|
||||
return $LANG;
|
||||
|
@ -268,6 +268,7 @@
|
||||
} else {
|
||||
trackEvent('/activity', '/search');
|
||||
$.get('{{ URL::route('getSearchData') }}', function(data) {
|
||||
console.log(data);
|
||||
window.searchData = true;
|
||||
var datasets = [];
|
||||
for (var type in data)
|
||||
@ -283,8 +284,7 @@
|
||||
return;
|
||||
}
|
||||
$('#search').typeahead(datasets).on('typeahead:selected', function(element, datum, name) {
|
||||
var type = name == 'Contacts' ? 'clients' : name.toLowerCase();
|
||||
window.location = '{{ URL::to('/') }}' + '/' + datum.entity_type + '/' + datum.public_id;
|
||||
window.location = datum.url;
|
||||
}).focus().typeahead('setQuery', $('#search').val());
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user