-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* create BcfTopicSnapshotsActions file * add translations * use BcfTopicSnapshotsActions * fix snapshot style * delete dead code * fix img in BcfTopicsSnapshots
- Loading branch information
Showing
6 changed files
with
155 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/components/bcf-topic-form/bcf-topic-snapshots-actions/BcfTopicSnapshotsActions.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.bcf-topic-snapshots-actions { | ||
&:not(.bcf-topic-snapshots-actions__xs) { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 6px; | ||
} | ||
} |
128 changes: 128 additions & 0 deletions
128
src/components/bcf-topic-form/bcf-topic-snapshots-actions/BcfTopicSnapshotsActions.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
<template> | ||
<div | ||
v-if="isXs" | ||
class="bcf-topic-snapshots-actions flex" | ||
:class="{ 'bcf-topic-snapshots-actions__xs': isXs }" | ||
> | ||
<BIMDataTooltip | ||
:disabled="viewpoints.length >= 4" | ||
:text="$t('BcfComponents.BcfTopicForm.takeSnapshot')" | ||
color="primary" | ||
position="right" | ||
> | ||
<BIMDataButton | ||
color="default" | ||
ghost | ||
rounded | ||
icon | ||
@click="createViewpoints" | ||
:disabled="viewpoints.length >= 4" | ||
> | ||
<BIMDataIconCamera size="s" /> | ||
</BIMDataButton> | ||
</BIMDataTooltip> | ||
<BIMDataTooltip | ||
:disabled="viewpoints.length >= 4" | ||
:text="$t('BcfComponents.BcfTopicForm.importFile')" | ||
color="primary" | ||
position="right" | ||
> | ||
<BIMDataButton color="default" ghost rounded icon :disabled="viewpoints.length >= 4"> | ||
<label for="files" class="flex items-center"> | ||
<BIMDataIconUnarchive fill color="default" size="s" /> | ||
</label> | ||
<input | ||
:disabled="viewpoints.length >= 4" | ||
hidden | ||
id="files" | ||
type="file" | ||
multiple | ||
accept="image/png, image/jpeg" | ||
@change="uploadViewpoints" | ||
/> | ||
</BIMDataButton> | ||
</BIMDataTooltip> | ||
</div> | ||
<div v-else class="bcf-topic-snapshots-actions"> | ||
<BIMDataButton color="primary" fill radius @click="createViewpoints"> | ||
<BIMDataIconCamera size="s" margin="0 6px 0 0" /> | ||
<span>{{ $t("BcfComponents.BcfTopicForm.takeSnapshot") }}</span> | ||
</BIMDataButton> | ||
<BIMDataButton color="primary" outline radius> | ||
<label for="files" class="flex items-center"> | ||
<BIMDataIconUnarchive fill color="default" size="s" margin="0 6px 0 0" /> | ||
<span>{{ $t("BcfComponents.BcfTopicForm.importFile") }}</span> | ||
</label> | ||
<input | ||
:disabled="viewpoints.length >= 4" | ||
hidden | ||
id="files" | ||
type="file" | ||
multiple | ||
accept="image/png, image/jpeg" | ||
@change="uploadViewpoints" | ||
/> | ||
</BIMDataButton> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
props: { | ||
isXs: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
viewpoints: { | ||
type: Array, | ||
default: () => [], | ||
}, | ||
getViewers: { | ||
type: Function, | ||
}, | ||
}, | ||
emits: ["create-viewpoint"], | ||
setup(props, { emit }) { | ||
const createViewpoints = () => { | ||
const viewers = Object.values(props.getViewers?.() ?? {}).flat(); | ||
viewers.forEach(async (viewer) => { | ||
const viewpoint = await viewer.getViewpoint(); | ||
emit("create-viewpoint", viewpoint); | ||
}); | ||
}; | ||
const uploadViewpoints = (event) => { | ||
[...event.target.files].forEach((file) => { | ||
let type; | ||
if (file.type === "image/png") { | ||
type = "png"; | ||
} else if (file.type === "image/jpeg") { | ||
type = "jpg"; // `jpeg` is not a valid value, only `jpg` is | ||
} else { | ||
type = file.type; | ||
} | ||
const reader = new FileReader(); | ||
reader.addEventListener("load", () => { | ||
const viewpoint = { | ||
snapshot: { | ||
snapshot_type: type, | ||
snapshot_data: reader.result, | ||
}, | ||
}; | ||
emit("create-viewpoint", viewpoint); | ||
}); | ||
reader.readAsDataURL(file); | ||
}); | ||
}; | ||
return { | ||
// Methods | ||
createViewpoints, | ||
uploadViewpoints, | ||
}; | ||
}, | ||
}; | ||
</script> | ||
<style scoped lang="scss" src="./BcfTopicSnapshotsActions.scss"></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,5 @@ | |
justify-content: center; | ||
align-items: center; | ||
border: 2px dashed var(--color-silver); | ||
cursor: pointer; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters