Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,9 @@ export default {
const closeMenu = () => {
isOpen.value = false;
menuItems.value = [];
nextTick(() => (menu.value.$el.style.top = ""));
nextTick(() => {
if (menu.value) menu.value.$el.style.top = "";
});
};

const onClick = event => {
Expand Down
25 changes: 17 additions & 8 deletions src/components/specific/files/visas-table/VisasTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,11 @@ import { computed, watch, ref } from "vue";
import { useI18n } from "vue-i18n";
import { useStandardBreakpoints } from "../../../../composables/responsive.js";
import { VISA_STATUS, VALIDATION_STATUS } from "../../../../config/visa.js";
import { enhanceVisa } from "../../../../utils/visas.js";
import { useFiles } from "../../../../state/files.js";
import { useProjects } from "../../../../state/projects.js";
import { useUser } from "../../../../state/user.js";
import { fullName } from "../../../../utils/users.js";
import { enhanceVisa } from "../../../../utils/visas.js";
import columnsDef, { columnsLG, columnsXL, columnsXXL } from "./columns.js";

import UserAvatarList from "../../users/user-avatar-list/UserAvatarList.vue";
Expand Down Expand Up @@ -130,15 +131,23 @@ export default {
emits: ["delete", "file-clicked", "go-folders-view", "reach-visa", "selection-changed"],
setup(props) {
const { t } = useI18n();
const { user } = useUser();
const { isLG, isXL, isXXL } = useStandardBreakpoints();

const {
fileStructureHandler: handler,
} = useFiles();
const { user } = useUser();
const { currentProject } = useProjects();
const { fileStructureHandler: handler } = useFiles();

const enhancedVisas = computed(() =>
props.visas.map((visa) => enhanceVisa(visa, user.value, t, handler))
const enhancedVisas = ref([]);
watch(
() => props.visas,
async () => {
enhancedVisas.value = await Promise.all(
props.visas.map((visa) => enhanceVisa(visa, user.value, currentProject.value, t, handler))
).then(
visas => visas.filter(visa => !!visa)
);
},
{ immediate: true }
);

const columns = computed(() => {
Expand Down Expand Up @@ -203,9 +212,9 @@ export default {

return {
columns,
enhancedVisas,
user,
fullName,
enhancedVisas,
isDelay,
statusClasses,
statusIcon,
Expand Down
10 changes: 3 additions & 7 deletions src/components/specific/visa/visa-summary/VisaSummary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
<BIMDataTextbox
class="visa-summary__shell__file__content__name"
:text="formatedVisa.document.name"
@click="$emit('preview-visa', formatedVisa.document.file)"
@click="$emit('preview-visa', formatedVisa.document)"
width="calc(100% - 20px - 12px * 3)"
/>
</div>
Expand All @@ -169,8 +169,8 @@
height="40px"
@click="
$emit('reach-file', {
...formatedVisa.document,
nature: formatedVisa.document.model_id ? 'Model' : 'Document',
id: formatedVisa.document.head_id ?? formatedVisa.document.id,
nature: 'Document',
})
"
>
Expand Down Expand Up @@ -297,10 +297,6 @@ export default {
...visa.creator,
fullName: visa.creator ? fullName(visa.creator) : t("Visa.summary.deletedUser"),
},
document: {
...visa.document,
file: handler.get({ id: visa.document.id, nature: "Document" }),
},
validations: visa.validations
.map((validation) => ({
...validation,
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@
"add": {
"title": "Validation request",
"errorDate": "Date invalid",
"errorValidator": "You must add at least 1 confirmer",
"errorValidator": "You must add at least 1 validator",
"dateInputPlaceholder": "To be validated before"
},
"summary": {
Expand Down
19 changes: 16 additions & 3 deletions src/utils/visas.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { fullName } from "./users.js";
import { VISA_STATUS, VALIDATION_STATUS } from "../config/visa.js";
import FileService from "../services/FileService.js";
import { fullName } from "./users.js";

export const enhanceVisa = (visa, user, t, handler) => {
export const enhanceVisa = async (visa, user, project, t, handler) => {
const validationType = () => {
if (visa.status === VISA_STATUS.CLOSE) {
return t("Visa.view.visaClosed");
Expand Down Expand Up @@ -37,7 +38,19 @@ export const enhanceVisa = (visa, user, t, handler) => {
return emailValidators;
};

const document = handler.get({ id: visa.document.head_id ?? visa.document.id, nature: "Document" });
let document
try {
document = handler.get({
id: visa.document.id,
nature: "Document",
});
if (!document) {
document = await FileService.getDocument(project, { id: visa.document_id });
}
} catch (error) {
console.error("[Visa Utils]", error);
}
if (!document) return;

return {
...visa,
Expand Down