Fix confusion with attachment indices, component key [SCI-7023] (#4288)

This commit is contained in:
artoscinote 2022-07-26 13:42:25 +02:00 committed by GitHub
parent 2800274d7c
commit f08e57c428
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 8 deletions

View file

@ -76,11 +76,11 @@
<template v-for="(attachment, index) in attachmentsOrdered">
<component
:is="attachment_view_mode(attachmentsOrdered[index])"
:key="index"
:attachment.sync="attachmentsOrdered[index]"
:key="attachment.id"
:attachment="attachment"
:stepId="parseInt(step.id)"
@attachment:viewMode="updateAttachmentViewMode"
@attachment:delete="deleteAttachment"
@attachment:delete="deleteAttachment(attachment.id)"
/>
</template>
</div>
@ -159,9 +159,8 @@
}
return `${attachment.attributes.view_mode}Attachment`
},
deleteAttachment(index) {
this.attachments.splice(index, 1)
this.$emit('attachment:deleted')
deleteAttachment(id) {
this.$emit('attachment:deleted', id)
},
initMarvinJS() {
// legacy logic from app/assets/javascripts/sitewide/marvinjs_editor.js

View file

@ -400,7 +400,8 @@
$('.comments-sidebar .close-btn').click();
this.showCommentsSidebar = true
},
attachmentDeleted() {
attachmentDeleted(id) {
this.attachments = this.attachments.filter((a) => a.id !== id );
this.$emit('stepUpdated');
},
closeCommentsSidebar() {

View file

@ -15,7 +15,7 @@ export default {
HelperModule.flashAlertMsg(result.flash, 'success');
},
error: () => {
HelperModule.flashAlertMsg(i18n.t('general.no_permissions'), 'danger');
HelperModule.flashAlertMsg(this.i18n.t('general.no_permissions'), 'danger');
}
});
}