fixes #5174 Refactor ticket weekly to use smartTable #1275

Merged
pau merged 4 commits from 5174-refactor-ticket-weekly into dev 2023-02-03 07:41:28 +00:00
3 changed files with 150 additions and 88 deletions

View File

@ -562,15 +562,15 @@ export default {
payoutBank: '.vn-dialog vn-autocomplete[ng-model="$ctrl.bankFk"]',
payoutDescription: 'vn-textfield[ng-model="$ctrl.receipt.description"]',
submitPayout: '.vn-dialog button[response="accept"]',
searchWeeklyResult: 'vn-ticket-weekly-index vn-table vn-tbody > vn-tr',
searchWeeklyResult: 'vn-ticket-weekly-index vn-card smart-table slot-table table tbody tr',
searchResultDate: 'vn-ticket-summary [label=Landed] span',
topbarSearch: 'vn-searchbar',
moreMenu: 'vn-ticket-index vn-icon-button[icon=more_vert]',
fourthWeeklyTicket: 'vn-ticket-weekly-index vn-table vn-tbody vn-tr:nth-child(4)',
fiveWeeklyTicket: 'vn-ticket-weekly-index vn-table vn-tbody vn-tr:nth-child(5)',
weeklyTicket: 'vn-ticket-weekly-index vn-table > div > vn-tbody > vn-tr',
firstWeeklyTicketDeleteIcon: 'vn-ticket-weekly-index vn-tr:nth-child(1) vn-icon-button[icon="delete"]',
firstWeeklyTicketAgency: 'vn-ticket-weekly-index vn-tr:nth-child(1) [ng-model="weekly.agencyModeFk"]',
fourthWeeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(4)',
fiveWeeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(5)',
weeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table table tbody tr',
firstWeeklyTicketDeleteIcon: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(1) vn-icon-button[icon="delete"]',
firstWeeklyTicketAgency: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(1) [ng-model="weekly.agencyModeFk"]',
acceptDeleteTurn: '.vn-confirm.shown button[response="accept"]'
},
createTicketView: {

View File

@ -17,87 +17,110 @@
model="model">
</vn-searchbar>
</vn-portal>
<vn-data-viewer
model="model"
class="vn-w-xl">
<vn-card>
<vn-table model="model">
<vn-thead>
<vn-tr>
<vn-th field="ticketFk" number>Ticket ID</vn-th>
<vn-th field="clientName">Client</vn-th>
<vn-th>Shipment</vn-th>
<vn-th>Agency</vn-th>
<vn-th>Warehouse</vn-th>
<vn-th>Salesperson</vn-th>
<vn-th shrink></vn-th>
</vn-tr>
</vn-thead>
<vn-tbody>
<vn-tr
ng-repeat="weekly in weeklies"
ui-sref="ticket.card.summary({id: {{::weekly.ticketFk}}})"
class="clickable">
<vn-td number>
<span
vn-click-stop="ticketDescriptor.show($event, weekly.ticketFk)"
class="link">
{{weekly.ticketFk}}
</span>
</vn-td>
<vn-td>
<span
vn-click-stop="clientDescriptor.show($event, weekly.clientFk)"
title ="{{::weekly.clientName}}"
class="link">
{{::weekly.clientName}}
</span>
</vn-td>
<vn-td vn-click-stop>
<vn-autocomplete
vn-id="weekday"
ng-model="weekly.weekDay"
data="$ctrl.weekdays"
show-field="name"
translate-fields="['name']"
value-field="id"
on-change="$ctrl.onUpdate(weekly.ticketFk, 'weekDay', value)"
order="id"
class="dense">
</vn-autocomplete>
</vn-td>
<vn-td vn-click-stop>
<vn-autocomplete
vn-id="agencyMode"
ng-model="weekly.agencyModeFk"
url="AgencyModes/isActive"
show-field="name"
value-field="id"
on-change="$ctrl.onUpdate(weekly.ticketFk, 'agencyModeFk', value)"
order="name"
class="dense">
</vn-autocomplete>
</vn-td>
<vn-td>{{::weekly.warehouseName}}</vn-td>
<vn-td>
<span
vn-click-stop="workerDescriptor.show($event, weekly.workerFk)"
class="link" >
{{::weekly.userName}}
</span>
</vn-td>
<vn-td shrink>
<vn-icon-button
icon="delete"
vn-click-stop="deleteWeekly.show(weekly.ticketFk)"
vn-tooltip="Delete">
</vn-icon-button>
</vn-td>
</vn-tr>
</vn-tbody>
</vn-table>
</vn-card>
</vn-data-viewer>
<vn-card>
<smart-table
model="model"
options="$ctrl.smartTableOptions"
view-config-id="ticketsMonitor"
expr-builder="$ctrl.exprBuilder(param, value)"
>
<slot-actions>
<vn-check
label="Auto-refresh"
vn-tooltip="Toggle auto-refresh every 2 minutes"
on-change="$ctrl.autoRefresh(value)">
</vn-check>
</slot-actions>
<slot-table>
<table>
<thead>
<tr>
<th field="ticketFk">
<span translate>Ticket ID</span>
</th>
<th field="clientName">
<span translate>Client</span>
</th>
<th field="weekDay">
<span translate>Shipment</span>
</th>
<th field="agencyModeFk">
<span translate>Agency</span>
</th>
<th field="warehouseFk">
<span translate>Warehouse</span>
</th>
<th field="nickName">
<span translate>Salesperson</span>
</th>
</tr>
</thead>
<tbody>
<tr
ng-repeat="weekly in weeklies"
ui-sref="ticket.card.summary({id: {{::weekly.ticketFk}}})"
class="clickable">
<td number>
<span
vn-click-stop="ticketDescriptor.show($event, weekly.ticketFk)"
class="link">
{{weekly.ticketFk}}
</span>
</td>
<td>
<span
vn-click-stop="clientDescriptor.show($event, weekly.clientFk)"
title ="{{::weekly.clientName}}"
class="link">
{{::weekly.clientName}}
</span>
</td>
<td vn-click-stop>
<vn-autocomplete
vn-id="weekday"
ng-model="weekly.weekDay"
data="$ctrl.weekdays"
show-field="name"
translate-fields="['name']"
value-field="id"
on-change="$ctrl.onUpdate(weekly.ticketFk, 'weekDay', value)"
order="id"
class="dense">
</vn-autocomplete>
</td>
<td vn-click-stop>
<vn-autocomplete
vn-id="agencyMode"
ng-model="weekly.agencyModeFk"
url="AgencyModes/isActive"
show-field="name"
value-field="id"
on-change="$ctrl.onUpdate(weekly.ticketFk, 'agencyModeFk', value)"
order="name"
class="dense">
</vn-autocomplete>
</td>
<td vn-click-stop>{{weekly.warehouseName}}</td>
<td>
<span
vn-click-stop="workerDescriptor.show($event, weekly.workerFk)"
class="link" >
{{::weekly.userName}}
</span>
</td>
<td shrink>
<vn-icon-button
icon="delete"
vn-click-stop="deleteWeekly.show(weekly.ticketFk)"
vn-tooltip="Delete">
</vn-icon-button>
</td>
</tr>
</tbody>
</table>
</slot-table>
</smart-table>
</vn-card>
<vn-client-descriptor-popover
vn-id="clientDescriptor">
</vn-client-descriptor-popover>
@ -112,4 +135,4 @@
on-accept="$ctrl.onDeleteWeeklyAccept($data)"
question="This ticket will be removed from weekly tickets! Continue anyway?"
message="You are going to delete this weekly ticket">
</vn-confirm>
</vn-confirm>

View File

@ -1,3 +1,4 @@
import ngModule from '../module';
import Section from 'salix/components/section';
@ -15,6 +16,44 @@ export default class Controller extends Section {
{id: 5, name: 'Saturday'},
{id: 6, name: 'Sunday'}
];
this.smartTableOptions = {
activeButtons: {
search: true,
shownColumns: true,
},
columns: [
{
field: 'ticketFk',
searchable: false
},
{
field: 'clientName',
},
{
field: 'weekDay',
searchable: false,
},
{
field: 'agencyModeFk',
searchable: false,
},
{
field: 'warehouseFk',
searchable: false,
},
{
field: 'nickname',
},
]
};
}
exprBuilder(param, value) {
switch (param) {
case 'clientName': return {'c.name': value};
case 'nickName': return {'u.name': value};
}
}
onUpdate(ticketFk, field, value) {