Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 3521-Monitors_ticket_summary
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
3741417fd6
|
@ -171,9 +171,10 @@ export default class SmartTable extends Component {
|
|||
if (field.length === 2)
|
||||
sortType = field[1];
|
||||
|
||||
const priority = this.sortCriteria.length + 1;
|
||||
const column = this.columns.find(column => column.field == fieldName);
|
||||
if (column) {
|
||||
this.sortCriteria.push({field: fieldName, sortType: sortType});
|
||||
this.sortCriteria.push({field: fieldName, sortType: sortType, priority: priority});
|
||||
|
||||
const isASC = sortType == 'ASC';
|
||||
const isDESC = sortType == 'DESC';
|
||||
|
@ -187,6 +188,8 @@ export default class SmartTable extends Component {
|
|||
column.element.classList.remove('desc');
|
||||
column.element.classList.add('asc');
|
||||
}
|
||||
|
||||
this.setPriority(column.element, priority);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -241,9 +244,13 @@ export default class SmartTable extends Component {
|
|||
const isDESC = existingCriteria && existingCriteria.sortType == 'DESC';
|
||||
|
||||
if (!existingCriteria) {
|
||||
this.sortCriteria.push({field: field, sortType: 'ASC'});
|
||||
const priority = this.sortCriteria.length + 1;
|
||||
|
||||
this.sortCriteria.push({field: field, sortType: 'ASC', priority: priority});
|
||||
element.classList.remove('desc');
|
||||
element.classList.add('asc');
|
||||
|
||||
this.setPriority(element, priority);
|
||||
}
|
||||
|
||||
if (isDESC) {
|
||||
|
@ -252,6 +259,8 @@ export default class SmartTable extends Component {
|
|||
}), 1);
|
||||
element.classList.remove('desc');
|
||||
element.classList.remove('asc');
|
||||
|
||||
element.querySelector('sort-priority').remove();
|
||||
}
|
||||
|
||||
if (isASC) {
|
||||
|
@ -260,9 +269,29 @@ export default class SmartTable extends Component {
|
|||
element.classList.add('desc');
|
||||
}
|
||||
|
||||
let priority = 0;
|
||||
for (const criteria of this.sortCriteria) {
|
||||
const column = this.columns.find(column => column.field == criteria.field);
|
||||
if (column) {
|
||||
criteria.priority = priority;
|
||||
priority++;
|
||||
|
||||
column.element.querySelector('sort-priority').remove();
|
||||
|
||||
this.setPriority(column.element, priority);
|
||||
}
|
||||
}
|
||||
|
||||
this.applySort();
|
||||
}
|
||||
|
||||
setPriority(column, priority) {
|
||||
const sortPriority = document.createElement('sort-priority');
|
||||
sortPriority.setAttribute('class', 'sort-priority');
|
||||
sortPriority.innerHTML = priority;
|
||||
column.appendChild(sortPriority);
|
||||
}
|
||||
|
||||
displaySearch() {
|
||||
const header = this.element.querySelector('thead > tr');
|
||||
if (!header) return;
|
||||
|
|
|
@ -96,9 +96,10 @@ describe('Component smartTable', () => {
|
|||
|
||||
expect(firstSortCriteria.field).toEqual('id');
|
||||
expect(firstSortCriteria.sortType).toEqual('ASC');
|
||||
expect(firstSortCriteria.priority).toEqual(1);
|
||||
});
|
||||
|
||||
it('should insert two new objects to the controller sortCriteria with a sortType values of "ASC" and "DESC"', () => {
|
||||
it('should add new entries to the controller sortCriteria with a sortType values of "ASC" and "DESC"', () => {
|
||||
const element = document.createElement('div');
|
||||
controller.model = {order: 'test1, id DESC'};
|
||||
controller.columns = [
|
||||
|
@ -114,8 +115,11 @@ describe('Component smartTable', () => {
|
|||
|
||||
expect(firstSortCriteria.field).toEqual('test1');
|
||||
expect(firstSortCriteria.sortType).toEqual('ASC');
|
||||
expect(firstSortCriteria.priority).toEqual(1);
|
||||
|
||||
expect(secondSortCriteria.field).toEqual('id');
|
||||
expect(secondSortCriteria.sortType).toEqual('DESC');
|
||||
expect(secondSortCriteria.priority).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ smart-table {
|
|||
|
||||
}
|
||||
th[field][number] {
|
||||
& > :before {
|
||||
& > span:before {
|
||||
vertical-align: middle;
|
||||
font-family: 'Material Icons';
|
||||
content: 'arrow_downward';
|
||||
|
@ -19,26 +19,26 @@ smart-table {
|
|||
|
||||
}
|
||||
|
||||
&.asc > :before, &.desc > :before {
|
||||
&.asc > span:before, &.desc > span:before {
|
||||
color: $color-font;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
&.asc > :before {
|
||||
&.asc > span:before {
|
||||
content: 'arrow_upward';
|
||||
}
|
||||
|
||||
&.desc > :before {
|
||||
&.desc > span:before {
|
||||
content: 'arrow_downward';
|
||||
}
|
||||
|
||||
&:hover > :before {
|
||||
&:hover > span:before {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
th[field]:not([number]) {
|
||||
& > :after {
|
||||
& > span:after {
|
||||
vertical-align: middle;
|
||||
font-family: 'Material Icons';
|
||||
content: 'arrow_downward';
|
||||
|
@ -48,20 +48,20 @@ smart-table {
|
|||
|
||||
}
|
||||
|
||||
&.asc > :after, &.desc > :after {
|
||||
&.asc > span:after, &.desc > span:after {
|
||||
color: $color-font;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
&.asc > :after {
|
||||
&.asc > span:after {
|
||||
content: 'arrow_upward';
|
||||
}
|
||||
|
||||
&.desc > :after {
|
||||
&.desc > span:after {
|
||||
content: 'arrow_downward';
|
||||
}
|
||||
|
||||
&:hover > :after {
|
||||
&:hover > span:after {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
@ -143,4 +143,16 @@ smart-table {
|
|||
flex: initial;
|
||||
width: 33%
|
||||
}
|
||||
}
|
||||
.sort-priority {
|
||||
background-color: $color-font-bg-marginal;
|
||||
border-radius: 50%;
|
||||
padding: 2px 5px;
|
||||
display: inline-block;
|
||||
text-align: center;
|
||||
width: 7px;
|
||||
height: 13px;
|
||||
|
||||
font-size: 10px;
|
||||
color: $color-font-bg
|
||||
}
|
|
@ -119,5 +119,6 @@
|
|||
"The PDF document does not exists": "The PDF document does not exists. Try regenerating it from 'Regenerate invoice PDF' option",
|
||||
"This item is not available": "This item is not available",
|
||||
"Deny buy request": "Purchase request for ticket id [{{ticketId}}]({{{url}}}) has been rejected. Reason: {{observation}}",
|
||||
"The type of business must be filled in basic data": "The type of business must be filled in basic data"
|
||||
"The type of business must be filled in basic data": "The type of business must be filled in basic data",
|
||||
"The worker has hours recorded that day": "The worker has hours recorded that day"
|
||||
}
|
|
@ -35,6 +35,13 @@
|
|||
{{::agencyModeName}} - {{::warehouseInName}} ({{::shipped | date: 'dd/MM/yyyy'}}) →
|
||||
{{::warehouseOutName}} ({{::landed | date: 'dd/MM/yyyy'}})
|
||||
</tpl-item>
|
||||
<append>
|
||||
<vn-icon-button
|
||||
icon="filter_alt"
|
||||
vn-click-stop="$ctrl.showFilterDialog($ctrl.entry.travelFk)"
|
||||
vn-tooltip="Filter...">
|
||||
</vn-icon-button>
|
||||
</append>
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
|
@ -121,4 +128,94 @@
|
|||
ng-click="watcher.loadOriginalData()">
|
||||
</vn-button>
|
||||
</vn-button-bar>
|
||||
</form>
|
||||
</form>
|
||||
|
||||
<!-- Filter travel dialog -->
|
||||
<vn-dialog
|
||||
vn-id="filterDialog"
|
||||
message="Filter travel">
|
||||
<tpl-body class="travelFilter">
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete
|
||||
label="Agency"
|
||||
ng-model="$ctrl.travelFilterParams.agencyFk"
|
||||
url="AgencyModes"
|
||||
show-field="name"
|
||||
value-field="id">
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete
|
||||
label="Warehouse Out"
|
||||
ng-model="$ctrl.travelFilterParams.warehouseOutFk"
|
||||
url="Warehouses"
|
||||
show-field="name"
|
||||
value-field="id">
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete
|
||||
label="Warehouse In"
|
||||
ng-model="$ctrl.travelFilterParams.warehouseInFk"
|
||||
url="Warehouses"
|
||||
show-field="name"
|
||||
value-field="id">
|
||||
</vn-autocomplete>
|
||||
<vn-date-picker
|
||||
label="Shipped"
|
||||
ng-model="$ctrl.travelFilterParams.shipped">
|
||||
</vn-date-picker>
|
||||
<vn-date-picker
|
||||
label="Landed"
|
||||
ng-model="$ctrl.travelFilterParams.landed">
|
||||
</vn-date-picker>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal class="vn-mb-md">
|
||||
<vn-button vn-none
|
||||
label="Search"
|
||||
ng-click="$ctrl.filter()">
|
||||
</vn-button>
|
||||
</vn-horizontal>
|
||||
<vn-crud-model
|
||||
vn-id="travelsModel"
|
||||
url="Travels"
|
||||
filter="$ctrl.travelFilter"
|
||||
data="travels"
|
||||
limit="10">
|
||||
</vn-crud-model>
|
||||
<vn-data-viewer
|
||||
model="travelsModel"
|
||||
class="vn-w-lg">
|
||||
<vn-table class="scrollable">
|
||||
<vn-thead>
|
||||
<vn-tr>
|
||||
<vn-th shrink>ID</vn-th>
|
||||
<vn-th expand>Agency</vn-th>
|
||||
<vn-th expand>Warehouse Out</vn-th>
|
||||
<vn-th expand>Warehouse In</vn-th>
|
||||
<vn-th expand>Shipped</vn-th>
|
||||
<vn-th expand>Landed</vn-th>
|
||||
</vn-tr>
|
||||
</vn-thead>
|
||||
<vn-tbody>
|
||||
<a ng-repeat="travel in travels"
|
||||
class="clickable vn-tr search-result"
|
||||
ng-click="$ctrl.selectTravel(travel.id)">
|
||||
<vn-td shrink>
|
||||
<span
|
||||
vn-click-stop="travelDescriptor.show($event, travel.id)"
|
||||
class="link">
|
||||
{{::travel.id}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td expand>{{::travel.agency.name}}</vn-td>
|
||||
<vn-td expand>{{::travel.warehouseOut.name}}</vn-td>
|
||||
<vn-td expand>{{::travel.warehouseIn.name}}</vn-td>
|
||||
<vn-td expand>{{::travel.shipped | date: 'dd/MM/yyyy'}}</vn-td>
|
||||
<vn-td expand>{{::travel.landed | date: 'dd/MM/yyyy'}}</vn-td>
|
||||
</a>
|
||||
</vn-tbody>
|
||||
</vn-table>
|
||||
</vn-data-viewer>
|
||||
<vn-travel-descriptor-popover
|
||||
vn-id="travel-descriptor"
|
||||
warehouse-fk="$ctrl.vnConfig.warehouseFk">
|
||||
</vn-travel-descriptor-popover>
|
||||
</tpl-body>
|
||||
</vn-dialog>
|
|
@ -1,10 +1,68 @@
|
|||
import ngModule from '../module';
|
||||
import Section from 'salix/components/section';
|
||||
import './style.scss';
|
||||
|
||||
class Controller extends Section {
|
||||
showFilterDialog(travel) {
|
||||
this.activeTravel = travel;
|
||||
this.travelFilterParams = {};
|
||||
this.travelFilter = {
|
||||
include: [
|
||||
{
|
||||
relation: 'agency',
|
||||
scope: {
|
||||
fields: ['name']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'warehouseIn',
|
||||
scope: {
|
||||
fields: ['name']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'warehouseOut',
|
||||
scope: {
|
||||
fields: ['name']
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
this.$.filterDialog.show();
|
||||
}
|
||||
|
||||
selectTravel(id) {
|
||||
this.entry.travelFk = id;
|
||||
this.$.filterDialog.hide();
|
||||
}
|
||||
|
||||
filter() {
|
||||
const filter = this.travelFilter;
|
||||
const params = this.travelFilterParams;
|
||||
const where = {};
|
||||
for (let key in params) {
|
||||
const value = params[key];
|
||||
if (!value) continue;
|
||||
|
||||
switch (key) {
|
||||
case 'agencyFk':
|
||||
case 'warehouseInFk':
|
||||
case 'warehouseOutFk':
|
||||
case 'shipped':
|
||||
case 'landed':
|
||||
where[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
filter.where = where;
|
||||
this.$.travelsModel.applyFilter(filter);
|
||||
}
|
||||
}
|
||||
ngModule.vnComponent('vnEntryBasicData', {
|
||||
template: require('./index.html'),
|
||||
controller: Section,
|
||||
bindings: {
|
||||
entry: '<'
|
||||
}
|
||||
},
|
||||
controller: Controller
|
||||
});
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
.travelFilter{
|
||||
width: 950px;
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
vn-id="model"
|
||||
url="SalesMonitors/salesFilter"
|
||||
limit="20"
|
||||
order="shipped DESC, theoreticalHour, id">
|
||||
order="nickname">
|
||||
</vn-crud-model>
|
||||
<vn-portal slot="topbar">
|
||||
<vn-searchbar
|
||||
|
|
Loading…
Reference in New Issue