refactor: implement state proxy in partner list patch and remove unnecessary xml asset registration

This commit is contained in:
Suherdy Yacob 2026-06-17 18:18:20 +07:00
parent 2823d613a8
commit 095f87d8b9
2 changed files with 31 additions and 10 deletions

View File

@ -23,7 +23,6 @@ Custom POS Loyalty and Membership management features:
], ],
'assets': { 'assets': {
'point_of_sale._assets_pos': [ 'point_of_sale._assets_pos': [
'pos_loyalty_member_custom/static/src/app/screens/partner_list_patch.xml',
'pos_loyalty_member_custom/static/src/app/screens/partner_list_patch.js', 'pos_loyalty_member_custom/static/src/app/screens/partner_list_patch.js',
'pos_loyalty_member_custom/static/src/app/models/pos_order_patch.js', 'pos_loyalty_member_custom/static/src/app/models/pos_order_patch.js',
] ]

View File

@ -7,24 +7,46 @@ import { normalize } from "@web/core/l10n/utils";
patch(PartnerList.prototype, { patch(PartnerList.prototype, {
setup() { setup() {
super.setup(...arguments); super.setup(...arguments);
this.state.inputQuery = ""; const realState = this.state;
this.realState = realState;
this.inputQuery = "";
this.state = new Proxy(realState, {
get: (target, prop, receiver) => {
if (prop === "query") {
// Access target.query to register dependency for reactivity when needed
const _unused = target.query;
return this.inputQuery;
}
return Reflect.get(target, prop, receiver);
},
set: (target, prop, value, receiver) => {
if (prop === "query") {
this.inputQuery = value;
if (!value && target.query !== "") {
target.query = "";
}
return true;
}
return Reflect.set(target, prop, value, receiver);
}
});
this._filteredLoyaltyCache = new Map(); this._filteredLoyaltyCache = new Map();
this._partnersSearchCache = new Map(); this._partnersSearchCache = new Map();
}, },
onInputQueryChange(newValue) {
if (!newValue) {
this.state.query = "";
}
},
async searchPartner() { async searchPartner() {
this.state.query = this.state.inputQuery || ""; if (this.realState) {
this.realState.query = this.inputQuery || "";
}
return super.searchPartner(...arguments); return super.searchPartner(...arguments);
}, },
async onEnter() { async onEnter() {
this.state.query = this.state.inputQuery || ""; if (this.realState) {
this.realState.query = this.inputQuery || "";
}
return super.onEnter(...arguments); return super.onEnter(...arguments);
}, },