Commit 9b572fec authored by hypsug0's avatar hypsug0
Browse files

feat: filter form detail input by type contact

parent 80eec709
......@@ -980,6 +980,52 @@ const sightingSearchBlock = () => {
// Sighting Form app
const countDetailBiomForm = [
'sex',
'age',
'time',
'device',
'method',
'manipulator',
'validator',
'transmitter',
'ab',
'd5',
'd3',
'pouce',
'queue',
'tibia',
'pied',
'cm3',
'tragus',
'poids',
'testicule',
'epididyme',
'tuniq_vag',
'gland_taille',
'gland_coul',
'mamelle',
'gestation',
'epiphyse',
'chinspot',
'usure_dent',
'comment',
]
const countDetailAcousticForm = ['time', 'method', 'count', 'unit', 'comment']
const countDetailOtherForm = [
"time",
"method",
"sex",
"age",
"count",
"unit",
"precision",
"transmitter",
"comment",
]
const CountDetailObject = (lastdata) => {
return {
id_countdetail: null,
......@@ -1039,36 +1085,142 @@ new Vue({
},
})
Vue.component('specieSelect', {
Vue.component('observerSelect', {
data() {
return {
selected: this.value,
dict: [],
options: [],
edit: false,
}
},
template: `<v-select class="form-control v-select-style" :options="options" :reduce="e => e.id" label="codesp" v-model="model">
<template v-slot:option="option">
<span class="label label-default" :class="option.sp_true?'label-success':'label-default' ">{{option.codesp}}</span> {{option.sci_name}}
</template>
<template #selected-option="{ sp_true, codesp, sci_name }">
<span class="label" :class="sp_true?'label-success':'label-default' ">{{codesp}}</span> {{sci_name}}
</template>
</v-select>`,
props: {
value: {
type: Number,
},
},
template: `
<span>
<v-select :disabled="!edit" class="form-control v-select-style" :options="options" :reduce="e => e.id" label="codesp" v-model="model">
<template v-slot:option="option">
<span class="label label-default" :class="option.sp_true?'label-success':'label-default' ">{{option.codesp}}</span> {{option.sci_name}}
</template>
<template #selected-option="{ sp_true, codesp, sci_name }">
<span class="label" :class="sp_true?'label-success':'label-default' ">{{codesp}}</span>&nbsp;{{sci_name}}
</template>
</v-select>
<i class="fas fa-edit" :class="edit ? 'text-muted':'text-warning'" @click="editState"></i>
</span>
`,
computed: {
model: {
get() {
console.debug('actual', this.selected)
return this.selected
return this.value
},
set(newValue) {
console.debug('test', newValue)
this.$emit('input', newValue)
},
},
selectedDetail: function () {
return this.options.find((e) => e.id == this.model)
},
},
methods: {
editState() {
this.edit = !this.edit
},
getSpecieDict() {
this.edit = this.value == null
if (localStorage.getItem('species') == null) {
console.debug('No dict in localStorage')
$http
.get('/api/v1/dict/specie')
.then((response) => {
console.debug(
'Saving downloaded dicts in localStorage',
response.data
)
this.options = response.data
localStorage.setItem(
'species',
JSON.stringify(this.options)
)
})
.catch((err) => {
console.error(err)
})
} else {
console.debug('loading species dict from localStorage')
this.options = JSON.parse(localStorage.getItem('species'))
}
this.options = this.options
.sort((a, b) => {
const ca = a.codesp,
cb = b.codesp
return ca < cb ? -1 : ca > cb ? 1 : 0
})
.sort((a, b) => Number(b.sp_true) - Number(a.sp_true))
},
},
mounted() {
this.getSpecieDict()
// this.edit = this.value == null
// console.debug('mounted edit', this.value, this.edit, this.value == null)
},
})
Vue.component('specieSelect', {
data() {
return {
selected: this.value,
dict: [],
options: [],
disabled: true,
}
},
props: {
value: {
type: Number,
},
},
template: `
<span>
<v-select :disabled="disabled" class="form-control v-select-style" :options="options" :reduce="e => e.id" label="codesp" v-model="model">
<template v-slot:option="option">
<span class="label label-default" :class="option.sp_true?'label-success':'label-default' ">{{option.codesp}}</span> {{option.sci_name}}
</template>
<template #selected-option="{ sp_true, codesp, sci_name }">
<span class="label" :class="sp_true?'label-success':'label-default' ">{{codesp}}</span>&nbsp;{{sci_name}}
</template>
</v-select>
<i class="fas fa-edit" :class="disabled ? 'text-muted':'text-warning'" @click="disabled = !disabled"></i>
</span>
`,
computed: {
model: {
get() {
console.debug('actual', this.selected, this.disabled)
this.disabled = this.value != null
return this.value
},
set(newValue) {
console.debug('test', newValue)
this.$emit('input', newValue)
},
},
selectedDetail: function () {
return this.options.find((e) => e.id == this.model)
},
},
methods: {
editState() {
this.disabled = !this.disabled
},
getSpecieDict() {
this.edit = this.value == null
if (localStorage.getItem('species') == null) {
console.debug('No dict in localStorage')
$http
......@@ -1102,6 +1254,13 @@ Vue.component('specieSelect', {
},
mounted() {
this.getSpecieDict()
// this.edit = this.value == null
console.debug(
'mounted edit',
this.value,
this.disabled,
this.value != null
)
},
})
......@@ -1112,6 +1271,9 @@ Vue.component('dictSelect', {
}
},
props: {
value: {
type: Number,
},
options: {
type: Array,
required: true,
......@@ -1128,11 +1290,9 @@ Vue.component('dictSelect', {
computed: {
model: {
get() {
console.debug('actual', this.selected)
return this.selected
return this.value
},
set(newValue) {
console.debug('test', newValue)
this.$emit('input', newValue)
},
},
......@@ -1144,6 +1304,8 @@ const sigthingFormApp = (id_session, type_contact) => {
return value >= 0
})
const form_fields = type_contact == 'vm' ? countDetailBiomForm : type_contact=='du' ? countDetailAcousticForm : countDetailOtherForm
VeeValidate.extend('required', {
validate(value) {
return {
......@@ -1174,6 +1336,7 @@ const sigthingFormApp = (id_session, type_contact) => {
return {
data: [],
dicts: {},
form_fields: type_contact == 'vm' ? countDetailBiomForm : type_contact=='du' ? countDetailAcousticForm : countDetailOtherForm,
url: sightingDataListUrl,
loadingMessage: true,
initialDataLoaded: false,
......@@ -1192,9 +1355,8 @@ const sigthingFormApp = (id_session, type_contact) => {
}
},
methods: {
findCondition (dict, code) {
console.log('<findCondition>', dict.find(e => e.code === code))
return dict.find(e => e.code === code)
findCondition(dict, code) {
return dict.find((e) => e.code === code)
},
selectItem(i) {
this.selectedItem = i
......@@ -1317,12 +1479,16 @@ const sigthingFormApp = (id_session, type_contact) => {
contact = contact || null
return contact ? dict.filter((e) => e.contact == contact) : dict
},
selectedCode(dict, value, code) {
// console.debug('selectedCode', dict, value, code)
// console.debug('find', dict.find(e=>e.id==value))
const select = dict.find((e) => e.id == value)
return dict.find((e) => e.id == value)?.code == code
},
taxaSelectOptions(dict, contact) {
return
},
getDictSpecie() {
},
getDictSpecie() {},
getDicts() {
if (localStorage.getItem('dicts') == null) {
console.debug('No dicts in localStorage')
......@@ -1388,8 +1554,8 @@ const sigthingFormApp = (id_session, type_contact) => {
// }
// },
computed: {
species() {
return this.data.map(e=> e.codesp)
species() {
return this.data.map((e) => e.codesp)
},
},
watch: {
......
......@@ -170,34 +170,35 @@ Observations de la session {{object.name}}
v-model:title="cd.id_sighting" v-model:content="cd.id_sighting" />
<input type="hidden" id="id" placeholder="id_countdetail" v-model:title="cd.id_countdetail"
v-model:content="cd.id_countdetail" />
<div class="form-group">
<div class="form-group" v-if="form_fields.includes('time')">
<label class="control-label" for="Time">Heure</label>
<input type="time" class="form-control input-sm" class="form-control" id="Time"
placeholder="Heure du contact" v-model:title="cd.time" v-model:content="cd.time" />
</div>
<validation-provider rules="required" immediate v-slot="{ errors, valid, invalid, classes}" slim>
<validation-provider v-if="form_fields.includes('method')" rules="required" immediate v-slot="{ errors, valid, invalid, classes}" slim>
<div class="form-group" :class='classes'>
<label class="control-label" for="Method">Méthode</label>
<dict-select :options="filteredDict(dicts.Method, typeContact)" v-model="cd.method"/>
<span v-if='invalid' class="help-block text-danger">[[ errors[0] ]]</span>
</div>
</validation-provider>
<div class="col form-group">
<div class="col form-group" v-if="form_fields.includes('sex')">
<label class="control-label" for="Sex">Sexe</label>
<dict-select :options="filteredDict(dicts.Sex)" v-model="cd.sex"/>
</div>
<div class="form-group">
<div class="form-group" v-if="form_fields.includes('age')">
<label class="control-label" for="Age">Age</label>
<dict-select :options="filteredDict(dicts.Age)" v-model="cd.age"/>
</div>
<validation-provider v-if="filteredDict(dicts.CountPrecision, typeContact).length > 0" immediate v-slot="{ errors, valid, invalid, classes}" slim>
<validation-provider v-if="form_fields.includes('precision') && filteredDict(dicts.CountPrecision, typeContact).length > 0 && !selectedCode(dicts.Method, cd.method, 'vvnc')" immediate v-slot="{ errors, valid, invalid, classes}" slim>
<div class="form-group" class="form-group" :class='classes'>
<label class="control-label" for="Precision">Précision</label>
<dict-select :options="filteredDict(dicts.CountPrecision, typeContact)" v-model="cd.precision"/>
<span v-if='invalid' class="help-block">[[ errors[0] ]]</span>
</div>
</validation-provider>
<validation-provider immediate rules="required|positive" v-slot="{ errors, valid, invalid, classes}"
<validation-provider v-if="form_fields.includes('count') && !selectedCode(dicts.Method, cd.method, 'vvnc')" immediate rules="required|positive" v-slot="{ errors, valid, invalid, classes}"
slim>
<div class="form-group" :class="classes">
<label class="control-label" for="Count">Dénombrement</label>
......@@ -206,14 +207,14 @@ Observations de la session {{object.name}}
<span v-if='invalid' class="help-block">[[ errors[0] ]]</span>
</div>
</validation-provider>
<validation-provider v-if="filteredDict(dicts.CountPrecision, typeContact).length > 0" rules="required" v-slot="{ errors, valid, invalid, classes}" slim>
<validation-provider v-if="form_fields.includes('unit') && filteredDict(dicts.CountPrecision, typeContact).length > 0 && !selectedCode(dicts.Method, cd.method, 'vvnc')" rules="required" v-slot="{ errors, valid, invalid, classes}" slim>
<div class="form-group" :class="classes">
<label class="control-label" for="Unit">Unité</label>
<dict-select :options="filteredDict(dicts.CountUnit, typeContact)" v-model="cd.unit"/>
<span v-if='invalid' class="help-block">[[ errors[0] ]]</span>
</div>
</validation-provider>
<validation-provider rules="positive" v-slot="{ errors, valid, invalid, classes}" slim>
<validation-provider v-if="form_fields.includes('ab')" rules="positive" v-slot="{ errors, valid, invalid, classes}" slim>
<div class="form-group" :class="classes">
<label class="control-label" for="AB">Avant-bras</label>
<input type="number" id="AB" class="form-control input-sm" v-model:title="cd.ab"
......@@ -221,7 +222,7 @@ Observations de la session {{object.name}}
<span v-if='invalid' class="help-block">[[ errors[0] ]]</span>
</div>
</validation-provider>
<validation-provider rules="positive" v-slot="{ errors, valid, invalid, classes}" slim>
<validation-provider v-if="form_fields.includes('d5')" rules="positive" v-slot="{ errors, valid, invalid, classes}" slim>
<div class="form-group" :class="classes">
<label class="control-label" for="D5">Doigt 5</label>
<input type="number" id="D5" class="form-control input-sm" v-model:title="cd.d5"
......@@ -229,7 +230,7 @@ Observations de la session {{object.name}}
<span v-if='invalid' class="help-block">[[ errors[0] ]]</span>
</div>
</validation-provider>
<validation-provider rules="positive" v-slot="{ errors, valid, invalid, classes}" slim>
<validation-provider v-if="form_fields.includes('pouce')" rules="positive" v-slot="{ errors, valid, invalid, classes}" slim>
<div class="form-group" :class="classes">
<label class="control-label" for="Pouce">Pouce</label>
<input type="number" id="Pouce" class="form-control input-sm" v-model:title="cd.pouce"
......@@ -237,7 +238,7 @@ Observations de la session {{object.name}}
<span v-if='invalid' class="help-block">[[ errors[0] ]]</span>
</div>
</validation-provider>
<validation-provider rules="positive" v-slot="{ errors, valid, invalid, classes}" slim>
<validation-provider v-if="form_fields.includes('queue')" rules="positive" v-slot="{ errors, valid, invalid, classes}" slim>
<div class="form-group" :class="classes">
<label class="control-label" for="Queue">Queue</label>
<input type="number" id="Queue" class="form-control input-sm" v-model:title="cd.queue"
......@@ -245,7 +246,7 @@ Observations de la session {{object.name}}
<span v-if='invalid' class="help-block">[[ errors[0] ]]</span>
</div>
</validation-provider>
<validation-provider rules="positive" v-slot="{ errors, valid, invalid, classes}" slim>
<validation-provider v-if="form_fields.includes('tibia')" rules="positive" v-slot="{ errors, valid, invalid, classes}" slim>
<div class="form-group" :class="classes">
<label class="control-label" for="Tibia">Tibia</label>
<input type="number" id="Tibia" class="form-control input-sm" v-model:title="cd.tibia"
......@@ -253,7 +254,7 @@ Observations de la session {{object.name}}
<span v-if='invalid' class="help-block">[[ errors[0] ]]</span>
</div>
</validation-provider>
<validation-provider rules="positive" v-slot="{ errors, valid, invalid, classes}" slim>
<validation-provider v-if="form_fields.includes('pied')" rules="positive" v-slot="{ errors, valid, invalid, classes}" slim>
<div class="form-group" :class="classes">
<label class="control-label" for="Pied">Pied</label>
<input type="number" id="Pied" class="form-control input-sm" v-model:title="cd.pied"
......@@ -261,7 +262,7 @@ Observations de la session {{object.name}}
<span v-if='invalid' class="help-block">[[ errors[0] ]]</span>
</div>
</validation-provider>
<validation-provider rules="positive" v-slot="{ errors, valid, invalid, classes}" slim>
<validation-provider v-if="form_fields.includes('cm3')" rules="positive" v-slot="{ errors, valid, invalid, classes}" slim>
<div class="form-group" :class="classes">
<label class="control-label" for="Cm3">cm3</label>
<input type="number" id="Cm3" class="form-control input-sm" v-model:title="cd.pied"
......@@ -269,7 +270,7 @@ Observations de la session {{object.name}}
<span v-if='invalid' class="help-block">[[ errors[0] ]]</span>
</div>
</validation-provider>
<validation-provider rules="positive" v-slot="{ errors, valid, invalid, classes}" slim>
<validation-provider v-if="form_fields.includes('tragus')" rules="positive" v-slot="{ errors, valid, invalid, classes}" slim>
<div class="form-group" :class="classes">
<label class="control-label" for="Tragus">tragus</label>
<input type="number" id="Tragus" class="form-control input-sm" v-model:title="cd.pied"
......@@ -277,7 +278,7 @@ Observations de la session {{object.name}}
<span v-if='invalid' class="help-block">[[ errors[0] ]]</span>
</div>
</validation-provider>
<validation-provider rules="positive" immediate v-slot="{ errors, valid, invalid, classes}" slim>
<validation-provider v-if="form_fields.includes('poids')" rules="positive" immediate v-slot="{ errors, valid, invalid, classes}" slim>
<div class="form-group" :class="classes">
<label class="control-label" for="Poids">poids</label>
<input type="number" id="Poids" class="form-control input-sm" v-model:title="cd.pied"
......@@ -285,48 +286,48 @@ Observations de la session {{object.name}}
<span v-if='invalid' class="help-block">[[ errors[0] ]]</span>
</div>
</validation-provider>
<div v-if="cd.sex === findCondition(dicts.Sex, 'm').id" class="form-group" class="form-group">
<div v-if="form_fields.includes('testicule') && cd.sex === findCondition(dicts.Sex, 'm').id" class="form-group" class="form-group">
<label class="control-label" for="Testicule">Testicule</label>
<dict-select id="Testicule" :options="filteredDict(dicts.BiomTesticule)" v-model="cd.testicule"/>
</div>
<div v-if="cd.sex === findCondition(dicts.Sex, 'm').id" class="form-group" class="form-group">
<div v-if="form_fields.includes('epididyme') && cd.sex === findCondition(dicts.Sex, 'm').id" class="form-group" class="form-group">
<label class="control-label" for="Epididyme">Epididyme</label>
<dict-select id="Epididyme" :options="filteredDict(dicts.BiomEpipidyme)" v-model="cd.epididyme"/>
</div>
<div v-if="cd.sex === findCondition(dicts.Sex, 'm').id" class="form-group" class="form-group">
<div v-if="form_fields.includes('tuniq_vag') && cd.sex === findCondition(dicts.Sex, 'm').id" class="form-group" class="form-group">
<label class="control-label" for="TuniqVag">Tunique vaginale</label>
<dict-select :options="filteredDict(dicts.BiomTuniqVag)" v-model="cd.tuniq_vag"/>
</div>
<div class="form-group">
<div v-if="form_fields.includes('gland_coul')" class="form-group">
<label class="control-label" for="GlandCoul">Couleur des glandes salivaires</label>
<dict-select :options="filteredDict(dicts.BiomGlandCoul)" v-model="cd.gland_coul"/>
</div>
<div class="form-group" >
<div v-if="form_fields.includes('gland_taille')" class="form-group" >
<label class="control-label" for="GlandTaille">Taille des glandes salivaires</label>
<dict-select :options="filteredDict(dicts.BiomGlandTaille)" v-model="cd.gland_taille"/>
</div>
<div v-if="cd.sex === findCondition(dicts.Sex, 'f').id" class="form-group" >
<div v-if="form_fields.includes('mamelle') && cd.sex === findCondition(dicts.Sex, 'f').id" class="form-group" >
<label class="control-label" for="Mamal">Etat des mamelles</label>
<dict-select :options="filteredDict(dicts.BiomMamelle)" v-model="cd.mamelle"/>
</div>
<div v-if="cd.sex === findCondition(dicts.Sex, 'f').id" class="form-group" >
<div v-if="form_fields.includes('gestation') && cd.sex === findCondition(dicts.Sex, 'f').id" class="form-group" >
<label class="control-label" for="Gestation">Etat de la gestation</label>
<dict-select :options="filteredDict(dicts.BiomGestation)" v-model="cd.gestation"/>
</div>
<div class="form-group" class="form-group" >
<div v-if="form_fields.includes('epiphyse')" class="form-group" class="form-group" >
<label class="control-label" for="Epiphyse">Epiphyse articulaire</label>
<dict-select :options="filteredDict(dicts.BiomEpiphyse)" v-model="cd.epiphyse"/>
</div>
<div class="form-group" >
<div v-if="form_fields.includes('chinspot')" class="form-group" >
<label class="control-label" for="Chinspot">Chinspot</label>
<dict-select :options="filteredDict(dicts.BiomChinspot)" v-model="cd.chinspot"/>
</div>
<div class="form-group" >
<div v-if="form_fields.includes('usure_dent')" class="form-group" >
<label class="control-label" for="SecualStatus">Usure des dents</label>
<dict-select :options="filteredDict(dicts.BiomDent)" v-model="cd.usure_dent"/>
</div>
<div class="form-group">
<div class="form-group" v-if="form_fields.includes('comment')">
<label for="sComment">Commentaire</label>
<textarea id="sComment" class="form-control" placeholder="Commentaire" v-model="cd.comment" class="form-control" rows="3"></textarea>
</div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment