Skip to content

Commit

Permalink
PATCH: fix: apply migration changes
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasRichel committed Jul 4, 2023
1 parent 8e11518 commit 25492cf
Show file tree
Hide file tree
Showing 12 changed files with 253 additions and 51 deletions.
14 changes: 10 additions & 4 deletions src/BIMDataFileManager/BIMDataFileManager.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import "@bimdata/design-system/dist/scss/BIMDataVariables.scss";

.bimdata-file-manager {
width: 100%;

Expand Down Expand Up @@ -68,6 +66,14 @@
}
}

&__pdf-page-selector {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}

&__modal {
position: absolute;
top: 0px;
Expand Down Expand Up @@ -107,9 +113,9 @@
align-items: center;
justify-content: center;
font-size: small;
color: $color-granite;
color: var(--color-granite);
span {
margin-top: calc($spacing-unit * 2);
margin-top: calc(var(--spacing-unit) * 2);
}
}
}
Expand Down
72 changes: 59 additions & 13 deletions src/BIMDataFileManager/BIMDataFileManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
@loaded="onFileLoaded(file, $event)"
:writeAccess="currentFolder.user_permission >= 100"
:viewPdf="viewPdf"
:pdfModelLoading="pdfModelLoading === file.id"
/>
</BIMDataResponsiveGrid>
</div>
Expand All @@ -130,6 +131,16 @@
</div>
</template>
<BIMDataLoading v-else />
<div
v-if="pdfPageSelectorDisplayed"
class="bimdata-file-manager__pdf-page-selector"
>
<PdfPageSelector
:model="pdfModel"
@select="selectPdfPage"
@close="selectPdfPage"
/>
</div>
<div class="bimdata-file-manager__modal" v-if="modalDisplayed">
<RenameModal
:projectId="projectId"
Expand Down Expand Up @@ -158,11 +169,13 @@
<script>
import { makeBIMDataApiClient } from "@bimdata/typescript-fetch-api-client";
import BIMDataPDFViewer from "../BIMDataPDFViewer/BIMDataPDFViewer.vue";
import FileCard from "./components/FileCard.vue";
import NewFolderButton from "./components/newFolder/NewFolderButton.vue";
import UploadFileButton from "./components/UploadFileButton.vue";
import RenameModal from "./components/modals/RenameModal.vue";
import DeleteModal from "./components/modals/DeleteModal.vue";
import PdfPageSelector from "./components/PdfPageSelector.vue";
import getFlattenTree from "./utils/flattenTree.js";
import { downloadFiles } from "./utils/files.js";
Expand All @@ -182,6 +195,8 @@ export default {
UploadFileButton,
RenameModal,
DeleteModal,
BIMDataPDFViewer,
PdfPageSelector,
},
provide() {
return {
Expand Down Expand Up @@ -241,6 +256,10 @@ export default {
type: Boolean,
default: false,
},
pdfPageSelect: {
type: Boolean,
default: false,
},
},
data() {
return {
Expand All @@ -255,6 +274,9 @@ export default {
entityDeletable: false,
successFileIds: [],
pdfToView: null,
pdfModel: null,
pdfModelLoading: null,
pdfPageSelectorDisplayed: false,
};
},
computed: {
Expand Down Expand Up @@ -359,15 +381,16 @@ export default {
},
methods: {
isDisabled(file) {
if (file.file) {
const extensionMatch = file.file_name.match(/\.(\w+$)/);
const fileExtension = extensionMatch && extensionMatch[1];
return (
this.select &&
this.selectableFileTypes.length > 0 &&
!(fileExtension && this.selectableFileTypes.includes(fileExtension))
);
}
if (file.nature === "Folder") return false;
const extensionMatch = file.file_name?.match(/\.(\w+$)/);
const fileExtension = extensionMatch && extensionMatch[1];
return (
this.select &&
this.selectableFileTypes.length > 0 &&
!(fileExtension && this.selectableFileTypes.includes(fileExtension))
);
},
onKeyDown(e) {
if (e.key === "Escape") {
Expand Down Expand Up @@ -508,21 +531,44 @@ export default {
content: newFolder,
});
},
onToggleFileSelect(file) {
async onToggleFileSelect(file) {
if (this.isFileSelected(file)) {
this.selectedFiles = this.selectedFiles.filter(
selectedFile => selectedFile !== file
({ document }) => document !== file
);
} else {
if (!this.multi) {
this.selectedFiles = [];
}
this.selectedFiles.push(file);
let pdfPage = null;
if (this.pdfPageSelect && file.model_type === "PDF") {
// If 'pdfPageSelect' mode is on and the selected file is a PDF model
// fetch the corresponding model to check its children (pages)
this.pdfModelLoading = file.id;
const model = await this.apiClient.modelApi.getModel(
this.spaceId,
file.model_id,
this.projectId
);
this.pdfModelLoading = null;
if (model.children?.length > 0) {
// If this is a multipage PDF open the page selector
this.pdfModel = model;
this.pdfPageSelectorDisplayed = true;
pdfPage = await new Promise(res => (this.selectPdfPage = res));
this.pdfPageSelectorDisplayed = false;
this.pdfModel = null;
if (!pdfPage) return; // If no page has been selected then the file is not selected
}
}
this.selectedFiles.push({ document: file, pdfPage });
}
this.$emit("selection-change", this.selectedFiles);
},
isFileSelected(file) {
return this.selectedFiles.includes(file);
return this.selectedFiles.some(({ document }) => file === document);
},
onBreadcrumClick(step) {
this.currentFolder = step;
Expand Down
37 changes: 22 additions & 15 deletions src/BIMDataFileManager/components/FileCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,24 @@
<BIMDataIcon name="ellipsis" size="l" fill color="granite-light" />
</BIMDataButton>
<div v-else-if="!isFolder">
<BIMDataCheckbox
:disabled="disabled"
v-if="multiSelect"
:modelValue="selected"
class="file-card__content__header__btn-menu__checkbox"
/>
<BIMDataRadio
:disabled="disabled"
v-else
big
:modelValue="selected"
name="BIMDataFileCardRadio"
/>
<template v-if="pdfModelLoading">
<BIMDataSpinner style="margin: 10px" />
</template>
<template v-else>
<BIMDataCheckbox
:disabled="disabled"
v-if="multiSelect"
:modelValue="selected"
class="file-card__content__header__btn-menu__checkbox"
/>
<BIMDataRadio
:disabled="disabled"
v-else
big
:modelValue="selected"
name="BIMDataFileCardRadio"
/>
</template>
</div>
</div>
<template v-if="file.nature === 'Folder'">
Expand Down Expand Up @@ -183,6 +188,10 @@ export default {
type: Boolean,
default: false,
},
pdfModelLoading: {
type: Boolean,
default: false,
},
},
emits: [
"rename",
Expand Down Expand Up @@ -301,8 +310,6 @@ export default {
</script>

<style scoped lang="scss">
@import "@bimdata/design-system/dist/scss/BIMDataVariables.scss";
.file-card {
height: 192px;
display: flex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
<div class="multi-line-text-box__content__tail__text">
<span>{{ text }} </span>
</div>
<div class="multi-line-text-box__content__tail__ellipsis">
...
</div>
<div class="multi-line-text-box__content__tail__ellipsis">...</div>
</div>
</template>
<span class="multi-line-text-box__content__full" v-else>
Expand Down Expand Up @@ -98,7 +96,7 @@ export default {
};
</script>

<style lang="scss">
<style scoped lang="scss">
.multi-line-text-box {
position: relative;
line-height: var(--textbox-line-height, 14px);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default {
};
</script>

<style lang="scss">
<style scoped lang="scss">
.multi-line-textbox-tooltip {
width: 100%;
&__content {
Expand All @@ -35,6 +35,7 @@ export default {
}
&::before {
content: "";
display: block;
position: absolute;
top: -8px;
border: var(--color-primary) solid 8px;
Expand Down
Loading

0 comments on commit 25492cf

Please sign in to comment.