[FIX] web_refresher: new record refresh

pull/2889/head
Taras Shabaranskyi 2024-07-21 02:51:21 +03:00
parent c177834d57
commit 324c5ea02d
4 changed files with 23 additions and 16 deletions

View File

@ -12,16 +12,23 @@ ControlPanel.components = Object.assign({}, ControlPanel.components, {
Refresher, Refresher,
}); });
/**
* @property {String[]} forbiddenSubTypes
* @property {Object<String, *>} refresherProps
*/
patch(ControlPanel.prototype, "web_refresher.ControlPanel", { patch(ControlPanel.prototype, "web_refresher.ControlPanel", {
setup() { setup() {
this._super(...arguments); this._super(...arguments);
const {config, searchModel} = this.env; this.forbiddenSubTypes = ["base_settings"];
const forbiddenSubType = ["base_settings"]; this.refresherProps = {
if (!forbiddenSubType.includes(config.viewSubType)) { searchModel: this.env.searchModel,
this.refresherProps = { pagerProps: this.pagerProps,
searchModel: searchModel, };
pagerProps: this.pagerProps, },
}; /**
} * @returns {Boolean}
*/
get displayRefresher() {
return !this.forbiddenSubTypes.includes(this.env.config.viewSubType);
}, },
}); });

View File

@ -89,9 +89,9 @@ export class Refresher extends Component {
* @returns {Promise<Boolean>} * @returns {Promise<Boolean>}
*/ */
async refresh() { async refresh() {
let updated = this._searchModelRefresh(); let updated = await this._pagerRefresh();
if (!updated) { if (!updated) {
updated = await this._pagerRefresh(); updated = this._searchModelRefresh();
} }
return updated; return updated;
} }

View File

@ -10,7 +10,7 @@
> >
<xpath expr="//div[hasclass('o_cp_pager')]" position="before"> <xpath expr="//div[hasclass('o_cp_pager')]" position="before">
<div class="oe_cp_refresher" role="search" t-ref="refresher"> <div class="oe_cp_refresher" role="search" t-ref="refresher">
<Refresher t-props="refresherProps" /> <Refresher t-if="displayRefresher" t-props="refresherProps" />
</div> </div>
</xpath> </xpath>
<xpath expr="//div[hasclass('o_cp_bottom_right')]" position="before"> <xpath expr="//div[hasclass('o_cp_bottom_right')]" position="before">
@ -19,7 +19,7 @@
class="o_cp_bottom_right d-flex flex-row-reverse" class="o_cp_bottom_right d-flex flex-row-reverse"
> >
<div class="oe_cp_refresher" role="search" t-ref="refresher"> <div class="oe_cp_refresher" role="search" t-ref="refresher">
<Refresher refresherReport="true" /> <Refresher t-if="displayRefresher" refresherReport="true" />
</div> </div>
</div> </div>
</xpath> </xpath>
@ -32,7 +32,7 @@
> >
<xpath expr="//div[hasclass('o_cp_pager')]" position="before"> <xpath expr="//div[hasclass('o_cp_pager')]" position="before">
<div class="oe_cp_refresher" role="search" t-ref="refresher"> <div class="oe_cp_refresher" role="search" t-ref="refresher">
<Refresher t-props="refresherProps" /> <Refresher t-if="displayRefresher" t-props="refresherProps" />
</div> </div>
</xpath> </xpath>
<xpath expr="//div[hasclass('o_cp_bottom_right')]" position="before"> <xpath expr="//div[hasclass('o_cp_bottom_right')]" position="before">
@ -41,7 +41,7 @@
class="o_cp_bottom_right d-flex flex-row-reverse" class="o_cp_bottom_right d-flex flex-row-reverse"
> >
<div class="oe_cp_refresher" role="search" t-ref="refresher"> <div class="oe_cp_refresher" role="search" t-ref="refresher">
<Refresher refresherReport="true" /> <Refresher t-if="displayRefresher" refresherReport="true" />
</div> </div>
</div> </div>
</xpath> </xpath>

View File

@ -10,7 +10,7 @@
> >
<xpath expr="//div[hasclass('o_cp_pager')]" position="before"> <xpath expr="//div[hasclass('o_cp_pager')]" position="before">
<div class="oe_cp_refresher" role="search" t-ref="refresher"> <div class="oe_cp_refresher" role="search" t-ref="refresher">
<Refresher t-props="refresherProps" /> <Refresher t-if="displayRefresher" t-props="refresherProps" />
</div> </div>
</xpath> </xpath>
<xpath expr="//div[hasclass('o_cp_bottom_right')]" position="before"> <xpath expr="//div[hasclass('o_cp_bottom_right')]" position="before">
@ -19,7 +19,7 @@
class="o_cp_bottom_right d-flex flex-row-reverse" class="o_cp_bottom_right d-flex flex-row-reverse"
> >
<div class="oe_cp_refresher" role="search" t-ref="refresher"> <div class="oe_cp_refresher" role="search" t-ref="refresher">
<Refresher refresherReport="true" /> <Refresher t-if="displayRefresher" refresherReport="true" />
</div> </div>
</div> </div>
</xpath> </xpath>