fix(smart-table): monitor only ticketFilter use url and add ?q in routes
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2022-11-02 09:40:09 +01:00
parent f8f44aaae7
commit 9891f7060d
8 changed files with 45 additions and 47 deletions

View File

@ -290,7 +290,7 @@ export default class Searchbar extends Component {
} }
let where = null; let where = null;
let params = null; let params = {};
if (this.exprBuilder) { if (this.exprBuilder) {
where = buildFilter(filter, where = buildFilter(filter,

View File

@ -19,9 +19,11 @@ export default class SmartTable extends Component {
this.transclude(); this.transclude();
} }
$onInit() { $onChanges() {
if (this.model) if (this.model) {
this.defaultFilter(); this.defaultFilter();
this.defaultOrder();
}
} }
$onDestroy() { $onDestroy() {
@ -53,11 +55,8 @@ export default class SmartTable extends Component {
set model(value) { set model(value) {
this._model = value; this._model = value;
if (value) { if (value)
this.$.model = value; this.$.model = value;
this.defaultFilter();
this.defaultOrder();
}
} }
getDefaultViewConfig() { getDefaultViewConfig() {
@ -168,7 +167,8 @@ export default class SmartTable extends Component {
} }
defaultFilter() { defaultFilter() {
if (!this.$params.q) return; if (this.disabledTableFilter || !this.$params.q) return;
const stateFilter = JSON.parse(this.$params.q).tableQ; const stateFilter = JSON.parse(this.$params.q).tableQ;
if (!stateFilter || !this.exprBuilder) return; if (!stateFilter || !this.exprBuilder) return;
@ -188,6 +188,8 @@ export default class SmartTable extends Component {
} }
defaultOrder() { defaultOrder() {
if (this.disabledTableOrder) return;
let stateOrder; let stateOrder;
if (this.$params.q) if (this.$params.q)
stateOrder = JSON.parse(this.$params.q).tableOrder; stateOrder = JSON.parse(this.$params.q).tableOrder;
@ -607,6 +609,8 @@ ngModule.vnComponent('smartTable', {
autoSave: '<?', autoSave: '<?',
exprBuilder: '&?', exprBuilder: '&?',
defaultNewData: '&?', defaultNewData: '&?',
options: '<?' options: '<?',
disabledTableFilter: '<?',
disabledTableOrder: '<?',
} }
}); });

View File

@ -73,7 +73,7 @@
{ {
"url": "/note", "url": "/note",
"state": "claim.card.note", "state": "claim.card.note",
"component": "ui-view", "component": "ui-view",
"abstract": true, "abstract": true,
"acl": ["salesPerson"] "acl": ["salesPerson"]
}, },
@ -105,7 +105,7 @@
"acl": ["claimManager"] "acl": ["claimManager"]
}, },
{ {
"url": "/action", "url": "/action?q",
"state": "claim.card.action", "state": "claim.card.action",
"component": "vn-claim-action", "component": "vn-claim-action",
"description": "Action", "description": "Action",
@ -131,4 +131,4 @@
"acl": ["claimManager"] "acl": ["claimManager"]
} }
] ]
} }

View File

@ -20,7 +20,7 @@
{"state": "client.card.credit.index", "icon": "credit_card"}, {"state": "client.card.credit.index", "icon": "credit_card"},
{"state": "client.card.greuge.index", "icon": "work"}, {"state": "client.card.greuge.index", "icon": "work"},
{"state": "client.card.balance.index", "icon": "icon-invoice"}, {"state": "client.card.balance.index", "icon": "icon-invoice"},
{"state": "client.card.recovery.index", "icon": "icon-recovery"}, {"state": "client.card.recovery.index", "icon": "icon-recovery"},
{"state": "client.card.webAccess", "icon": "cloud"}, {"state": "client.card.webAccess", "icon": "cloud"},
{"state": "client.card.log", "icon": "history"}, {"state": "client.card.log", "icon": "history"},
{ {
@ -37,7 +37,7 @@
{"state": "client.card.unpaid", "icon": "icon-defaulter"} {"state": "client.card.unpaid", "icon": "icon-defaulter"}
] ]
} }
] ]
}, },
"keybindings": [ "keybindings": [
{"key": "c", "state": "client.index"} {"key": "c", "state": "client.index"}
@ -147,7 +147,7 @@
{ {
"url": "/note", "url": "/note",
"state": "client.card.note", "state": "client.card.note",
"component": "ui-view", "component": "ui-view",
"abstract": true "abstract": true
}, },
{ {
@ -236,7 +236,7 @@
"client": "$ctrl.client" "client": "$ctrl.client"
} }
}, },
{ {
"url": "/create?payed&companyFk&bankFk&payedAmount", "url": "/create?payed&companyFk&bankFk&payedAmount",
"state": "client.card.balance.create", "state": "client.card.balance.create",
"component": "vn-client-balance-create", "component": "vn-client-balance-create",
@ -406,13 +406,13 @@
} }
}, },
{ {
"url": "/defaulter", "url": "/defaulter?q",
"state": "client.defaulter", "state": "client.defaulter",
"component": "vn-client-defaulter", "component": "vn-client-defaulter",
"description": "Defaulter" "description": "Defaulter"
}, },
{ {
"url" : "/notification", "url" : "/notification?q",
"state": "client.notification", "state": "client.notification",
"component": "vn-client-notification", "component": "vn-client-notification",
"description": "Notifications" "description": "Notifications"
@ -424,7 +424,7 @@
"description": "Unpaid" "description": "Unpaid"
}, },
{ {
"url": "/extended-list", "url": "/extended-list?q",
"state": "client.extendedList", "state": "client.extendedList",
"component": "vn-client-extended-list", "component": "vn-client-extended-list",
"description": "Extended list" "description": "Extended list"

View File

@ -23,9 +23,9 @@
</vn-portal> </vn-portal>
<div class="vn-w-xl"> <div class="vn-w-xl">
<vn-card> <vn-card>
<smart-table <smart-table
model="model" model="model"
options="$ctrl.smartTableOptions" options="$ctrl.smartTableOptions"
expr-builder="$ctrl.exprBuilder(param, value)"> expr-builder="$ctrl.exprBuilder(param, value)">
<slot-table> <slot-table>
<table> <table>
@ -34,18 +34,18 @@
<th field="itemFk"> <th field="itemFk">
<span translate>Item ID</span> <span translate>Item ID</span>
</th> </th>
<th field="itemName"> <th field="name">
<span translate>Description</span> <span translate>Description</span>
</th> </th>
<th field="warehouseFk"> <th field="warehouseFk">
<span translate>Warehouse</span> <span translate>Warehouse</span>
</th> </th>
<th <th
field="rate2" field="rate2"
vn-tooltip="Price By Unit"> vn-tooltip="Price By Unit">
<span translate>P.P.U.</span> <span translate>P.P.U.</span>
</th> </th>
<th <th
field="rate3" field="rate3"
vn-tooltip="Price By Package"> vn-tooltip="Price By Package">
<span translate>P.P.P.</span> <span translate>P.P.P.</span>
@ -170,7 +170,7 @@
</vn-icon-button> </vn-icon-button>
</div> </div>
</slot-table> </slot-table>
</smart-table> </smart-table>
</vn-card> </vn-card>
</div> </div>
<vn-item-descriptor-popover <vn-item-descriptor-popover
@ -182,4 +182,4 @@
on-accept="$ctrl.removePrice($data.$index)" on-accept="$ctrl.removePrice($data.$index)"
question="Are you sure you want to continue?" question="Are you sure you want to continue?"
message="This row will be removed"> message="This row will be removed">
</vn-confirm> </vn-confirm>

View File

@ -12,14 +12,6 @@ export default class Controller extends Section {
}, },
defaultSearch: true, defaultSearch: true,
columns: [ columns: [
{
field: 'itemName',
autocomplete: {
url: 'Items',
showField: 'name',
valueField: 'id'
}
},
{ {
field: 'warehouseFk', field: 'warehouseFk',
autocomplete: { autocomplete: {
@ -105,8 +97,8 @@ export default class Controller extends Section {
exprBuilder(param, value) { exprBuilder(param, value) {
switch (param) { switch (param) {
case 'itemName': case 'name':
return {'i.id': value}; return {'i.name': {like: `%${value}%`}};
case 'itemFk': case 'itemFk':
case 'warehouseFk': case 'warehouseFk':
case 'rate2': case 'rate2':

View File

@ -19,22 +19,24 @@
</vn-none> </vn-none>
</vn-horizontal> </vn-horizontal>
<vn-card vn-id="card"> <vn-card vn-id="card">
<smart-table <smart-table
model="model" model="model"
options="$ctrl.smartTableOptions" options="$ctrl.smartTableOptions"
expr-builder="$ctrl.exprBuilder(param, value)" expr-builder="$ctrl.exprBuilder(param, value)"
disabled-table-filter="true"
disabled-table-order="true"
class="scrollable sm"> class="scrollable sm">
<slot-actions> <slot-actions>
<vn-horizontal> <vn-horizontal>
<vn-date-picker <vn-date-picker
class="vn-pa-xs" class="vn-pa-xs"
label="From" label="From"
ng-model="$ctrl.dateFrom" ng-model="$ctrl.dateFrom"
on-change="$ctrl.addFilterDate()"> on-change="$ctrl.addFilterDate()">
</vn-date-picker> </vn-date-picker>
<vn-date-picker <vn-date-picker
class="vn-pa-xs" class="vn-pa-xs"
label="To" label="To"
ng-model="$ctrl.dateTo" ng-model="$ctrl.dateTo"
on-change="$ctrl.addFilterDate()"> on-change="$ctrl.addFilterDate()">
</vn-date-picker> </vn-date-picker>
@ -100,9 +102,9 @@
</slot-pagination> </slot-pagination>
</smart-table> </smart-table>
</vn-card> </vn-card>
<vn-worker-descriptor-popover <vn-worker-descriptor-popover
vn-id="workerDescriptor"> vn-id="workerDescriptor">
</vn-worker-descriptor-popover> </vn-worker-descriptor-popover>
<vn-client-descriptor-popover <vn-client-descriptor-popover
vn-id="clientDescriptor"> vn-id="clientDescriptor">
</vn-client-descriptor-popover> </vn-client-descriptor-popover>

View File

@ -39,7 +39,7 @@
"abstract": true, "abstract": true,
"component": "vn-route-card" "component": "vn-route-card"
}, { }, {
"url": "/agency-term", "url": "/agency-term?q",
"abstract": true, "abstract": true,
"state": "route.agencyTerm", "state": "route.agencyTerm",
"component": "ui-view" "component": "ui-view"
@ -49,12 +49,12 @@
"component": "vn-agency-term-index", "component": "vn-agency-term-index",
"description": "Autonomous", "description": "Autonomous",
"acl": ["administrative"] "acl": ["administrative"]
},{ },{
"url": "/createInvoiceIn?q", "url": "/createInvoiceIn?q",
"state": "route.agencyTerm.createInvoiceIn", "state": "route.agencyTerm.createInvoiceIn",
"component": "vn-agency-term-create-invoice-in", "component": "vn-agency-term-create-invoice-in",
"description": "File management", "description": "File management",
"params": { "params": {
"route": "$ctrl.route" "route": "$ctrl.route"
}, },
"acl": ["administrative"] "acl": ["administrative"]
@ -92,4 +92,4 @@
"acl": ["delivery"] "acl": ["delivery"]
} }
] ]
} }