remove property editor alias from config response
This commit is contained in:
@@ -962,8 +962,6 @@ components:
|
||||
PropertyEditorConfigResponse:
|
||||
type: object
|
||||
properties:
|
||||
propertyEditorAlias:
|
||||
type: string
|
||||
properties:
|
||||
type: array
|
||||
items:
|
||||
@@ -971,7 +969,6 @@ components:
|
||||
defaultConfig:
|
||||
type: object
|
||||
required:
|
||||
- propertyEditorAlias
|
||||
- properties
|
||||
ServerStatus:
|
||||
type: string
|
||||
|
||||
@@ -322,7 +322,6 @@ export interface components {
|
||||
config?: components["schemas"]["PropertyEditorConfig"];
|
||||
};
|
||||
PropertyEditorConfigResponse: {
|
||||
propertyEditorAlias: string;
|
||||
properties: components["schemas"]["PropertyEditorConfigProperty"][];
|
||||
defaultConfig?: { [key: string]: unknown };
|
||||
};
|
||||
|
||||
@@ -2,15 +2,23 @@ import { BehaviorSubject, map, Observable } from 'rxjs';
|
||||
import { getPropertyEditorConfig } from '../../api/fetcher';
|
||||
import type { PropertyEditorConfig } from '../../models';
|
||||
|
||||
export class UmbPropertyEditorConfigStore {
|
||||
private _items: BehaviorSubject<Array<PropertyEditorConfig>> = new BehaviorSubject(<Array<PropertyEditorConfig>>[]);
|
||||
public readonly items: Observable<Array<PropertyEditorConfig>> = this._items.asObservable();
|
||||
export interface PropertyEditorConfigRef {
|
||||
propertyEditorAlias: string;
|
||||
config: PropertyEditorConfig;
|
||||
}
|
||||
|
||||
getByAlias(alias: string): Observable<PropertyEditorConfig | undefined> {
|
||||
export class UmbPropertyEditorConfigStore {
|
||||
private _items: BehaviorSubject<Array<PropertyEditorConfigRef>> = new BehaviorSubject(
|
||||
<Array<PropertyEditorConfigRef>>[]
|
||||
);
|
||||
public readonly items: Observable<Array<PropertyEditorConfigRef>> = this._items.asObservable();
|
||||
|
||||
getByAlias(alias: string): Observable<PropertyEditorConfigRef | undefined> {
|
||||
// TODO: only fetch if the data type is not in the store?
|
||||
getPropertyEditorConfig({ propertyEditorAlias: alias })
|
||||
.then((res) => {
|
||||
this.update([res.data]);
|
||||
const propertyEditorConfigRef: PropertyEditorConfigRef = { propertyEditorAlias: alias, config: res.data };
|
||||
this.update([propertyEditorConfigRef]);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
@@ -19,9 +27,9 @@ export class UmbPropertyEditorConfigStore {
|
||||
return this.items.pipe(map((items) => items.find((item) => item.propertyEditorAlias === alias)));
|
||||
}
|
||||
|
||||
public update(updatedItems: Array<PropertyEditorConfig>) {
|
||||
public update(updatedItems: Array<PropertyEditorConfigRef>) {
|
||||
const storedItems = this._items.getValue();
|
||||
const updated: PropertyEditorConfig[] = [...storedItems];
|
||||
const updated: PropertyEditorConfigRef[] = [...storedItems];
|
||||
|
||||
updatedItems.forEach((updatedItem) => {
|
||||
const index = storedItems
|
||||
|
||||
@@ -37,12 +37,8 @@ export const handlers = [
|
||||
if (!alias) return;
|
||||
|
||||
const config = umbPropertyEditorData.getConfig(alias);
|
||||
if (!config) return;
|
||||
|
||||
const response = {
|
||||
propertyEditorAlias: alias,
|
||||
config: config,
|
||||
};
|
||||
|
||||
return res(ctx.status(200), ctx.json<PropertyEditorConfigResponse>(response));
|
||||
return res(ctx.status(200), ctx.json<PropertyEditorConfigResponse>(config));
|
||||
}),
|
||||
];
|
||||
|
||||
@@ -50,9 +50,7 @@ export interface PropertyEditorsListResponse {
|
||||
|
||||
export interface PropertyEditorResponse extends PropertyEditor {}
|
||||
|
||||
export interface PropertyEditorConfigResponse extends PropertyEditorConfig {
|
||||
propertyEditorAlias: string;
|
||||
}
|
||||
export interface PropertyEditorConfigResponse extends PropertyEditorConfig {}
|
||||
|
||||
export interface PropertyEditor {
|
||||
alias: string;
|
||||
|
||||
Reference in New Issue
Block a user