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
36 changes: 0 additions & 36 deletions src/components/generic/address-input/AddressInput.scss

This file was deleted.

39 changes: 38 additions & 1 deletion src/components/generic/address-input/AddressInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,41 @@ export default {
};
</script>

<style scoped lang="scss" src="./AddressInput.scss"></style>
<style scoped lang="css">
.address-input {
position: relative;
display: inline-block;

.address-input__suggestions {
position: absolute;
z-index: 1;
top: 100%;
left: 0;
width: 100%;
margin-top: calc(var(--spacing-unit) / 2);
padding: calc(var(--spacing-unit) / 2) 0;
border-radius: 2px;
box-shadow: var(--box-shadow);
background-color: var(--color-white);

.address-input__suggestions__item {
display: flex;
align-items: center;
gap: calc(var(--spacing-unit) / 2);
padding: var(--spacing-unit);
cursor: pointer;

&.hovered,
&:hover {
background-color: var(--color-silver-light);
}

.address-input__suggestions__item__icon {
width: 16px;
height: 16px;
color: var(--color-primary);
}
}
}
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,25 @@
gap: var(--spacing-unit);
padding: calc(var(--spacing-unit) / 2) var(--spacing-unit);

transition: padding-bottom 0.3s ease-out;

&.submit {
padding-bottom: calc(var(--spacing-unit) * 2);
}

.model-location-form__form-control__input {
flex-grow: 1;
font-size: 1rem;
}

.model-location-form__form-control__checkbox {
position: absolute;
bottom: calc(0px - var(--spacing-unit) * 2);
text-wrap: nowrap;
}

.model-location-form__form-control__close-btn {
color: var(--color-granite-light);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
:longitude="inputLongitude"
:latitude="inputLatitude"
/>
<div class="model-location-form__form-control">
<div class="model-location-form__form-control" :class="{ submit: isSubmitStep }">
<AddressInput
class="model-location-form__form-control__input"
:placeholder="$t('ModelLocationForm.addressInputPlaceholder')"
Expand All @@ -21,10 +21,18 @@
</BIMDataButton>
</template>
<template v-else>
<BIMDataButton color="primary" fill radius @click="submitAddress">
{{ $t("t.validate") }}
</BIMDataButton>
<BIMDataButton color="default" outline radius @click="cancel">
<div style="position: relative">
<BIMDataCheckbox
v-show="isSubmitStep"
class="model-location-form__form-control__checkbox"
v-model="applyToAllModels"
:text="$t('ModelLocationForm.applyToAllModels')"
/>
<BIMDataButton color="primary" fill radius @click="submitAddress">
{{ $t("t.validate") }}
</BIMDataButton>
</div>
<BIMDataButton color="default" outline radius @click="changeAddress">
{{ $t("t.change") }}
</BIMDataButton>
</template>
Expand Down Expand Up @@ -81,7 +89,7 @@ const props = defineProps({

const emit = defineEmits(["close", "location-updated"]);

const { createModelLocation, updateModelLocation } = useModels();
const { createModelLocation, updateModelLocation, updateProjectModelsLocation } = useModels();

const isSubmitStep = ref(false);
const checkLoading = ref(false);
Expand All @@ -90,6 +98,7 @@ const submitLoading = inject("loading", false);
const inputAddress = ref("");
const inputLongitude = ref(0);
const inputLatitude = ref(0);
const applyToAllModels = ref(false);

const checkAddress = async () => {
if (inputAddress.value) {
Expand All @@ -106,17 +115,19 @@ const checkAddress = async () => {

const submitAddress = async () => {
const [latDMS, longDMS] = DD2DMS(inputLatitude.value, inputLongitude.value)
console.log([inputLatitude.value, inputLongitude.value])
console.log([latDMS, longDMS])

const location = {
site: props.site,
address: inputAddress.value,
longitude: longDMS,
latitude: latDMS
};

try {
submitLoading.value = true;
if (props.site) {
if (applyToAllModels.value) {
await updateProjectModelsLocation(props.project, location);
} else if (props.site) {
await updateModelLocation(props.project, props.model, location);
} else {
await createModelLocation(props.project, props.model, location);
Expand All @@ -127,9 +138,10 @@ const submitAddress = async () => {
}
};

const cancel = () => {
const changeAddress = () => {
isSubmitStep.value = false;
};

const close = () => {
inputAddress.value = "";
isSubmitStep.value = false;
Expand Down
5 changes: 3 additions & 2 deletions src/i18n/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@
"addLocationButtonText": "Fill in"
},
"ModelLocationForm": {
"addressInputPlaceholder": "Enter address"
"addressInputPlaceholder": "Enter address",
"applyToAllModels": "Apply to all models"
},
"ModelsActionBar": {
"mergeButtonText": "Merge"
Expand Down Expand Up @@ -981,4 +982,4 @@
"title": "Delete {visasCount} visas",
"message": "You are about to delete the visas on the following files:"
}
}
}
5 changes: 3 additions & 2 deletions src/i18n/lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@
"addLocationButtonText": "Renseigner"
},
"ModelLocationForm": {
"addressInputPlaceholder": "Entrer une adresse"
"addressInputPlaceholder": "Entrer une adresse",
"applyToAllModels": "Appliquer à tous les modèles"
},
"ModelsActionBar": {
"mergeButtonText": "Fusionner"
Expand Down Expand Up @@ -981,4 +982,4 @@
"title": "Suppression de {visasCount} visas",
"message": "Vous êtes sur le point de supprimer les visas sur les fichiers suivants :"
}
}
}
1 change: 0 additions & 1 deletion src/services/FileService.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import eachLimit from "async/eachLimit";
import { FILE_TYPE } from "../config/files.js";
import { download } from "../utils/download.js";
import { segregate } from "../utils/file-structure.js";
Expand Down
57 changes: 34 additions & 23 deletions src/state/models.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import eachLimit from "async/eachLimit";
import { reactive, readonly, toRefs } from "vue";
import ModelService from "../services/ModelService.js";

Expand Down Expand Up @@ -80,18 +81,12 @@ const fetchModelLocation = async (project, model) => {
);
let siteAddressValue, refLongitudeValue, refLatitudeValue;
if (site && site.attributes) {
// Extract SiteAddress, RefLongitude and RefLatitude
// values from model site attributes.
// Extract SiteAddress, RefLongitude and RefLatitude values from model site attributes.
const { properties } = site.attributes;
siteAddressValue = (
properties.find(p => p.definition.name === "SiteAddress") || {}
).value;
refLongitudeValue = (
properties.find(p => p.definition.name === "RefLongitude") || {}
).value;
refLatitudeValue = (
properties.find(p => p.definition.name === "RefLatitude") || {}
).value;
const prop = name => properties.find(p => p.definition.name === name);
siteAddressValue = prop("SiteAddress")?.value;
refLongitudeValue = prop("RefLongitude")?.value;
refLatitudeValue = prop("RefLatitude")?.value;
}
return {
site,
Expand Down Expand Up @@ -138,18 +133,14 @@ const updateModelLocation = async (
{ site, address, longitude, latitude }
) => {
let siteAddressID, refLongitudeID, refLatitudeID;
// Extract SiteAddress, RefLongitude and RefLatitude
// IDs from model site attributes.

// Extract SiteAddress, RefLongitude and RefLatitude IDs from model site attributes.
const { properties } = site.attributes;
siteAddressID = (
properties.find(p => p.definition.name === "SiteAddress") || {}
).id;
refLongitudeID = (
properties.find(p => p.definition.name === "RefLongitude") || {}
).id;
refLatitudeID = (
properties.find(p => p.definition.name === "RefLatitude") || {}
).id;
const prop = name => properties.find(p => p.definition.name === name);
siteAddressID = prop("SiteAddress")?.id;
refLongitudeID = prop("RefLongitude")?.id;
refLatitudeID = prop("RefLatitude")?.id;

const props = [
{ id: siteAddressID, name: "SiteAddress", value: address },
{ id: refLongitudeID, name: "RefLongitude", value: longitude },
Expand All @@ -164,6 +155,25 @@ const updateModelLocation = async (
return newProperties;
};

const updateProjectModelsLocation = (project, location) => {
return eachLimit(
state.projectModels,
5,
async model => {
const [site] = await ModelService.fetchModelElementsByType(
project,
model,
"IfcSite"
);
if (site) {
await updateModelLocation(project, model, { ...location, site });
} else {
await createModelLocation(project, model, location);
}
}
);
};

export function useModels() {
const readonlyState = readonly(state);
return {
Expand All @@ -181,6 +191,7 @@ export function useModels() {
softDeleteModels,
fetchModelLocation,
createModelLocation,
updateModelLocation
updateModelLocation,
updateProjectModelsLocation,
};
}
Loading