diff --git a/src/classes/api/endpoints/class-tainacan-rest-items-controller.php b/src/classes/api/endpoints/class-tainacan-rest-items-controller.php index 9084e72c8..362139bec 100644 --- a/src/classes/api/endpoints/class-tainacan-rest-items-controller.php +++ b/src/classes/api/endpoints/class-tainacan-rest-items-controller.php @@ -1011,7 +1011,7 @@ class REST_Items_Controller extends REST_Controller { move_uploaded_file($files['document']['tmp_name'], $tmp_file_name); $document_id = $TainacanMedia->insert_attachment_from_file($tmp_file_name, $item_id); if($document_id === false) { - $entities_erros[] = ["document" => __('error on create document', 'tainacan')]; + $entities_erros[] = ["document" => __('Error while creating document', 'tainacan')]; wp_delete_attachment($document_id, true); } else { $item->set_document_type('attachment'); @@ -1026,7 +1026,7 @@ class REST_Items_Controller extends REST_Controller { move_uploaded_file($files['thumbnail']['tmp_name'], $tmp_file_name); $thumbnail_id = $TainacanMedia->insert_attachment_from_file($tmp_file_name); if($thumbnail_id === false) { - $entities_erros[] = ["thumbnail" => __('error on create thumbnail', 'tainacan')]; + $entities_erros[] = ["thumbnail" => __('Error while creating thumbnail', 'tainacan')]; wp_delete_attachment($thumbnail_id, true); } else { $item->set__thumbnail_id($thumbnail_id); @@ -1050,7 +1050,7 @@ class REST_Items_Controller extends REST_Controller { $attachment_id = $TainacanMedia->insert_attachment_from_file($tmp_file_name, $item_id); unlink($tmp_file_name); if($attachment_id === false) { - $entities_erros[] = ['attachments' => __('error on create attachment ', 'tainacan') . "($attachments_name[$i])" ]; + $entities_erros[] = ['attachments' => __('Error while creating attachment ', 'tainacan') . "($attachments_name[$i])" ]; break; } $insert_attachments[] = $attachment_id; diff --git a/src/views/item-submission/pages/item-submission-form.vue b/src/views/item-submission/pages/item-submission-form.vue index 00a400ed0..05c16c8f1 100644 --- a/src/views/item-submission/pages/item-submission-form.vue +++ b/src/views/item-submission/pages/item-submission-form.vue @@ -63,10 +63,15 @@ attached :aria-close-label="$i18n.get('delete')" @close="form.document = ''" - :type="formErrors.find(error => error.metadatum_id== 'document') ? 'is-danger' : ''"> + :type="documentErrorMessage ? 'is-danger' : ''"> {{ form.document.name }} +
+ {{ documentErrorMessage }} +
+ {{ thumbnailErrorMessage }} +
@@ -238,10 +248,15 @@ attached :aria-close-label="$i18n.get('delete')" @close="form.attachments.splice(index, 1)" - :type="formErrors.find(error => error.metadatum_id == 'attachments') ? 'is-danger' : ''"> + :type="attachmentsErrorMessage.includes(attachment.name) ? 'is-danger' : ''"> {{ attachment.name }} ++ {{ attachmentsErrorMessage }} +
@@ -477,6 +492,18 @@ export default { }, hasMoreThanOneDocumentTypeOption() { return [ this.hideFileModalButton, this.hideTextModalButton, this.hideLinkModalButton ].filter((option) => { return option == false }).length > 1; + }, + documentErrorMessage() { + const existingError = this.formErrors.find(error => error.metadatum_id == 'document'); + return existingError ? existingError.errors : ''; + }, + attachmentsErrorMessage() { + const existingError = this.formErrors.find(error => error['attachments'] || error.metadatum_id == 'attachments'); + return existingError ? existingError.errors : ''; + }, + thumbnailErrorMessage() { + const existingError = this.formErrors.find(error => error.metadatum_id == 'thumbnail'); + return existingError ? existingError.errors : ''; } }, created() {