Skip to content

Commit

Permalink
fix nomenclatures'
Browse files Browse the repository at this point in the history
  • Loading branch information
lpofredc committed Nov 20, 2024
1 parent ea96078 commit 701250e
Show file tree
Hide file tree
Showing 11 changed files with 1,040 additions and 181 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Generated by Django 4.2.16 on 2024-11-20 13:40

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
dependencies = [
(
"sinp_nomenclatures",
"0004_alter_nomenclature_status_alter_source_name_and_more",
),
("cables", "0008_remove_diagnosis_sgmt_veget_integr_risk_and_more"),
]

operations = [
migrations.AlterField(
model_name="diagnosis",
name="sgmt_landscape_integr_risk",
field=models.ForeignKey(
blank=True,
help_text="Landscape level of risk",
limit_choices_to={"type__mnemonic": "risk_level"},
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="segment_landscape_risk",
to="sinp_nomenclatures.nomenclature",
verbose_name="landscape level of risk",
),
),
migrations.AlterField(
model_name="diagnosis",
name="sgmt_moving_risk",
field=models.ForeignKey(
blank=True,
help_text="Moving level of risk",
limit_choices_to={"type__mnemonic": "risk_level"},
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="segment_moving_risk",
to="sinp_nomenclatures.nomenclature",
verbose_name="moving level of risk",
),
),
]
894 changes: 894 additions & 0 deletions backend/commons/fixtures/nomenclatures_with_pk.xml

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions backend/mortality/migrations/0007_alter_mortality_infrstr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 4.2.16 on 2024-11-20 13:40

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
dependencies = [
("cables", "0009_alter_diagnosis_sgmt_landscape_integr_risk_and_more"),
("mortality", "0006_mortality_areas"),
]

operations = [
migrations.AlterField(
model_name="mortality",
name="infrstr",
field=models.ForeignKey(
blank=True,
help_text="Infrastructure related to mortality case",
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="mortality",
to="cables.infrastructure",
verbose_name="Infrastructure related to mortality case",
),
),
]
2 changes: 1 addition & 1 deletion frontend/components/data/detail/infrastructure.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<v-main scrollable>
<v-container>
<data-card-infrastructure :data="data" />
<data-card-mortality-for-infrastructure :data="data.properties.mortality" />
<data-card-mortality-for-infrastructure v-if="data.properties?.mortality?.length > 0" :data="data.properties?.mortality" />
<data-card-diagnosis v-if="lastDiag" :diagnosis="lastDiag" :infrastructure-type="type" />
<data-card-operation v-if="lastOp" :operation="lastOp" :support-id="data.properties.id"
@delete="$emit('update')" />
Expand Down
11 changes: 6 additions & 5 deletions frontend/components/form/diagnosis.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
<v-date-input v-model="formDate" label="Date de visite" inner-prepend-icon="mdi-calendar" variant="solo"
density="compact" :rules="[rules.required]" :max="new Date()" />
</v-col>
<template v-if="infrastructureType === 'point'">
<v-col cols="12">
<v-autocomplete v-model="diagData.pole_type_id" chips :items="poleTypes" item-title="label"
item-value="id" :rules="[rules.required]" hide-selected :label="$t('support.support-type')" multiple
<v-col cols="12">
<v-autocomplete v-model="diagData.pole_type_id" chips :items="armingItems" item-title="label"
item-value="id" :rules="[rules.required]" hide-selected :label="$t('armings')" multiple
deletable-chips variant="solo" density="compact" />
</v-col>
<template v-if="infrastructureType === 'point'">
<v-col cols="12" md="6">
<v-select v-model="diagData.pole_attractivity_id" :items="riskLevels" item-title="label" item-value="id"
:rules="[rules.required]" :label="$t('support.attractiveness')" variant="solo" density="compact" />
Expand Down Expand Up @@ -105,6 +105,7 @@ const infrastructureType = computed(() => (route.query.type).toLowerCase())
const diagnosisReady = ref(false)
const diagnosisId = computed(() => route.query.id_diagnosis)
const formDate = ref(new Date(Date.now() - new Date().getTimezoneOffset() * 60000))
const armingItems = computed(() => nomenclaturesStore.getArmingItems(infrastructureType.value))
const diagData: DiagData = reactive({
date: new Date(Date.now() - new Date().getTimezoneOffset() * 60000),
Expand All @@ -129,7 +130,7 @@ const rules = reactive({
// Menu items
const poleTypes = computed(() => nomenclaturesStore.poleTypeItems)
const armings = computed(() => nomenclaturesStore.armingItems)
const conditions = computed(() => nomenclaturesStore.conditionItems)
const riskLevels = computed(() => nomenclaturesStore.riskLevelItems)
Expand Down
7 changes: 5 additions & 2 deletions frontend/components/form/equipment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<v-card-text>
<v-row>
<v-col lg="4" md="12">
<v-autocomplete v-model="equipmentData.type_id" :items="equipmentType" item-title="label" item-value="id"
<v-autocomplete v-model="equipmentData.type_id" :items="equipmentItems" item-title="label" item-value="id"
:rules="[rules.required]" hide-selected :label="$t('support.support-type')" variant="solo" density="compact"
@input="updateEquipmentData" />
</v-col>
Expand All @@ -27,9 +27,12 @@
<script lang="ts" setup>
const { t } = useI18n()
const route = useRoute()
const nomenclaturesStore = useNomenclaturesStore()
const equipmentType = computed(() => nomenclaturesStore.equipmentTypeItems)
const infrastructureType = computed(() => (route.query.type).toLowerCase())
const equipmentItems = computed(() => nomenclaturesStore.getEquipmentItems(infrastructureType.value))
const rules = reactive({
required: (v: string | number) => !!v || t('valid.required'),
Expand Down
7 changes: 4 additions & 3 deletions frontend/components/form/operation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
prepend-icon="mdi-content-save-all" @click="submit">Sauvegarder</v-btn>
</v-card-actions>
</v-form>
<div>
<!-- <div>
<pre><code>{{ opData }}</code></pre>
</div>
</div> -->
</v-card>
</template>

Expand All @@ -47,7 +47,7 @@ const route = useRoute()
const coordinatesStore = useCoordinatesStore()
const cablesStore = useCablesStore()
// const nomenclaturesStore = useNomenclaturesStore()
const nomenclaturesStore = useNomenclaturesStore()
const errorStore = useErrorsStore()
const formValid = ref(false)
Expand All @@ -73,6 +73,7 @@ const opData = reactive({
geom: null,
})
const updateEquipmentData = (index, updatedEquipment) => {
opData.equipments[index] = updatedEquipment;
};
Expand Down
2 changes: 1 addition & 1 deletion frontend/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"loading-conditions-issue": "Issue with loading \"Infrastructure Condition\" options occured. You were disconnected",
"loading-img-issue": "Loading issue. File is not loaded",
"loading-ownerss-issue": "Issue with loading \"Owner\" options occured. You were disconnected",
"loading-poletypes-issue": "Issue with loading \"PoleType\" options occured. You were disconnected",
"loading-armings-issue": "Issue with loading \"PoleType\" options occured. You were disconnected",
"loading-risklevels-issue": "Issue with loading \"Risk Level\" options occured. You were disconnected",
"nomenclature_not_found_resource": "Server Data loading issue. You were disconnected",
"sending-img-issue": "An error occured. Some pictures may have not been saved in database. Please, check it"
Expand Down
3 changes: 2 additions & 1 deletion frontend/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"lowRisk": "Risque faible",
"midRisk": "Risque modéré",
"highRisk": "Risque élevé",
"armings": "Armements",
"app": {
"appShortName": "aviCable",
"appName": "Avifaune & câbles aériens",
Expand Down Expand Up @@ -127,7 +128,7 @@
"loading-conditions-issue": "un problème de chargement des options \"Etat des Infrastructures\" est survenu. Vous avez été déconnecté",
"loading-img-issue": "Erreur de chargement. Fichier non chargée",
"loading-owners-issue": "un problème de chargement des options \"Propriétaire\" est survenu. Vous avez été déconnecté",
"loading-poletypes-issue": "un problème de chargement des options \"type de Poteaux\" est survenu. Vous avez été déconnecté",
"loading-armings-issue": "un problème de chargement des options \"type de Poteaux\" est survenu. Vous avez été déconnecté",
"loading-risklevels-issue": "un problème de chargement des options \"Niveau de Risque\" est survenu. Vous avez été déconnecté",
"nomenclature_not_found_resource": "Problème Serveur de chargement des données. vous avez été déconnecté",
"sending-img-issue": "Une erreur est survenu. Des images peuvent ne pas avoir été sauvegardée dans la base de données. Veuillez vérifier",
Expand Down
4 changes: 2 additions & 2 deletions frontend/static/errorConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
"code": 704,
"msg": "loading-owners-issue"
},
"get_infrstr_poletypes": {
"get_infrstr_armings": {
"code": 705,
"msg": "loading-poletypes-issue"
"msg": "loading-armings-issue"
},
"get_infrstr_risklevels": {
"code": 706,
Expand Down
Loading

0 comments on commit 701250e

Please sign in to comment.