refs #5206 url gets params
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Alexandre Riera 2023-03-10 10:05:16 +01:00
parent ed5208c9e4
commit 874fd0656c
4 changed files with 95 additions and 115 deletions

View File

@ -26,6 +26,7 @@
<vn-th field="warehouseInFk">Warehouse In</vn-th>
<vn-th field="landed" center shrink-date>Landed</vn-th>
<vn-th shrink></vn-th>
<vn-th shrink field="totalEntries">Total entries</vn-th>
<vn-th shrink></vn-th>
</vn-tr>
</vn-thead>
@ -61,6 +62,7 @@
ng-class="{active: travel.isReceived}">
</vn-icon>
</vn-td>
<vn-td shrink>{{::travel.totalEntries}}</vn-td>
<vn-td shrink>
<vn-horizontal class="buttons">
<vn-icon-button

View File

@ -7,92 +7,77 @@
ng-keydown="$ctrl.onKeyPress($event, 'search')">
</vn-textfield>
</vn-horizontal>
<vn-horizontal class="input horizontal">
<vn-input-number
min="0"
label="Total entries"
ng-model="$ctrl.totalEntries"
ng-keydown="$ctrl.onKeyPress($event, 'totalEntries')">
</vn-input-number>
</vn-horizontal>
<vn-horizontal class="input horizontal">
<vn-autocomplete
vn-id="agency"
label="Agency"
ng-model="$ctrl.filter.agencyModeFk"
url="AgencyModes"
data="$ctrl.agencyModes"
show-field="name"
value-field="id"
on-change="$ctrl.addFilters()">
on-change="$ctrl.applyFilters()">
</vn-autocomplete>
<vn-autocomplete
vn-id="continent"
label="Continent Out"
ng-model="$ctrl.filter.continent"
url="Continents"
show-field="name"
value-field="code"
on-change="$ctrl.addFilters()">
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal class="horizontal">
<vn-date-picker
label="Shipped from"
ng-model="$ctrl.filter.shippedFrom"
on-change="$ctrl.changeShipped()">
</vn-date-picker>
<vn-date-picker
label="Shipped to"
ng-model="$ctrl.filter.shippedTo"
on-change="$ctrl.changeShipped()">
</vn-date-picker>
</vn-horizontal>
<vn-vertical class="input">
<vn-none class="or" translate>Or</vn-none>
<div class="scope-days">
<vn-input-number
min="0"
step="1"
label="Days onward"
ng-model="$ctrl.filter.scopeDays"
on-change="$ctrl.changeScopeDays()"
display-controls="true"
info="Cannot choose a range of dates and days onward at the same time">
</vn-input-number>
</div>
</vn-vertical>
<vn-horizontal class="input horizontal">
<vn-date-picker
label="Landed from"
ng-model="$ctrl.filter.landedFrom"
on-change="$ctrl.addFilters()">
</vn-date-picker>
<vn-date-picker
label="Landed to"
ng-model="$ctrl.filter.landedTo"
on-change="$ctrl.addFilters()">
</vn-date-picker>
</vn-horizontal>
<vn-horizontal class="input horizontal">
<vn-autocomplete
vn-id="warehouseOut"
label="Warehouse Out"
ng-model="$ctrl.filter.warehouseOutFk"
url="Warehouses"
data="$ctrl.warehouses"
show-field="name"
value-field="id"
on-change="$ctrl.addFilters()">
on-change="$ctrl.applyFilters()">
</vn-autocomplete>
<vn-autocomplete
vn-id="warehouseIn"
label="Warehouse In"
ng-model="$ctrl.filter.warehouseInFk"
url="Warehouses"
data="$ctrl.warehouses"
show-field="name"
value-field="id"
on-change="$ctrl.addFilters()">
on-change="$ctrl.applyFilters()">
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal class="input horizontal">
<vn-input-number
min="0"
step="1"
label="Days onward"
ng-model="$ctrl.filter.scopeDays"
on-change="$ctrl.applyFilters()"
display-controls="true"
info="Cannot choose a range of dates and days onward at the same time">
</vn-input-number>
</vn-horizontal>
<vn-horizontal class="input horizontal">
<vn-date-picker
label="Landed from"
ng-model="$ctrl.filter.landedFrom"
on-change="$ctrl.applyFilters()">
</vn-date-picker>
<vn-date-picker
label="Landed to"
ng-model="$ctrl.filter.landedTo"
on-change="$ctrl.applyFilters()">
</vn-date-picker>
</vn-horizontal>
<vn-horizontal class="input horizontal">
<vn-autocomplete
vn-id="continent"
label="Continent Out"
ng-model="$ctrl.filter.continent"
data="$ctrl.continents"
show-field="name"
value-field="code"
on-change="$ctrl.applyFilters()">
</vn-autocomplete>
<vn-input-number
min="0"
label="Total entries"
ng-model="$ctrl.totalEntries"
ng-keydown="$ctrl.onKeyPress($event, 'totalEntries')">
</vn-input-number>
</vn-horizontal>
<div class="chips">
<vn-chip
ng-if="$ctrl.filter.search"
@ -101,13 +86,6 @@
class="colored">
<span>Id/{{$ctrl.$t('Reference')}}: {{$ctrl.filter.search}}</span>
</vn-chip>
<vn-chip
ng-if="$ctrl.filter.totalEntries"
removable="true"
on-remove="$ctrl.removeParamFilter('totalEntries')"
class="colored">
<span>{{$ctrl.$t('Total entries')}}: {{$ctrl.filter.totalEntries}}</span>
</vn-chip>
<vn-chip
ng-if="agency.selection"
removable="true"
@ -116,25 +94,18 @@
<span>{{$ctrl.$t('Agency')}}: {{agency.selection.name}}</span>
</vn-chip>
<vn-chip
ng-if="continent.selection"
ng-if="warehouseOut.selection"
removable="true"
on-remove="$ctrl.removeParamFilter('continent')"
on-remove="$ctrl.removeParamFilter('warehouseOutFk')"
class="colored">
<span>{{$ctrl.$t('Continent Out')}}: {{continent.selection.name}}</span>
<span>{{$ctrl.$t('Warehouse Out')}}: {{warehouseOut.selection.name}}</span>
</vn-chip>
<vn-chip
ng-if="$ctrl.filter.shippedFrom"
ng-if="warehouseIn.selection"
removable="true"
on-remove="$ctrl.removeParamFilter('shippedFrom')"
on-remove="$ctrl.removeParamFilter('warehouseInFk')"
class="colored">
<span>{{$ctrl.$t('Shipped from')}}: {{$ctrl.filter.shippedFrom | date:'dd/MM/yyyy'}}</span>
</vn-chip>
<vn-chip
ng-if="$ctrl.filter.shippedTo"
removable="true"
on-remove="$ctrl.removeParamFilter('shippedTo')"
class="colored">
<span>{{$ctrl.$t('Shipped to')}}: {{$ctrl.filter.shippedTo | date:'dd/MM/yyyy'}}</span>
<span>{{$ctrl.$t('Warehouse In')}}: {{warehouseIn.selection.name}}</span>
</vn-chip>
<vn-chip
ng-if="$ctrl.filter.scopeDays"
@ -158,18 +129,18 @@
<span>{{$ctrl.$t('Landed to')}}: {{$ctrl.filter.landedTo | date:'dd/MM/yyyy'}}</span>
</vn-chip>
<vn-chip
ng-if="warehouseOut.selection"
ng-if="continent.selection"
removable="true"
on-remove="$ctrl.removeParamFilter('warehouseOutFk')"
on-remove="$ctrl.removeParamFilter('continent')"
class="colored">
<span>{{$ctrl.$t('Warehouse Out')}}: {{warehouseOut.selection.name}}</span>
<span>{{$ctrl.$t('Continent Out')}}: {{continent.selection.name}}</span>
</vn-chip>
<vn-chip
ng-if="warehouseIn.selection"
ng-if="$ctrl.filter.totalEntries"
removable="true"
on-remove="$ctrl.removeParamFilter('warehouseInFk')"
on-remove="$ctrl.removeParamFilter('totalEntries')"
class="colored">
<span>{{$ctrl.$t('Warehouse In')}}: {{warehouseIn.selection.name}}</span>
<span>{{$ctrl.$t('Total entries')}}: {{$ctrl.filter.totalEntries}}</span>
</vn-chip>
</div>
</vn-side-menu>

View File

@ -5,47 +5,59 @@ import './style.scss';
class Controller extends SearchPanel {
constructor($, $element) {
super($, $element);
this.filter = {
scopeDays: 1,
};
this.initFilter();
this.fetchData();
}
changeShipped() {
this.filter.scopeDays = null;
this.addFilters();
$onChanges() {
if (this.model)
this.applyFilters();
}
changeScopeDays() {
this.filter.shippedFrom = null;
this.filter.shippedTo = null;
this.addFilters();
fetchData() {
this.$http.get('AgencyModes').then(res => {
this.agencyModes = res.data;
});
this.$http.get('Warehouses').then(res => {
this.warehouses = res.data;
});
this.$http.get('Continents').then(res => {
this.continents = res.data;
});
}
addFilters(param) {
this.model.addFilter({}, this.filter)
initFilter() {
this.filter = {};
if (this.$params.q) {
this.filter = JSON.parse(this.$params.q);
this.search = this.filter.search;
this.totalEntries = this.filter.totalEntries;
}
if (!this.filter.scopeDays) this.filter.scopeDays = 7;
}
applyFilters(param) {
this.model.applyFilter({}, this.filter)
.then(() => {
if (param)
this.checkJustOneResult();
if (param && this.model._orgData.length === 1)
this.$state.go('travel.card.summary', {id: this.model._orgData[0].id});
else
this.$state.go(this.$state.current.name, {q: JSON.stringify(this.filter)}, {location: 'replace'});
});
}
removeParamFilter(param) {
if (this[param]) this[param] = null;
this.filter[param] = null;
this.addFilters();
if (this[param]) delete this[param];
delete this.filter[param];
this.applyFilters();
}
onKeyPress($event, param) {
if ($event.key === 'Enter') {
this.filter[param] = this[param];
this.addFilters(param === 'search');
this.applyFilters(param === 'search');
}
}
checkJustOneResult() {
if (this.model._orgData.length === 1)
this.$state.go('travel.card.summary', {id: this.model._orgData[0].id});
}
}
ngModule.vnComponent('vnTravelSearchPanel', {

View File

@ -33,10 +33,5 @@ vn-travel-search-panel vn-side-menu {
font-size: 26px;
color: $color-font-secondary;
}
.scope-days{
display: flex;
align-items: center;
}
}
}