Restored ticket table and added table compatibility on contextmenu
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2021-10-28 09:06:03 +02:00
parent b27a443729
commit bfc9228eef
3 changed files with 194 additions and 43 deletions

View File

@ -49,7 +49,7 @@ export default class Contextmenu {
get rowIndex() {
if (!this.row) return null;
const table = this.row.closest('vn-table, .vn-table');
const table = this.row.closest('table, vn-table, .vn-table');
const rows = table.querySelectorAll('[ng-repeat]');
return Array.from(rows).findIndex(
@ -67,13 +67,13 @@ export default class Contextmenu {
get cell() {
if (!this.target) return null;
return this.target.closest('vn-td, .vn-td, vn-td-editable');
return this.target.closest('td, vn-td, .vn-td, vn-td-editable');
}
get cellIndex() {
if (!this.row) return null;
const cells = this.row.querySelectorAll('vn-td, .vn-td, vn-td-editable');
const cells = this.row.querySelectorAll('td, vn-td, .vn-td, vn-td-editable');
return Array.from(cells).findIndex(
cellItem => cellItem == this.cell
);
@ -82,8 +82,8 @@ export default class Contextmenu {
get rowHeader() {
if (!this.row) return null;
const table = this.row.closest('vn-table, .vn-table');
const headerCells = table && table.querySelectorAll('vn-thead vn-th');
const table = this.row.closest('table, vn-table, .vn-table');
const headerCells = table && table.querySelectorAll('thead th, vn-thead vn-th');
const headerCell = headerCells && headerCells[this.cellIndex];
return headerCell;
@ -147,7 +147,7 @@ export default class Contextmenu {
*/
isActionAllowed() {
if (!this.target) return false;
const isTableCell = this.target.closest('vn-td, .vn-td');
const isTableCell = this.target.closest('td, vn-td, .vn-td');
return isTableCell && this.fieldName;
}

View File

@ -1,12 +1,12 @@
<!-- <vn-auto-search
<vn-auto-search
model="model">
</vn-auto-search> -->
<vn-crud-model auto-load="true"
</vn-auto-search>
<!-- <vn-crud-model auto-load="true"
vn-id="model"
url="Tickets"
limit="20"
order="id DESC">
</vn-crud-model>
</vn-crud-model> -->
<vn-card>
<!-- To access table component should be a nested component -->
<smart-table
@ -42,15 +42,41 @@
check-field="$checked"> <!-- Change $checked as default prop -->
</vn-multi-check>
</th>
<th class="icon-field"></th>
<th field="id">
<span translate>#ID</span>
</th>
<th field="nickname">
<span translate>Nickname</span>
<th field="salesPersonFk">
<span translate>Salesperson</span>
</th>
<th field="shipped" shrink-date>
<span translate>Date</span>
</th>
<th>
<span translate>Pepinillos</span>
<span translate>Hour</span>
</th>
<th field="zoneHour" shrink>
<span translate>Closure</span>
</th>
<th field="nickname">
<span translate>Alias</span>
</th>
<th field="provinceFk">
<span translate>Province</span>
</th>
<th field="stateFk">
<span translate>State</span>
</th>
<th field="zoneFk">
<span translate>Zone</span>
</th>
<th field="warehouseFk">
<span translate>Warehouse</span>
</th>
<th field="totalWithVat" number>
<span translate>Total</span>
</th>
<th></th>
</tr>
</thead>
<tbody>
@ -66,9 +92,113 @@
vn-click-stop>
</vn-check>
</td>
<td>{{::ticket.id}}</td>
<td>{{::ticket.nickname}}</td>
<td><vn-textfield ng-model="::ticket.nickname"/></td>
<td class="icon-field">
<vn-icon
ng-show="::ticket.isTaxDataChecked === 0"
translate-attr="{title: 'No verified data'}"
class="bright"
icon="icon-no036">
</vn-icon>
<vn-icon
ng-show="::ticket.hasTicketRequest"
translate-attr="{title: 'Purchase request'}"
class="bright"
icon="icon-100">
</vn-icon>
<vn-icon
ng-show="::ticket.isAvailable === 0"
translate-attr="{title: 'Not available'}"
class="bright"
icon="icon-unavailable">
</vn-icon>
<vn-icon
ng-show="::ticket.isFreezed"
translate-attr="{title: 'Client frozen'}"
class="bright"
icon="icon-frozen">
</vn-icon>
<vn-icon
ng-show="::ticket.risk"
title="{{::$ctrl.$t('Risk')}}: {{ticket.risk}}"
class="bright"
icon="icon-risk">
</vn-icon>
<vn-icon
ng-show="::ticket.hasComponentLack"
translate-attr="{title: 'Component lack'}"
class="bright"
icon="icon-components">
</vn-icon>
</td>
<td shrink>{{::ticket.id}}</td>
<td class="expendable">
<span
title="{{::ticket.userName}}"
vn-click-stop="workerDescriptor.show($event, ticket.salesPersonFk)"
class="link">
{{::ticket.userName | dashIfEmpty}}
</span>
</td>
<td shrink-date>
<span class="chip {{$ctrl.compareDate(ticket.shipped)}}">
{{::ticket.shipped | date: 'dd/MM/yyyy'}}
</span>
</td>
<td shrink>{{::ticket.shipped | date: 'HH:mm'}}</td>
<td shrink>{{::ticket.zoneLanding | date: 'HH:mm'}}</td>
<td>
<span
title="{{::ticket.nickname}}"
vn-click-stop="clientDescriptor.show($event, ticket.clientFk)"
class="link">
{{::ticket.nickname}}
</span>
</td>
<td class="expendable">{{::ticket.province}}</td>
<td class="expendable">
<span
ng-show="ticket.refFk"
title="{{::ticket.refFk}}"
vn-click-stop="invoiceOutDescriptor.show($event, ticket.invoiceOutId)"
class="link">
{{::ticket.refFk}}
</span>
<span
ng-show="!ticket.refFk"
class="chip {{$ctrl.stateColor(ticket)}}">
{{ticket.state}}
</span>
</td>
<td>
<span
title="{{::ticket.zoneName}}"
vn-click-stop="zoneDescriptor.show($event, ticket.zoneFk)"
class="link">
{{::ticket.zoneName | dashIfEmpty}}
</span>
</td>
<td>{{::ticket.warehouse}}</td>
<td number>
<span class="chip {{$ctrl.totalPriceColor(ticket)}}">
{{::(ticket.totalWithVat ? ticket.totalWithVat : 0) | currency: 'EUR': 2}}
</span>
</td>
<td actions>
<vn-icon-button
vn-anchor="::{
state: 'ticket.card.sale',
params: {id: ticket.id},
target: '_blank'
}"
vn-tooltip="Go to lines"
icon="icon-lines">
</vn-icon-button>
<vn-icon-button
vn-click-stop="$ctrl.preview(ticket)"
vn-tooltip="Preview"
icon="preview">
</vn-icon-button>
</td>
</tr>
</tbody>
</table>
@ -131,6 +261,36 @@
vn-id="invoiceOutDescriptor">
</vn-invoice-out-descriptor-popover>
<vn-contextmenu vn-id="contextmenu" targets="['smart-table']" model="model"
expr-builder="$ctrl.exprBuilder(param, value)">
<slot-menu>
<vn-item translate
ng-if="contextmenu.isFilterAllowed()"
ng-click="contextmenu.filterBySelection()">
Filter by selection
</vn-item>
<vn-item translate
ng-if="contextmenu.isFilterAllowed()"
ng-click="contextmenu.excludeSelection()">
Exclude selection
</vn-item>
<vn-item translate
ng-if="contextmenu.isFilterAllowed()"
ng-click="contextmenu.removeFilter()">
Remove filter
</vn-item>
<vn-item translate
ng-click="contextmenu.removeAllFilters()">
Remove all filters
</vn-item>
<vn-item translate
ng-if="contextmenu.isActionAllowed()"
ng-click="contextmenu.copyValue()">
Copy value
</vn-item>
</slot-menu>
</vn-contextmenu>
<!-- Make invoice confirmation dialog -->
<vn-confirm
vn-id="makeInvoiceConfirmation"

View File

@ -136,37 +136,28 @@ export default class Controller extends Section {
exprBuilder(param, value) {
switch (param) {
case 'nickname':
return {'nickname': {like: `%${value}%`}};
case 'stateFk':
return {'ts.stateFk': value};
case 'salesPersonFk':
return {'c.salesPersonFk': value};
case 'provinceFk':
return {'a.provinceFk': value};
case 'hour':
return {'z.hour': value};
case 'shipped':
return {'t.shipped': {
between: this.dateRange(value)}
};
case 'id':
return {[param]: value};
case 'refFk':
case 'zoneFk':
case 'nickname':
case 'agencyModeFk':
case 'warehouseFk':
return {[`t.${param}`]: value};
}
}
// exprBuilder(param, value) {
// switch (param) {
// case 'stateFk':
// return {'ts.stateFk': value};
// case 'salesPersonFk':
// return {'c.salesPersonFk': value};
// case 'provinceFk':
// return {'a.provinceFk': value};
// case 'hour':
// return {'z.hour': value};
// case 'shipped':
// return {'t.shipped': {
// between: this.dateRange(value)}
// };
// case 'id':
// case 'refFk':
// case 'zoneFk':
// case 'nickname':
// case 'agencyModeFk':
// case 'warehouseFk':
// return {[`t.${param}`]: value};
// }
// }
dateRange(value) {
const minHour = new Date(value);
minHour.setHours(0, 0, 0, 0);