mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-13 07:46:10 +00:00
updated itemsApi
This commit is contained in:
parent
d1bd58cfa8
commit
efaa9aac69
@ -8,12 +8,16 @@ export class itemsApi<T> implements ItemsApi<T>{
|
|||||||
|
|
||||||
collectionName: string;
|
collectionName: string;
|
||||||
filter: any;
|
filter: any;
|
||||||
|
layerId: string | undefined;
|
||||||
|
|
||||||
constructor(collectionName: string, layerId?: string | undefined, mapId?: string | undefined, filter?: any, ) {
|
constructor(collectionName: string, layerId?: string | undefined, mapId?: string | undefined, filter?: any, ) {
|
||||||
this.collectionName = collectionName;
|
this.collectionName = collectionName;
|
||||||
if(filter) this.filter = filter;
|
if(filter) this.filter = filter;
|
||||||
else this.filter = {};
|
else this.filter = {};
|
||||||
if(layerId) this.filter = {... filter, ... { "layer" : { "id": { "_eq": layerId }}}}
|
this.layerId = layerId;
|
||||||
|
if(layerId) {
|
||||||
|
this.filter = {... filter, ... { "layer" : { "id": { "_eq": layerId }}}}
|
||||||
|
}
|
||||||
if(mapId) this.filter = {... filter, ... { "map" : { "id": { "_eq": mapId }}}}
|
if(mapId) this.filter = {... filter, ... { "map" : { "id": { "_eq": mapId }}}}
|
||||||
console.log(this.filter);
|
console.log(this.filter);
|
||||||
|
|
||||||
@ -43,7 +47,7 @@ export class itemsApi<T> implements ItemsApi<T>{
|
|||||||
|
|
||||||
async createItem(item: T & { id?: string }) {
|
async createItem(item: T & { id?: string }) {
|
||||||
try {
|
try {
|
||||||
return await directusClient.request(createItem(this.collectionName as keyof MyCollections, item))
|
return await directusClient.request(createItem(this.collectionName as keyof MyCollections, {...item, ...(this.layerId && {layer: this.layerId})}))
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
if (error.errors[0]?.message)
|
if (error.errors[0]?.message)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user