feat: update data mapper in the base store
update the data mapper in the base store, add extra params for the function, which can be better rebuild the data used in the list page or detail page Change-Id: Idb02ff0cce8ef48318b6eb9f0b5c8c6521fc961b
This commit is contained in:
parent
8166bade64
commit
12bc328c24
@ -69,8 +69,8 @@ export default class BaseStore {
|
|||||||
|
|
||||||
get mapper() {
|
get mapper() {
|
||||||
// update response items;
|
// update response items;
|
||||||
return (data) => data;
|
// eslint-disable-next-line no-unused-vars
|
||||||
// return ObjectMapper[this.module] || (data => data);
|
return (data, allProjects, originFilters) => data;
|
||||||
}
|
}
|
||||||
|
|
||||||
get mapperBeforeFetchProject() {
|
get mapperBeforeFetchProject() {
|
||||||
@ -395,7 +395,7 @@ export default class BaseStore {
|
|||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
newData = newData.map(this.mapper);
|
newData = newData.map((d) => this.mapper(d, all_projects, filters));
|
||||||
this.list.update({
|
this.list.update({
|
||||||
data: newData,
|
data: newData,
|
||||||
total: newData.length || 0,
|
total: newData.length || 0,
|
||||||
@ -476,7 +476,7 @@ export default class BaseStore {
|
|||||||
const allDataNew = allData.map(this.mapperBeforeFetchProject);
|
const allDataNew = allData.map(this.mapperBeforeFetchProject);
|
||||||
let newData = await this.listDidFetchProject(allDataNew, all_projects);
|
let newData = await this.listDidFetchProject(allDataNew, all_projects);
|
||||||
newData = await this.listDidFetch(newData, all_projects, filters);
|
newData = await this.listDidFetch(newData, all_projects, filters);
|
||||||
newData = newData.map(this.mapper);
|
newData = newData.map((d) => this.mapper(d, all_projects, filters));
|
||||||
let count;
|
let count;
|
||||||
let total;
|
let total;
|
||||||
if (result.count || result.total) {
|
if (result.count || result.total) {
|
||||||
@ -529,7 +529,7 @@ export default class BaseStore {
|
|||||||
const item = this.mapperBeforeFetchProject(originData, rest, true);
|
const item = this.mapperBeforeFetchProject(originData, rest, true);
|
||||||
try {
|
try {
|
||||||
const newItem = await this.detailDidFetch(item, all_projects, rest);
|
const newItem = await this.detailDidFetch(item, all_projects, rest);
|
||||||
const detail = this.mapper(newItem);
|
const detail = this.mapper(newItem, all_projects, rest);
|
||||||
this.detail = detail;
|
this.detail = detail;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
|
Loading…
Reference in New Issue
Block a user