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
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@bimdata/bcf-components": "6.7.7",
"@bimdata/components": "1.10.1",
"@bimdata/design-system": "2.3.0",
"@bimdata/typescript-fetch-api-client": "10.35.0",
"@bimdata/typescript-fetch-api-client": "10.36.0",
"@bimdata/viewer": "2.17.0-beta.4",
"@paddle/paddle-js": "^1.6.2",
"async": "^3.2.6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ import { fileUploadInput } from "../../../../../utils/upload.js";
import ModelsActionBar from "../models-action-bar/ModelsActionBar.vue";
import ModelsDeleteModal from "../models-delete-modal/ModelsDeleteModal.vue";
import ModelsTable from "../../models-table/ModelsTable.vue";
import { FILE_TYPE } from "../../../../../config/files.js";

export default {
components: {
Expand Down Expand Up @@ -159,7 +160,7 @@ export default {
const router = useRouter();
const { isProjectGuest } = useUser();
const { createModel, updateModels } = useModels();
const { downloadFiles: download } = useFiles();
const { fileStructureHandler: handler, downloadFiles: download } = useFiles();

const fileUploads = ref([]);
const fileExtensions = computed(() =>
Expand Down Expand Up @@ -220,7 +221,7 @@ export default {
const downloadModels = async (models) => {
await download(
props.project,
models.map(({ document }) => document),
models.map(m => handler.get({ nature: FILE_TYPE.DOCUMENT, id: m.document_id })),
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="models-action-bar">
<BIMDataButton
:disabled="!hasAdminPermModel(project, models)"
:disabled="!hasAdminPerm(project, modelDocument)"
width="120px"
color="high"
ghost
Expand All @@ -13,7 +13,7 @@
</BIMDataButton>

<BIMDataButton
:disabled="!hasAdminPermModel(project, models)"
:disabled="!hasAdminPerm(project, modelDocument)"
width="120px"
ghost
squared
Expand Down Expand Up @@ -56,10 +56,13 @@

<script setup>
import { computed } from "vue";
import { FILE_TYPE } from "../../../../../config/files.js";
import { MODEL_TYPE } from "../../../../../config/models.js";
import { useFiles } from "../../../../../state/files.js";
import { useUser } from "../../../../../state/user.js";

const { hasAdminPermModel } = useUser();
const { hasAdminPerm } = useUser();
const { fileStructureHandler: handler } = useFiles();

const props = defineProps({
project: {
Expand All @@ -80,6 +83,8 @@ defineEmits([
"unarchive",
]);

const modelDocument = computed(() => handler.get({ nature: FILE_TYPE.DOCUMENT, id: props.model.document_id }));

const isArchived = computed(() => props.models.every(m => m.archived));

const isIFC = computed(() => props.models.every(m => m.type === MODEL_TYPE.IFC));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
/>
</template>

<template v-if="model.document">
<template v-if="model.document_id">
<BIMDataButton
class="model-actions-cell__btn"
data-test-id="btn-download-model"
Expand All @@ -107,7 +107,7 @@
<BIMDataButton
class="model-actions-cell__btn"
data-test-id="btn-toggle-menu"
:disabled="!hasAdminPerm(project, model.document)"
:disabled="!hasAdminPerm(project, modelDocument)"
ripple
rounded
icon
Expand Down Expand Up @@ -137,7 +137,9 @@
<script>
import { ref, computed, nextTick } from "vue";
import { MODEL_STATUS, MODEL_TYPE } from "../../../../../config/models.js";
import { FILE_TYPE } from "../../../../../config/files.js";
import { WINDOWS } from "../../../../../config/viewer.js";
import { useFiles } from "../../../../../state/files.js";
import { useUser } from "../../../../../state/user.js";
import { dropdownPositioner } from "../../../../../utils/positioner.js";
// Components
Expand Down Expand Up @@ -171,18 +173,21 @@ export default {
"view-photosphereBuilding",
],
setup(props, { emit }) {
const { isProjectGuest, hasAdminPerm } = useUser();
const { fileStructureHandler: handler } = useFiles();
const { hasAdminPerm, isProjectGuest } = useUser();

const menu = ref(null);
const isOpen = ref(false);
const isModelReady = computed(() => MODEL_STATUS.COMPLETED === props.model.status);

const modelDocument = computed(() => handler.get({ nature: FILE_TYPE.DOCUMENT, id: props.model.document_id }));

const menuItems = ref([]);
const openMenu = () => {
if (!props.parent) return;

isOpen.value = true;
if (props.model.document) {
if (props.model.document_id) {
menuItems.value.push({
key: 1,
text: "t.rename",
Expand Down Expand Up @@ -258,13 +263,14 @@ export default {
// References
menu,
isOpen,
hasAdminPerm,
isModelReady,
menuItems,
modelDocument,
MODEL_TYPE,
WINDOWS,
// Methods
closeMenu,
hasAdminPerm,
isProjectGuest,
onClick,
openMenu,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="model-path-cell__last-folder" v-click-away="() => (showFullPath = false)">
<BIMDataIconFolderLocation fill color="primary" margin="0 12px 0 0" />
<BIMDataTextbox
:text="lastFolderLocation(model.document)"
:text="lastFolderLocation(model.document_id)"
cutPosition="middle"
:tooltip="false"
width="auto"
Expand All @@ -13,9 +13,9 @@
<transition name="fade">
<div v-if="hovering || showFullPath" class="model-path-cell__location">
<div
v-if="truncatedFolderLocation(model.document).length > 0"
v-if="truncatedFolderLocation(model.document_id).length > 0"
class="flex items-center"
v-for="(folder, index) in truncatedFolderLocation(model.document)"
v-for="(folder, index) in truncatedFolderLocation(model.document_id)"
:key="folder.id"
>
<div
Expand All @@ -24,7 +24,7 @@
v-if="folder.id !== 'ellipsis'"
>
<BIMDataIconFolderLocation
v-if="index === truncatedFolderLocation(model.document).length - 1"
v-if="index === truncatedFolderLocation(model.document_id).length - 1"
fill
color="primary"
margin="0 6px 0 0"
Expand All @@ -51,7 +51,7 @@
>
</BIMDataTextbox>
</div>
<div v-if="showChevron(folder, index, model.document)" class="m-x-6">
<div v-if="showChevron(folder, index, model.document_id)" class="m-x-6">
<BIMDataIconChevron size="xxxs" fill color="default" />
</div>
</div>
Expand All @@ -72,7 +72,10 @@
<script>
import { ref, onDeactivated, onActivated } from "vue";
import { useI18n } from "vue-i18n";
import { FILE_TYPE } from "../../../../../config/files.js";
import { useFiles } from "../../../../../state/files.js";
import { getAscendants } from "../../../../../utils/file-structure.js";

export default {
props: {
model: {
Expand All @@ -87,6 +90,7 @@ export default {
emits: ["go-folders-view"],
setup(props, { emit }) {
const { t } = useI18n();
const { fileStructureHandler: handler } = useFiles();

const folderLocation = (model) => {
const parentFolders = getAscendants(model, props.allFolders)
Expand All @@ -98,8 +102,10 @@ export default {
return parentFolders;
};

const truncatedFolderLocation = (model) => {
const parentFolders = folderLocation(model);
const truncatedFolderLocation = (docId) => {
const doc = handler.get({ nature: FILE_TYPE.DOCUMENT, id: docId });

const parentFolders = folderLocation(doc);
const maxFoldersToShow = 4;

if (parentFolders.length > maxFoldersToShow) {
Expand All @@ -112,8 +118,10 @@ export default {
return parentFolders;
};

const lastFolderLocation = (model) => {
const parentFolders = getAscendants(model, props.allFolders);
const lastFolderLocation = (docId) => {
const doc = handler.get({ nature: FILE_TYPE.DOCUMENT, id: docId });

const parentFolders = getAscendants(doc, props.allFolders);
return parentFolders[0]?.name ?? t("t.rootFolder");
};

Expand All @@ -125,11 +133,12 @@ export default {
emit("go-folders-view", selectedFolder);
};

const showChevron = (folder, index, model) => {
const showChevron = (folder, index, docId) => {
const folderLocation = truncatedFolderLocation(docId);
return (
index < truncatedFolderLocation(model).length - 1 &&
index < folderLocation.length - 1 &&
folder.id !== "ellipsis" &&
truncatedFolderLocation(model)[index + 1].id !== "ellipsis"
folderLocation[index + 1].id !== "ellipsis"
);
};

Expand Down
2 changes: 1 addition & 1 deletion src/services/ModelService.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ModelService {

async fetchModels(project) {
try {
return await this.callQueue.push(() => apiClient.modelApi.getModels(project.cloud.id, project.id));
return await this.callQueue.push(() => apiClient.modelApi.getModelsSummary(project.cloud.id, project.id));
} catch (error) {
ErrorService.handleError(
new RuntimeError(ERRORS.MODELS_FETCH_ERROR, error)
Expand Down
9 changes: 3 additions & 6 deletions src/state/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,11 @@ const updateModels = async (project, models) => {
};

const updateModelName = async (project, model, name) => {
// In order to update a model name we have to update the name
// of its assiociated document.
// In order to update a model name we have to update the name of its assiociated document.
const { updateFiles } = useFiles();
const [newDocument] = await updateFiles(project, [
{ ...model.document, name }
]);
await updateFiles(project, [{ id: model.document_id, name }]);

return { ...model, name, document: newDocument };
return { ...model, name };
};

const mergeModels = async (project, models, name) => {
Expand Down
6 changes: 0 additions & 6 deletions src/state/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@ function hasAdminPerm(project, file) {
(isProjectAdmin(project) || files.every(f => f?.user_permission === FILE_PERMISSION.READ_WRITE));
}

function hasAdminPermModel(project, model) {
const models = [].concat(model);
return hasAdminPerm(project, models.map(m => m.document));
}

export function useUser() {
const readonlyState = readonly(state);
return {
Expand All @@ -142,6 +137,5 @@ export function useUser() {
isFavoriteProject,
isGuidedTourComplete,
hasAdminPerm,
hasAdminPermModel,
};
}
Loading