Browse Source

Fix componentWithCollectionsState

pages-datasources
mohamedsalem401 1 year ago
parent
commit
b6181addd9
  1. 12
      packages/core/src/data_sources/model/ComponentWithCollectionsState.ts

12
packages/core/src/data_sources/model/ComponentWithCollectionsState.ts

@ -105,14 +105,14 @@ export default class ComponentWithCollectionsState<DataResolverType> extends Com
switch (true) { switch (true) {
case isObject(dataSource) && dataSource instanceof DataSource: { case isObject(dataSource) && dataSource instanceof DataSource: {
const id = dataSource.get('id')!; const id = dataSource.get('id')!;
return this.listDataSourceVariables(id); return this.getDataSourceRecordsItems(id);
} }
case isDataVariable(dataSource): { case isDataVariable(dataSource): {
const path = dataSource.path; const path = dataSource.path;
if (!path) return []; if (!path) return [];
const isDataSourceId = path.split('.').length === 1; const isDataSourceId = path.split('.').length === 1;
if (isDataSourceId) { if (isDataSourceId) {
return this.listDataSourceVariables(path); return this.getDataSourceRecordsItems(path);
} else { } else {
return em.DataSources.getValue(path, []); return em.DataSources.getValue(path, []);
} }
@ -132,14 +132,10 @@ export default class ComponentWithCollectionsState<DataResolverType> extends Com
this.dataSourceWatcher = undefined; this.dataSourceWatcher = undefined;
} }
private listDataSourceVariables(path: string): DataVariableProps[] { private getDataSourceRecordsItems(path: string): any[] {
const records = this.em.DataSources.getValue(path, []); const records = this.em.DataSources.getValue(path, []);
const keys = Object.keys(records);
return keys.map((key) => ({ return Object.entries(records).map(([_, value]) => value);
type: DataVariableType,
path: path + '.' + key,
}));
} }
destroy(options?: ObjectAny): false | JQueryXHR { destroy(options?: ObjectAny): false | JQueryXHR {

Loading…
Cancel
Save