diff --git a/app/pages/user/settings/index.vue b/app/pages/user/settings/index.vue index 98b5a3f3..b718b0f6 100644 --- a/app/pages/user/settings/index.vue +++ b/app/pages/user/settings/index.vue @@ -16,7 +16,7 @@
-
diff --git a/ving/docs/change-log.md b/ving/docs/change-log.md index 363f337f..20c4b208 100644 --- a/ving/docs/change-log.md +++ b/ving/docs/change-log.md @@ -7,6 +7,9 @@ outline: deep ### 2024-10-27 * Added ego behavior to useVingRecord() and useVingKind() to allow disambiguation of multiple copies of the same record with different views. +* VingRecord.propOptions() now returns validation options S3File relations in the form of acceptedFileExtensions. +* VingRecord.describe().meta no longer includes the acceptedFileExtensions on S3File relations. +* NOTE: If you are using `record.meta.acceptedFileExtensions` in your UI, you will need to change it to `record.options.relationName` instead. For example `record.meta.acceptedFileExtensions.avatar` would become `record.options.avatar`. ### 2024-10-25 * Fix a bug in redis client where it wouldn't connect to the AWS valkey/redis cluster. diff --git a/ving/docs/subsystems/ui.md b/ving/docs/subsystems/ui.md index 41eaa6e9..491edc27 100644 --- a/ving/docs/subsystems/ui.md +++ b/ving/docs/subsystems/ui.md @@ -79,10 +79,10 @@ Creates a user interface for uploading [S3Files](/rest/S3File). It handles the r Props: -- **acceptedFiles** - An array of file extensions that S3File should accept. Defaults to `['png','jpg']`. This can and should be automatically filled by a `meta.acceptedFileExtensions` property from a [Ving Record](ving-record) when dealing with S3Files. It is set by the `relation.acceptedFileExtensions` attribute in a [Ving Schema](ving-schema). For example: +- **acceptedFiles** - An array of file extensions that S3File should accept. Defaults to `['png','jpg']`. This can and should be automatically filled by property such as `options.avatar` which will be generated when enabling `options` on a [Ving Record](ving-record) when dealing with S3Files. It is set by the `relation.acceptedFileExtensions` attribute in a [Ving Schema](ving-schema). For example: ```html - + ``` - **afterUpload** - Required. A function that will be executed after upload. This function should then call the appropriate import endpoint to post process and verify the file. - **info** - A string that will be displayed inside the dropzone box. Useful to give the user some insights about the nature of the files you will allow such as size or dimension contstraints. diff --git a/ving/docs/subsystems/ving-record.md b/ving/docs/subsystems/ving-record.md index e2323ba5..c1660145 100644 --- a/ving/docs/subsystems/ving-record.md +++ b/ving/docs/subsystems/ving-record.md @@ -429,7 +429,7 @@ const user = apikey.parent('user'); ``` #### propOptions -Returns a list of enumeration options for this record. +Returns a list of validation options for fields in this record. ```js const options = await user.propOptions(params, false); @@ -442,6 +442,7 @@ const options = await user.propOptions(params, false); { label : 'Username', value : 'username' }, ... ], + avatar : [ 'png', 'jpg' ], ... } ``` diff --git a/ving/generator/nuxtpages.mjs b/ving/generator/nuxtpages.mjs index 401b5a16..8d998d57 100644 --- a/ving/generator/nuxtpages.mjs +++ b/ving/generator/nuxtpages.mjs @@ -286,7 +286,7 @@ const editProps = (schema) => { else if (prop.type == 'id' && prop?.relation?.type == 'parent' && prop.relation?.kind == 'S3File') { out += `
-
`; } diff --git a/ving/record/VingRecord.mjs b/ving/record/VingRecord.mjs index bfccb5d0..ec801900 100644 --- a/ving/record/VingRecord.mjs +++ b/ving/record/VingRecord.mjs @@ -242,11 +242,6 @@ export class VingRecord { const parent = await this.parent(field.relation.name); out.related[field.relation.name] = await parent.describe(params); } - if (isObject(out.meta) && 'acceptedFileExtensions' in field.relation) { - if (!('acceptedFileExtensions' in out.meta)) - out.meta.acceptedFileExtensions = {}; - out.meta.acceptedFileExtensions[field.relation.name] = field.relation.acceptedFileExtensions; - } } } @@ -418,7 +413,7 @@ export class VingRecord { } /** - * Returns a list of the enumerated prop options available to the current user + * Returns a list of the enumerated prop options available to the current user. These options can be used to validate the data submitted to this field. * * @param {Object} params A list of params to change the output of the describe. Defaults to `{}` * @param {Object} params.currentUser The `User` or `Session` instance to test ownership against @@ -453,6 +448,12 @@ export class VingRecord { else if (prop.options) { options[prop.name] = await this[prop.options](); } + else if (prop.relation + && ['parent', 'sibling'].includes(prop.relation.type) + && 'acceptedFileExtensions' in prop.relation + ) { + options[prop.relation.name] = prop.relation.acceptedFileExtensions; + } } return options; }