Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Загрузка файлов - проверки #4308

Merged
merged 3 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions l2-frontend/src/components/UploadFile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,17 @@
placeholder="Выберите структуру файла"
/>
<h5
v-else
v-else-if="noSupportedFileForms"
class="text-center"
>
Такие структуры файла не поддерживаются
</h5>
<h5
v-else
class="text-center"
>
Нет разрешенных форм
</h5>
</div>
<div
v-if="selectedForm"
Expand Down Expand Up @@ -90,7 +96,9 @@ import api from '@/api';

import typesAndForms, { formsFile, typesFile } from './types-and-forms-file';

const { getTypes, getForms, getFileFilters } = typesAndForms();
const {
getTypes, getForms, getFileFilters, unsupportedFileForms,
} = typesAndForms();

const store = useStore();

Expand Down Expand Up @@ -140,6 +148,8 @@ const allowedFormsForOrganization = async () => {
allowedForms.value = result;
};

const noSupportedFileForms = ref(false);

onMounted(async () => {
await allowedFormsForOrganization();
currentFileTypes.value = getTypes(props.typesFile);
Expand All @@ -161,6 +171,7 @@ const changeType = () => {
} else {
selectedForm.value = null;
}
noSupportedFileForms.value = unsupportedFileForms(selectedType.value, props.formsFile);
};

watch(selectedType, () => {
Expand Down
14 changes: 13 additions & 1 deletion l2-frontend/src/components/types-and-forms-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ export default function typesAndForms() {
}
return result;
};
const unsupportedFileForms = (type: string, forms: string[]) => {
const result = forms.filter(form => {
const supportedForm = fileForms.value[type][form];
if (supportedForm) {
return supportedForm.id === form;
}
return false;
});
return result.length === 0;
};

const getForms = (type: string, forms: string[] = null, onlyResult = false, allowedForms: string[] = null): formsFile[] => {
let result: formsFile[] = [];
Expand All @@ -65,5 +75,7 @@ export default function typesAndForms() {
}
return result;
};
return { getTypes, getForms, getFileFilters };
return {
getTypes, getForms, getFileFilters, unsupportedFileForms,
};
}
Loading