Show warning icon for no-meta collections/fields

This commit is contained in:
rijkvanzanten
2020-09-03 14:56:31 -04:00
parent f1ce3322cf
commit 7554366f6f
3 changed files with 39 additions and 4 deletions

View File

@@ -199,12 +199,22 @@ export default class CollectionsService {
const payload = data as Partial<Collection>;
if (!payload.meta) {
throw new InvalidPayloadException(`"system" key is required`);
throw new InvalidPayloadException(`"meta" key is required`);
}
return (await collectionItemsService.update(payload.meta!, key as any)) as
| string
| string[];
const keys = Array.isArray(key) ? key : [key];
for (const key of keys) {
const exists = await this.knex.select('collection').from('directus_collections').where({ collection: key }).first() !== undefined;
if (exists) {
await collectionItemsService.update(payload.meta, key);
} else {
await collectionItemsService.create({ ...payload.meta, collection: key });
}
}
return key;
}
const payloads = Array.isArray(data) ? data : [data];