Skip to content

Commit

Permalink
Merge pull request #522 from codeworks-projects/fix/edit-names-documents
Browse files Browse the repository at this point in the history
Fix/edit names documents
  • Loading branch information
dulvui committed Jan 23, 2024
2 parents 399f240 + 6692383 commit a3bd1f0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later
@click="saveAndNext()"
>{{
t(
'datasets.editView.dialog.multipleFilesLanguage.buttonSaveAndNext'
'datasets.editView.dialog.multipleFilesLanguage.buttonNext'
)
}}</ButtonCustom
>
Expand Down Expand Up @@ -95,8 +95,6 @@ import { Variant } from '../../../../../../components/button/types';
import { useDialogStore } from './dialogStore';
import DialogConfirmDeselectAllLanguages from './DialogConfirmDeselectAllLanguages.vue';
import {
useEventSaveChanges,
useEventDiscardChanges,
addItemsInModalAndSave,
updateItemsInModalAndSave,
setIgnoreDelete,
Expand Down Expand Up @@ -141,12 +139,10 @@ const saveAndNext = () => {
updateItemsInModalAndSave();
}
useEventSaveChanges.emit(true);
emit('close');
};
const discardUpdates = () => {
useEventDiscardChanges.emit(true);
emit('close');
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,16 @@ export const setDataForDocumentEdit = (item: FileEntry) => {
for (const lang in Documents) {
const currentLanguageDocuments = Documents[lang];
for (const currentDocument of currentLanguageDocuments) {
if (currentDocument.DocumentURL !== item.src) {
continue;
}

const index = dialogData.findIndex((item) => item.language === lang);
dialogData[index] = {
...dialogData[index],
documentName: currentDocument.DocumentName,
language: lang,
available: currentDocument.DocumentURL === item.src,
available: true,
};
}
}
Expand Down Expand Up @@ -131,7 +135,11 @@ export const updateItem = (index: number, value: FileLanguageUpdate) => {

const currentItem = dialogStore.items[dialogStore.activeTab].data[index];

if (currentItem.documentName && !value.documentName) {
if (
currentItem.documentName &&
!value.documentName &&
!currentItem.disableAvailabilityChange
) {
value.available = false;
}

Expand Down Expand Up @@ -202,11 +210,11 @@ export const updateItemsInModalAndSave = () => {
const keyLangDocuments = documentInModal.language as keyof typeof Documents;
const currentDocumentData = Documents[keyLangDocuments] || [];

const currentSavedDocumentIndex = currentDocumentData.find(
const currentSavedDocumentIndex = currentDocumentData.findIndex(
(item: any) => item.DocumentURL === itemInModalToSave.src
);

if (currentSavedDocumentIndex) {
if (currentSavedDocumentIndex >= 0) {
Documents[keyLangDocuments].splice(currentSavedDocumentIndex, 1);
}
}
Expand Down
1 change: 1 addition & 0 deletions databrowser/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
},
"multipleFilesLanguage": {
"buttonSaveAndNext": "Save & next",
"buttonNext": "Next",
"buttonDiscardChanges": "Discard changes",
"title": "Choose language",
"description": "Which language would you like to assign the uploaded document to?"
Expand Down

0 comments on commit a3bd1f0

Please sign in to comment.