First functional version (No tests)
This commit is contained in:
parent
c6b2db9a79
commit
9d1bc8eb54
|
@ -21,17 +21,23 @@ export default class Searchbar extends Component {
|
|||
constructor($element, $) {
|
||||
super($element, $);
|
||||
this.searchState = '.';
|
||||
this.autoState = true;
|
||||
|
||||
let criteria = {};
|
||||
this.deregisterCallback = this.$transitions.onSuccess(
|
||||
criteria, () => this.onStateChange());
|
||||
{}, transition => this.onStateChange(transition));
|
||||
}
|
||||
|
||||
$postLink() {
|
||||
this.onStateChange();
|
||||
if (this.autoState) {
|
||||
if (!this.baseState) {
|
||||
let stateParts = this.$state.current.name.split('.');
|
||||
this.baseState = stateParts[0];
|
||||
}
|
||||
|
||||
if (this.$state.is(this.searchState) && this.filter !== null)
|
||||
this.doSearch();
|
||||
this.searchState = `${this.baseState}.index`;
|
||||
}
|
||||
|
||||
this.fetchStateFilter(this.autoLoad);
|
||||
}
|
||||
|
||||
$onDestroy() {
|
||||
|
@ -62,11 +68,18 @@ export default class Searchbar extends Component {
|
|||
if (value == null) this.params = [];
|
||||
}
|
||||
|
||||
onStateChange() {
|
||||
let filter = null;
|
||||
let isIndex = this.$state.is(this.searchState);
|
||||
onStateChange(transition) {
|
||||
if (!this.element.parentNode
|
||||
|| transition == this.transition)
|
||||
return;
|
||||
|
||||
this.fetchStateFilter();
|
||||
}
|
||||
|
||||
fetchStateFilter(autoLoad) {
|
||||
if (this.$state.is(this.searchState)) {
|
||||
let filter = null;
|
||||
|
||||
if (isIndex) {
|
||||
if (this.$params.q) {
|
||||
try {
|
||||
filter = JSON.parse(this.$params.q);
|
||||
|
@ -75,15 +88,12 @@ export default class Searchbar extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
focus(this.element.querySelector('vn-textfield input'));
|
||||
}
|
||||
if (!filter && autoLoad)
|
||||
filter = {};
|
||||
|
||||
this.filter = filter;
|
||||
|
||||
if (isIndex)
|
||||
this.doSearch();
|
||||
else if (this.model)
|
||||
this.model.clear();
|
||||
this.doSearch(filter, 'state');
|
||||
} else
|
||||
this.clearSearch();
|
||||
}
|
||||
|
||||
openPanel(event) {
|
||||
|
@ -112,21 +122,16 @@ export default class Searchbar extends Component {
|
|||
this.$.popover.hide();
|
||||
filter = compact(filter);
|
||||
filter = filter != null ? filter : {};
|
||||
this.goSearch(filter);
|
||||
this.doSearch(filter, 'panel');
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
this.goSearch(this.fromBar());
|
||||
this.doSearch(this.fromBar(), 'bar');
|
||||
}
|
||||
|
||||
removeParam(index) {
|
||||
this.params.splice(index, 1);
|
||||
this.goSearch(this.fromBar());
|
||||
}
|
||||
|
||||
goSearch(filter) {
|
||||
this.filter = filter;
|
||||
this.doSearch();
|
||||
this.doSearch(this.fromBar(), 'bar');
|
||||
}
|
||||
|
||||
fromBar() {
|
||||
|
@ -180,75 +185,94 @@ export default class Searchbar extends Component {
|
|||
});
|
||||
}
|
||||
|
||||
doSearch() {
|
||||
let filter = this.filter;
|
||||
if (filter == null && this.autoload)
|
||||
filter = {};
|
||||
|
||||
if (this.onSearch)
|
||||
this.onSearch({$params: filter});
|
||||
|
||||
if (this.model) {
|
||||
if (filter !== null) {
|
||||
let where = buildFilter(filter,
|
||||
(param, value) => this.exprBuilder({param, value}));
|
||||
|
||||
let userParams = {};
|
||||
let hasParams = false;
|
||||
|
||||
if (this.paramBuilder) {
|
||||
for (let param in filter) {
|
||||
let value = filter[param];
|
||||
if (value == null) continue;
|
||||
let expr = this.paramBuilder({param, value});
|
||||
if (expr) {
|
||||
Object.assign(userParams, expr);
|
||||
hasParams = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.model.applyFilter(
|
||||
where ? {where} : null,
|
||||
hasParams ? userParams : null
|
||||
).then(() => this.onModelFilter());
|
||||
} else
|
||||
this.model.clear();
|
||||
}
|
||||
clearSearch() {
|
||||
if (!this.filter) return;
|
||||
if (this.model) this.model.clear();
|
||||
this.filter = null;
|
||||
}
|
||||
|
||||
onModelFilter() {
|
||||
doSearch(filter, source) {
|
||||
let promise;
|
||||
|
||||
if (this.model)
|
||||
promise = this.modelSearch(filter);
|
||||
else if (this.onSearch)
|
||||
promise = this.onSearch({$params: filter});
|
||||
|
||||
promise = promise || this.$q.resolve();
|
||||
promise.then(data => this.onFilter(filter, source, data));
|
||||
}
|
||||
|
||||
modelSearch(filter) {
|
||||
if (filter === null) {
|
||||
this.model.clear();
|
||||
return this.$q.resolve();
|
||||
}
|
||||
|
||||
let where = null;
|
||||
let params = null;
|
||||
|
||||
if (this.exprBuilder) {
|
||||
where = buildFilter(filter,
|
||||
(param, value) => this.exprBuilder({param, value}));
|
||||
} else {
|
||||
params = Object.assign({}, filter);
|
||||
|
||||
if (this.fetchParams)
|
||||
params = this.fetchParams({$params: params});
|
||||
}
|
||||
|
||||
return this.model.applyFilter(where ? {where} : null, params)
|
||||
.then(() => this.model.data);
|
||||
}
|
||||
|
||||
onFilter(filter, source, data) {
|
||||
let state;
|
||||
let params;
|
||||
let opts;
|
||||
let data = this.model.data;
|
||||
let currentState = this.$state.current.name;
|
||||
let stateParts = currentState.split('.');
|
||||
let baseState = stateParts[0];
|
||||
let subState = stateParts[1];
|
||||
|
||||
if (this.goState && data && data.length == 1) {
|
||||
if (data && data.length == 1 && this.autoState && source != 'state') {
|
||||
let baseDepth = this.baseState.split('.').length;
|
||||
let stateParts = this.$state.current.name
|
||||
.split('.')
|
||||
.slice(baseDepth);
|
||||
|
||||
let subState = stateParts[0];
|
||||
|
||||
switch (subState) {
|
||||
case 'index':
|
||||
subState = 'card.summary';
|
||||
break;
|
||||
case 'card':
|
||||
subState += `.${stateParts[2]}`;
|
||||
subState += `.${stateParts[1]}`;
|
||||
if (stateParts.length >= 3)
|
||||
subState += '.index';
|
||||
break;
|
||||
default:
|
||||
subState = 'card.summary';
|
||||
}
|
||||
|
||||
if (this.goStateParams)
|
||||
params = this.goStateParams({$row: data[0]});
|
||||
if (this.singleParams)
|
||||
params = this.singleParams({$row: data[0]});
|
||||
|
||||
state = `${this.baseState}.${subState}`;
|
||||
filter = null;
|
||||
} else {
|
||||
if (subState == 'index')
|
||||
state = this.searchState;
|
||||
|
||||
if (filter)
|
||||
params = {q: JSON.stringify(filter)};
|
||||
if (this.$state.is(state))
|
||||
opts = {location: 'replace'};
|
||||
subState = `index`;
|
||||
params = {q: JSON.stringify(this.filter)};
|
||||
}
|
||||
|
||||
this.$state.go(`${baseState}.${subState}`, params, opts);
|
||||
this.filter = filter;
|
||||
|
||||
if (source != 'state')
|
||||
this.transition = this.$state.go(state, params, opts).transition;
|
||||
if (source != 'bar')
|
||||
focus(this.element.querySelector('vn-textfield input'));
|
||||
}
|
||||
|
||||
exprBuilder(param, value) {
|
||||
return {[param]: value};
|
||||
singleParams(params) {
|
||||
return {id: params.$row.id};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -256,27 +280,29 @@ ngModule.vnComponent('vnSearchbar', {
|
|||
controller: Searchbar,
|
||||
template: require('./searchbar.html'),
|
||||
bindings: {
|
||||
searchState: '@?',
|
||||
filter: '<?',
|
||||
suggestedFilter: '<?',
|
||||
panel: '@',
|
||||
info: '@?',
|
||||
model: '<?',
|
||||
onSearch: '&?',
|
||||
model: '<?',
|
||||
exprBuilder: '&?',
|
||||
paramBuilder: '&?',
|
||||
goState: '@?',
|
||||
goStateParams: '&?'
|
||||
baseState: '@?',
|
||||
autoState: '<?',
|
||||
singleParams: '&?',
|
||||
fetchParams: '&?'
|
||||
}
|
||||
});
|
||||
|
||||
class AutoSearch {
|
||||
constructor(vnSlotService) {
|
||||
let searchbar = vnSlotService.getContent('topbar');
|
||||
if (searchbar && searchbar.$ctrl instanceof Searchbar) {
|
||||
this.vnSlotService = vnSlotService;
|
||||
}
|
||||
|
||||
$postLink() {
|
||||
let searchbar = this.vnSlotService.getContent('topbar');
|
||||
if (searchbar && searchbar.$ctrl instanceof Searchbar)
|
||||
this.model = searchbar.$ctrl.model;
|
||||
console.log(this.model.data);
|
||||
}
|
||||
}
|
||||
}
|
||||
AutoSearch.$inject = ['vnSlotService'];
|
||||
|
|
|
@ -67,7 +67,7 @@ export function config($translatePartialLoaderProvider, $httpProvider, $compileP
|
|||
.cssClassDirectivesEnabled(false);
|
||||
|
||||
let env = process.env.NODE_ENV;
|
||||
if (!env || env == 'development')
|
||||
if (env && env !== 'development')
|
||||
$compileProvider.debugInfoEnabled(false);
|
||||
}
|
||||
ngModule.config(config);
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="Claims/filter"
|
||||
limit="20"
|
||||
data="claims"
|
||||
order="claimStateFk ASC, created DESC"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-auto-search
|
||||
on-search="$ctrl.onSearch($params)">
|
||||
model="model">
|
||||
</vn-auto-search>
|
||||
<vn-data-viewer
|
||||
model="model"
|
||||
|
@ -26,7 +18,7 @@
|
|||
</vn-thead>
|
||||
<vn-tbody>
|
||||
<a
|
||||
ng-repeat="claim in claims"
|
||||
ng-repeat="claim in model.data"
|
||||
class="{{::$ctrl.compareDate(ticket.shipped)}} clickable vn-tr search-result"
|
||||
ui-sref="claim.card.summary({id: claim.id})">
|
||||
<vn-td number>{{::claim.id}}</vn-td>
|
||||
|
|
|
@ -43,13 +43,6 @@ export default class Controller {
|
|||
onDescriptorLoad() {
|
||||
this.$.popover.relocate();
|
||||
}
|
||||
|
||||
onSearch(params) {
|
||||
if (params)
|
||||
this.$.model.applyFilter(null, params);
|
||||
else
|
||||
this.$.model.clear();
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$scope'];
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="Claims/filter"
|
||||
limit="20"
|
||||
order="claimStateFk ASC, created DESC"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-portal slot="topbar">
|
||||
<vn-searchbar
|
||||
search-state="claim.index"
|
||||
panel="vn-claim-search-panel"
|
||||
info="Search claim by id or client name">
|
||||
info="Search claim by id or client name"
|
||||
model="model">
|
||||
</vn-searchbar>
|
||||
</vn-portal>
|
||||
<vn-portal slot="menu">
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="Clients"
|
||||
order="id DESC"
|
||||
limit="8"
|
||||
data="clients">
|
||||
</vn-crud-model>
|
||||
|
||||
<vn-auto-search
|
||||
model="model"
|
||||
expr-builder="$ctrl.exprBuilder(param, value)">
|
||||
model="model">
|
||||
</vn-auto-search>
|
||||
<vn-data-viewer
|
||||
model="model"
|
||||
|
@ -15,7 +8,7 @@
|
|||
<vn-card>
|
||||
<div class="vn-list separated">
|
||||
<a
|
||||
ng-repeat="client in clients track by client.id"
|
||||
ng-repeat="client in model.data track by client.id"
|
||||
ui-sref="client.card.summary(::{id: client.id})"
|
||||
translate-attr="{title: 'View client'}"
|
||||
class="vn-item search-result">
|
||||
|
|
|
@ -7,33 +7,6 @@ export default class Controller {
|
|||
this.clientSelected = null;
|
||||
}
|
||||
|
||||
exprBuilder(param, value) {
|
||||
switch (param) {
|
||||
case 'search':
|
||||
return /^\d+$/.test(value)
|
||||
? {id: value}
|
||||
: {name: {like: `%${value}%`}};
|
||||
case 'phone':
|
||||
return {
|
||||
or: [
|
||||
{phone: value},
|
||||
{mobile: value}
|
||||
]
|
||||
};
|
||||
case 'name':
|
||||
case 'socialName':
|
||||
case 'city':
|
||||
return {[param]: {like: `%${value}%`}};
|
||||
case 'email':
|
||||
return {[param]: {like: `%${value}%`}};
|
||||
case 'id':
|
||||
case 'fi':
|
||||
case 'postcode':
|
||||
case 'salesPersonFk':
|
||||
return {[param]: value};
|
||||
}
|
||||
}
|
||||
|
||||
openSummary(client, event) {
|
||||
if (event.defaultPrevented) return;
|
||||
event.preventDefault();
|
||||
|
|
|
@ -1,8 +1,16 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="Clients"
|
||||
order="id DESC"
|
||||
limit="8"
|
||||
data="clients">
|
||||
</vn-crud-model>
|
||||
<vn-portal slot="topbar">
|
||||
<vn-searchbar
|
||||
search-state="client.index"
|
||||
panel="vn-client-search-panel"
|
||||
info="Search client by id or name">
|
||||
info="Search client by id or name"
|
||||
model="model"
|
||||
expr-builder="$ctrl.exprBuilder(param, value)">
|
||||
</vn-searchbar>
|
||||
</vn-portal>
|
||||
<vn-portal slot="menu">
|
||||
|
|
|
@ -1,7 +1,33 @@
|
|||
import ngModule from '../module';
|
||||
import ModuleMain from 'salix/components/module-main';
|
||||
|
||||
export default class Client extends ModuleMain {}
|
||||
export default class Client extends ModuleMain {
|
||||
exprBuilder(param, value) {
|
||||
switch (param) {
|
||||
case 'search':
|
||||
return /^\d+$/.test(value)
|
||||
? {id: value}
|
||||
: {name: {like: `%${value}%`}};
|
||||
case 'phone':
|
||||
return {
|
||||
or: [
|
||||
{phone: value},
|
||||
{mobile: value}
|
||||
]
|
||||
};
|
||||
case 'name':
|
||||
case 'socialName':
|
||||
case 'city':
|
||||
case 'email':
|
||||
return {[param]: {like: `%${value}%`}};
|
||||
case 'id':
|
||||
case 'fi':
|
||||
case 'postcode':
|
||||
case 'salesPersonFk':
|
||||
return {[param]: value};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnClient', {
|
||||
controller: Client,
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="Entries/filter"
|
||||
limit="20"
|
||||
params="::$ctrl.params"
|
||||
data="entries"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-auto-search
|
||||
on-search="$ctrl.onSearch($params)">
|
||||
model="model">
|
||||
</vn-auto-search>
|
||||
<vn-data-viewer
|
||||
model="model"
|
||||
|
@ -30,7 +22,7 @@
|
|||
</vn-tr>
|
||||
</vn-thead>
|
||||
<vn-tbody>
|
||||
<a ng-repeat="entry in entries"
|
||||
<a ng-repeat="entry in model.data"
|
||||
class="clickable vn-tr search-result"
|
||||
ui-sref="entry.card.summary({id: {{::entry.id}}})">
|
||||
<vn-td shrink>
|
||||
|
|
|
@ -5,13 +5,6 @@ export default class Controller {
|
|||
this.$ = $scope;
|
||||
}
|
||||
|
||||
onSearch(params) {
|
||||
if (params)
|
||||
this.$.model.applyFilter(null, params);
|
||||
else
|
||||
this.$.model.clear();
|
||||
}
|
||||
|
||||
showTravelDescriptor(event, travelFk) {
|
||||
if (event.defaultPrevented) return;
|
||||
event.preventDefault();
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="Entries/filter"
|
||||
limit="20"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-portal slot="topbar">
|
||||
<vn-searchbar
|
||||
search-state="entry.index"
|
||||
panel="vn-entry-search-panel"
|
||||
info="Search entrys by id">
|
||||
info="Search entrys by id"
|
||||
model="model">
|
||||
</vn-searchbar>
|
||||
</vn-portal>
|
||||
<vn-portal slot="menu">
|
||||
|
|
|
@ -1,16 +1,9 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="InvoiceOuts/filter"
|
||||
limit="20"
|
||||
data="invoiceOuts"
|
||||
order="issued DESC">
|
||||
</vn-crud-model>
|
||||
<vn-auto-search
|
||||
on-search="$ctrl.onSearch($params)">
|
||||
model="model">
|
||||
</vn-auto-search>
|
||||
<vn-data-viewer
|
||||
model="model"
|
||||
class="vn-w-md vn-my-md">
|
||||
class="vn-w-md">
|
||||
<vn-card>
|
||||
<vn-table model="model">
|
||||
<vn-thead>
|
||||
|
@ -27,7 +20,7 @@
|
|||
</vn-tr>
|
||||
</vn-thead>
|
||||
<vn-tbody>
|
||||
<a ng-repeat="invoiceOut in invoiceOuts"
|
||||
<a ng-repeat="invoiceOut in model.data"
|
||||
class="clickable vn-tr search-result"
|
||||
ui-sref="invoiceOut.card.summary({id: {{::invoiceOut.id}}})">
|
||||
<vn-td>{{::invoiceOut.ref | dashIfEmpty}}</vn-td>
|
||||
|
|
|
@ -32,13 +32,6 @@ export default class Controller {
|
|||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
}
|
||||
|
||||
onSearch(params) {
|
||||
if (params)
|
||||
this.$.model.applyFilter(null, params);
|
||||
else
|
||||
this.$.model.clear();
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$scope', 'vnToken'];
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="InvoiceOuts/filter"
|
||||
limit="20"
|
||||
order="issued DESC">
|
||||
</vn-crud-model>
|
||||
<vn-portal slot="topbar">
|
||||
<vn-searchbar
|
||||
search-state="invoiceOut.index"
|
||||
panel="vn-invoice-search-panel"
|
||||
info="Search invoices by reference">
|
||||
info="Search invoices by reference"
|
||||
model="model">
|
||||
</vn-searchbar>
|
||||
</vn-portal>
|
||||
<vn-portal slot="menu">
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="Items/filter"
|
||||
limit="12"
|
||||
order="isActive DESC, name, id"
|
||||
data="items">
|
||||
</vn-crud-model>
|
||||
<vn-auto-search
|
||||
on-search="$ctrl.onSearch($params)">
|
||||
model="model">
|
||||
</vn-auto-search>
|
||||
<vn-data-viewer
|
||||
model="model"
|
||||
|
@ -37,7 +30,7 @@
|
|||
</vn-tr>
|
||||
</vn-thead>
|
||||
<vn-tbody>
|
||||
<a ng-repeat="item in items"
|
||||
<a ng-repeat="item in model.data"
|
||||
class="clickable vn-tr search-result"
|
||||
ui-sref="item.card.summary({id: item.id})">
|
||||
<vn-td shrink>
|
||||
|
|
|
@ -21,13 +21,6 @@ class Controller {
|
|||
event.stopImmediatePropagation();
|
||||
}
|
||||
|
||||
onSearch(params) {
|
||||
if (params)
|
||||
this.$.model.applyFilter(null, params);
|
||||
else
|
||||
this.$.model.clear();
|
||||
}
|
||||
|
||||
showItemDescriptor(event, itemFk) {
|
||||
if (event.defaultPrevented) return;
|
||||
|
||||
|
@ -39,7 +32,6 @@ class Controller {
|
|||
this.$.itemDescriptor.show();
|
||||
}
|
||||
|
||||
|
||||
showWorkerDescriptor(event, workerFk) {
|
||||
if (event.defaultPrevented) return;
|
||||
|
||||
|
|
|
@ -1,9 +1,16 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="Items/filter"
|
||||
limit="12"
|
||||
order="isActive DESC, name, id"
|
||||
data="items">
|
||||
</vn-crud-model>
|
||||
<vn-portal slot="topbar">
|
||||
<vn-searchbar
|
||||
search-state="item.index"
|
||||
panel="vn-item-search-panel"
|
||||
info="Search items by id, name or barcode"
|
||||
suggested-filter="{isActive: true}">
|
||||
suggested-filter="{isActive: true}"
|
||||
model="model">
|
||||
</vn-searchbar>
|
||||
</vn-portal>
|
||||
<vn-portal slot="menu">
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="Orders/filter"
|
||||
limit="20"
|
||||
data="orders"
|
||||
order="landed DESC, clientFk">
|
||||
</vn-crud-model>
|
||||
|
||||
<vn-auto-search
|
||||
on-search="$ctrl.onSearch($params)">
|
||||
model="model">
|
||||
</vn-auto-search>
|
||||
<vn-data-viewer
|
||||
model="model"
|
||||
|
@ -27,8 +21,10 @@
|
|||
</vn-tr>
|
||||
</vn-thead>
|
||||
<vn-tbody>
|
||||
<vn-tr ng-repeat="order in orders" class="clickable search-result"
|
||||
ui-sref="order.card.summary({id: {{::order.id}}})">
|
||||
<vn-tr
|
||||
ng-repeat="order in model.data"
|
||||
class="clickable search-result"
|
||||
ui-sref="order.card.summary({id: {{::order.id}}})">
|
||||
<vn-td number>{{::order.id}}</vn-td>
|
||||
<vn-td expand>
|
||||
<span class="link" ng-click="$ctrl.showClientDescriptor($event, order.clientFk)">
|
||||
|
|
|
@ -8,13 +8,6 @@ export default class Controller {
|
|||
this.ticketSelected = null;
|
||||
}
|
||||
|
||||
onSearch(params) {
|
||||
if (params)
|
||||
this.$.model.applyFilter(null, params);
|
||||
else
|
||||
this.$.model.clear();
|
||||
}
|
||||
|
||||
showClientDescriptor(event, clientFk) {
|
||||
this.$.clientDescriptor.clientFk = clientFk;
|
||||
this.$.clientDescriptor.parent = event.target;
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="Orders/filter"
|
||||
limit="20"
|
||||
data="orders"
|
||||
order="landed DESC, clientFk">
|
||||
</vn-crud-model>
|
||||
<vn-portal slot="topbar">
|
||||
<vn-searchbar
|
||||
search-state="order.index"
|
||||
panel="vn-order-search-panel"
|
||||
info="Search orders by id">
|
||||
info="Search orders by id"
|
||||
model="model">
|
||||
</vn-searchbar>
|
||||
</vn-portal>
|
||||
<vn-portal slot="menu">
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="Routes/filter"
|
||||
limit="20"
|
||||
data="routes"
|
||||
order="created DESC"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-auto-search
|
||||
on-search="$ctrl.onSearch($params)">
|
||||
model="model">
|
||||
</vn-auto-search>
|
||||
<vn-data-viewer
|
||||
model="model"
|
||||
|
@ -27,7 +19,7 @@
|
|||
</vn-tr>
|
||||
</vn-thead>
|
||||
<vn-tbody>
|
||||
<a ng-repeat="route in routes"
|
||||
<a ng-repeat="route in model.data"
|
||||
class="clickable vn-tr search-result"
|
||||
ui-sref="route.card.summary({id: {{::route.id}}})">
|
||||
<vn-td number>{{::route.id | dashIfEmpty}}</vn-td>
|
||||
|
|
|
@ -24,13 +24,6 @@ export default class Controller {
|
|||
this.routeSelected = route;
|
||||
this.$.summary.show();
|
||||
}
|
||||
|
||||
onSearch(params) {
|
||||
if (params)
|
||||
this.$.model.applyFilter(null, params);
|
||||
else
|
||||
this.$.model.clear();
|
||||
}
|
||||
}
|
||||
Controller.$inject = ['$scope', 'vnToken'];
|
||||
|
||||
|
|
|
@ -1,9 +1,16 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="Routes/filter"
|
||||
limit="20"
|
||||
order="created DESC"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-portal slot="topbar">
|
||||
<vn-searchbar
|
||||
search-state="route.index"
|
||||
panel="vn-route-search-panel"
|
||||
info="Search routes by id"
|
||||
filter="$ctrl.filter">
|
||||
filter="$ctrl.filter"
|
||||
model="model">
|
||||
</vn-searchbar>
|
||||
</vn-portal>
|
||||
<vn-portal slot="menu">
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="Tickets/filter"
|
||||
limit="20"
|
||||
params="::$ctrl.params"
|
||||
data="tickets"
|
||||
order="shipped DESC, zoneHour ASC, zoneMinute ASC, clientFk">
|
||||
</vn-crud-model>
|
||||
<vn-auto-search
|
||||
on-search="$ctrl.onSearch($params)">
|
||||
model="model">
|
||||
<append style="display: none;">
|
||||
<vn-icon-menu
|
||||
vn-id="more-button"
|
||||
|
@ -49,7 +41,7 @@
|
|||
</vn-tr>
|
||||
</vn-thead>
|
||||
<vn-tbody>
|
||||
<a ng-repeat="ticket in tickets"
|
||||
<a ng-repeat="ticket in model.data"
|
||||
class="clickable vn-tr search-result"
|
||||
ui-sref="ticket.card.summary({id: {{::ticket.id}}})">
|
||||
<vn-td shrink>
|
||||
|
|
|
@ -38,30 +38,6 @@ export default class Controller {
|
|||
this.$.balanceCreateDialog.description += description.join(', ');
|
||||
}
|
||||
|
||||
getScopeDates(days) {
|
||||
const today = new Date();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
|
||||
const daysOnward = new Date(today);
|
||||
daysOnward.setDate(today.getDate() + days);
|
||||
daysOnward.setHours(23, 59, 59, 999);
|
||||
|
||||
return {from: today, to: daysOnward};
|
||||
}
|
||||
|
||||
onSearch(params) {
|
||||
if (params) {
|
||||
if (typeof(params.scopeDays) === 'number')
|
||||
Object.assign(params, this.getScopeDates(params.scopeDays));
|
||||
// Set default params to 1 scope days
|
||||
else if (Object.entries(params).length == 0)
|
||||
params = this.getScopeDates(1);
|
||||
|
||||
this.$.model.applyFilter(null, params);
|
||||
} else
|
||||
this.$.model.clear();
|
||||
}
|
||||
|
||||
goToLines(event, ticketFk) {
|
||||
this.preventDefault(event);
|
||||
let url = this.$state.href('ticket.card.sale', {id: ticketFk}, {absolute: true});
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="Tickets/filter"
|
||||
limit="20"
|
||||
order="shipped DESC, zoneHour ASC, zoneMinute ASC, clientFk">
|
||||
</vn-crud-model>
|
||||
<vn-portal slot="topbar">
|
||||
<vn-searchbar
|
||||
search-state="ticket.index"
|
||||
panel="vn-ticket-search-panel"
|
||||
info="Search ticket by id or alias">
|
||||
info="Search ticket by id or alias"
|
||||
model="model"
|
||||
fetch-params="$ctrl.fetchParams($params)">
|
||||
</vn-searchbar>
|
||||
</vn-portal>
|
||||
<vn-portal slot="menu">
|
||||
|
|
|
@ -1,7 +1,25 @@
|
|||
import ngModule from '../module';
|
||||
import ModuleMain from 'salix/components/module-main';
|
||||
|
||||
export default class Ticket extends ModuleMain {}
|
||||
export default class Ticket extends ModuleMain {
|
||||
fetchParams($params) {
|
||||
if (!Object.entries($params).length)
|
||||
$params.scopeDays = 1;
|
||||
|
||||
if (typeof $params.scopeDays === 'number') {
|
||||
const from = new Date();
|
||||
from.setHours(0, 0, 0, 0);
|
||||
|
||||
const to = new Date(from.getTime());
|
||||
to.setDate(to.getDate() + $params.scopeDays);
|
||||
to.setHours(23, 59, 59, 999);
|
||||
|
||||
Object.assign($params, {from, to});
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnTicket', {
|
||||
controller: Ticket,
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="Travels/filter"
|
||||
limit="20"
|
||||
params="::$ctrl.params"
|
||||
data="travels"
|
||||
order="shipped DESC, landed DESC">
|
||||
</vn-crud-model>
|
||||
|
||||
<vn-auto-search
|
||||
on-search="$ctrl.onSearch($params)">
|
||||
model="model">
|
||||
</vn-auto-search>
|
||||
<vn-data-viewer
|
||||
model="model"
|
||||
|
|
|
@ -12,29 +12,6 @@ export default class Controller {
|
|||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
}
|
||||
|
||||
getScopeDates(days) {
|
||||
const today = new Date();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
const daysOnward = new Date(today);
|
||||
daysOnward.setDate(today.getDate() + days);
|
||||
daysOnward.setHours(23, 59, 59, 999);
|
||||
return {shippedFrom: today, shippedTo: daysOnward};
|
||||
}
|
||||
|
||||
onSearch(params) {
|
||||
if (params) {
|
||||
let newParams = params;
|
||||
if (params.scopeDays) {
|
||||
const scopeDates = this.getScopeDates(params.scopeDays);
|
||||
Object.assign(newParams, scopeDates);
|
||||
} else if (Object.entries(params).length == 0)
|
||||
newParams = this.getScopeDates(1);
|
||||
|
||||
this.$.model.applyFilter(null, newParams);
|
||||
} else
|
||||
this.$.model.clear();
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$scope'];
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="Travels/filter"
|
||||
limit="20"
|
||||
order="shipped DESC, landed DESC">
|
||||
</vn-crud-model>
|
||||
<vn-portal slot="topbar">
|
||||
<vn-searchbar
|
||||
search-state="travel.index"
|
||||
panel="vn-travel-search-panel"
|
||||
info="Search travels by id">
|
||||
info="Search travels by id"
|
||||
model="model"
|
||||
fetch-params="$ctrl.fetchParams($params)">
|
||||
</vn-searchbar>
|
||||
</vn-portal>
|
||||
<vn-portal slot="menu">
|
||||
|
|
|
@ -1,7 +1,25 @@
|
|||
import ngModule from '../module';
|
||||
import ModuleMain from 'salix/components/module-main';
|
||||
|
||||
export default class Travel extends ModuleMain {}
|
||||
export default class Travel extends ModuleMain {
|
||||
fetchParams($params) {
|
||||
if (!Object.entries($params).length)
|
||||
$params.scopeDays = 1;
|
||||
|
||||
if (typeof $params.scopeDays === 'number') {
|
||||
const shippedFrom = new Date();
|
||||
shippedFrom.setHours(0, 0, 0, 0);
|
||||
|
||||
const shippedTo = new Date(shippedFrom.getTime());
|
||||
shippedTo.setDate(shippedTo.getDate() + $params.scopeDays);
|
||||
shippedTo.setHours(23, 59, 59, 999);
|
||||
|
||||
Object.assign($params, {shippedFrom, shippedTo});
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.vnComponent('vnTravel', {
|
||||
controller: Travel,
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="Workers/filter"
|
||||
limit="20"
|
||||
order="id"
|
||||
data="workers">
|
||||
</vn-crud-model>
|
||||
<vn-auto-search
|
||||
on-search="$ctrl.onSearch($params)">
|
||||
model="model">
|
||||
</vn-auto-search>
|
||||
<vn-data-viewer
|
||||
model="model"
|
||||
|
@ -14,7 +7,7 @@
|
|||
<vn-card>
|
||||
<div class="vn-list separated">
|
||||
<a
|
||||
ng-repeat="worker in workers track by worker.id"
|
||||
ng-repeat="worker in model.data track by worker.id"
|
||||
ui-sref="worker.card.summary({id: worker.id})"
|
||||
translate-attr="{title: 'View worker'}"
|
||||
class="vn-item search-result">
|
||||
|
|
|
@ -9,13 +9,6 @@ export default class Controller {
|
|||
});
|
||||
}
|
||||
|
||||
onSearch(params) {
|
||||
if (params)
|
||||
this.$.model.applyFilter(null, params);
|
||||
else
|
||||
this.$.model.clear();
|
||||
}
|
||||
|
||||
preview(event, worker) {
|
||||
if (event.defaultPrevented) return;
|
||||
|
||||
|
@ -26,7 +19,6 @@ export default class Controller {
|
|||
this.$.preview.show();
|
||||
}
|
||||
|
||||
|
||||
goToTimeControl(event, workerId) {
|
||||
if (event.defaultPrevented) return;
|
||||
|
||||
|
@ -34,6 +26,7 @@ export default class Controller {
|
|||
event.stopPropagation();
|
||||
this.$state.go('worker.card.timeControl', {id: workerId}, {absolute: true});
|
||||
}
|
||||
|
||||
onMoreChange(callback) {
|
||||
callback.call(this);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="Workers/filter"
|
||||
limit="20"
|
||||
order="id">
|
||||
</vn-crud-model>
|
||||
<vn-portal slot="topbar">
|
||||
<vn-searchbar
|
||||
search-state="worker.index"
|
||||
panel="vn-worker-search-panel"
|
||||
info="Search workers by id, firstName, lastName or user name">
|
||||
info="Search workers by id, firstName, lastName or user name"
|
||||
model="model">
|
||||
</vn-searchbar>
|
||||
</vn-portal>
|
||||
<vn-portal slot="menu">
|
||||
|
|
|
@ -4,25 +4,25 @@
|
|||
filter="::$ctrl.filter">
|
||||
</vn-crud-model>
|
||||
<vn-portal slot="topbar">
|
||||
<vn-searchbar></vn-searchbar>
|
||||
<vn-searchbar
|
||||
on-search="$ctrl.onSearch($params)"
|
||||
auto-state="false">
|
||||
</vn-searchbar>
|
||||
</vn-portal>
|
||||
<vn-auto-search
|
||||
on-search="$ctrl.onSearch($params)">
|
||||
</vn-auto-search>
|
||||
<div class="vn-w-md">
|
||||
<vn-card class="vn-pa-lg vn-mt-md">
|
||||
<vn-treeview
|
||||
vn-id="treeview"
|
||||
root-label="Locations"
|
||||
fetch-func="$ctrl.onFetch($item)"
|
||||
sort-func="$ctrl.onSort($a, $b)">
|
||||
<vn-check acl-role="deliveryBoss"
|
||||
ng-model="item.selected"
|
||||
on-change="$ctrl.onSelection(value, item)"
|
||||
triple-state="true"
|
||||
ng-click="$event.preventDefault()"
|
||||
label="{{::item.name}}">
|
||||
</vn-check>
|
||||
</vn-treeview>
|
||||
<vn-card class="vn-pa-lg">
|
||||
<vn-treeview
|
||||
vn-id="treeview"
|
||||
root-label="Locations"
|
||||
fetch-func="$ctrl.onFetch($item)"
|
||||
sort-func="$ctrl.onSort($a, $b)">
|
||||
<vn-check acl-role="deliveryBoss"
|
||||
ng-model="item.selected"
|
||||
on-change="$ctrl.onSelection(value, item)"
|
||||
triple-state="true"
|
||||
ng-click="$event.preventDefault()"
|
||||
label="{{::item.name}}">
|
||||
</vn-check>
|
||||
</vn-treeview>
|
||||
</vn-card>
|
||||
</div>
|
||||
|
|
|
@ -6,13 +6,10 @@
|
|||
</vn-crud-model>
|
||||
<vn-portal slot="topbar">
|
||||
<vn-searchbar
|
||||
search-state="zone.index"
|
||||
panel="vn-zone-search-panel"
|
||||
info="Search zone by id or name"
|
||||
panel="vn-zone-search-panel"
|
||||
model="model"
|
||||
expr-builder="$ctrl.exprBuilder(param, value)"
|
||||
go-state="zone.card.summary"
|
||||
go-state-params="{id: $row.id}">
|
||||
expr-builder="$ctrl.exprBuilder(param, value)">
|
||||
</vn-searchbar>
|
||||
</vn-portal>
|
||||
<vn-portal slot="menu">
|
||||
|
|
Loading…
Reference in New Issue