Commit 87c6b343 authored by hypsug0's avatar hypsug0
Browse files

wip: sighting form

parent 6ece3880
......@@ -1196,14 +1196,17 @@ Vue.component('specieSelect', {
<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>
<i class="fas fa-edit" :class="disabled ? 'text-muted':'text-warning'" @click="editState()"></i>
</span>
`,
computed: {
model: {
get() {
console.debug('actual', this.selected, this.disabled)
this.disabled = this.value != null
// this.disabled = this.value != null
if (!this.value) {
this.disabled = false
}
return this.value
},
set(newValue) {
......@@ -1217,7 +1220,9 @@ Vue.component('specieSelect', {
},
methods: {
editState() {
console.debug('disable bef>', this.disabled)
this.disabled = !this.disabled
console.debug('disable aft>', this.disabled)
},
getSpecieDict() {
this.edit = this.value == null
......@@ -1392,8 +1397,18 @@ const sigthingFormApp = (id_session, type_contact) => {
return !(this.initialDataLoaded && this.dictsLoaded)
},
addNewSighting() {
this.data.push({ ...this.newSighting })
const newS = { ...this.newSighting }
const cds = []
this.data.forEach(es => cds.push([...es.countdetails]))
last = cds.slice(-1)
console.debug('last', last)
console.debug('cd0', newS.countdetails[0])
newS.countdetails[0].method = last.method
newS.countdetails[0].precision = last.precision
console.debug('newS', newS)
this.data.push(newS)
this.selectedItem = this.data.length - 1
this.countDetailSelectedItem = 0
},
// refactorForSelect(dict, contact) {
// const dict = this.filteredDict(dict, contact)
......@@ -1536,7 +1551,6 @@ const sigthingFormApp = (id_session, type_contact) => {
console.debug('ERROR', err)
this.messages.push({ type: 'danger', message: err })
})
},
filteredDict(dict, contact) {
contact = contact || null
......@@ -1617,16 +1631,22 @@ const sigthingFormApp = (id_session, type_contact) => {
})
},
dupSpecies() {
const cleanArray = [... new Set(this.species)]
this.messages.length = 0
const cleanArray = [...new Set(this.species)]
let duplicates = [...this.species]
cleanArray.forEach((item) => {
const i = duplicates.indexOf(item)
duplicates = duplicates
.slice(0, i)
.concat(duplicates.slice(i + 1, duplicates.length))
})
console.debug('<dupSpecies>',duplicates) //[ 1, 5 ]
this.messages.push({type:'error', message: `dup species ${duplicates}`})
.slice(0, i)
.concat(duplicates.slice(i + 1, duplicates.length))
})
console.debug('<dupSpecies>', duplicates) //[ 1, 5 ]
if (duplicates.length > 0) {
this.messages.push({
type: 'danger',
message: `Espèce(s) ${duplicates.map(e => `${this.getSpecieValue(e, 'sci_name')}`)} en double`,
})
}
},
},
computed: {
......@@ -1640,8 +1660,7 @@ const sigthingFormApp = (id_session, type_contact) => {
this.data.forEach((e, i) => {
e.total_count = this.sumCountDetails(i)
})
this.dupSpecies
this.dupSpecies()
},
deep: true,
},
......
......@@ -171,18 +171,18 @@ Observations de la session {{object.name}}
</thead>
<tbody>
<template v-for="(cd, icd) in data[selectedItem].countdetails">
<tr @click="displayCountDetailForm(icd)" :class="{'info': countDetailSelectedItem == icd}" >
<tr @click="displayCountDetailForm(icd)" :class="{'info' : countDetailSelectedItem == icd}" >
<td><span class="text-muted"><small>[[icd]]</small></td>
<!-- <td><span class="text-danger pull-right" @click="delCountDetail(selectedItem,icd)" tooltip><i
class="fa fa-trash"></i></span></td>-->
<td v-if="form_fields.includes('time')">[[cd.time ? cd.time :'-']]</td>
<td v-if="form_fields.includes('method')" v-html="selectedValueHtml(filteredDict(dicts.Method, typeContact), cd.method)"></td>
<td v-if="form_fields.includes('method')" :class="{'danger' : cd.method == null}" v-html="selectedValueHtml(filteredDict(dicts.Method, typeContact), cd.method)"></td>
<td v-if="form_fields.includes('sex')" v-html="selectedValueHtml(dicts.Sex, cd.sex)"></td>
<td v-if="form_fields.includes('age')" v-html="selectedValueHtml(dicts.Age, cd.age)"></td>
<td v-if="form_fields.includes('precision')" v-html="selectedValueHtml(filteredDict(dicts.CountPrecision, typeContact), cd.precision)"></td>
<td v-if="form_fields.includes('precision')" :class="{'danger' : cd.precision == null && !selectedCode(dicts.Method, cd.method, 'vvnc')}" v-html="selectedValueHtml(filteredDict(dicts.CountPrecision, typeContact), cd.precision)"></td>
<td v-if="form_fields.includes('ab')">[[cd.ab]]</td>
<td v-if="form_fields.includes('poids')">[[cd.poids]]</td>
<td v-if="form_fields.includes('count')">[[cd.count || '-']] [[dicts.CountUnit.find((e) => e.id == cd.unit)?.code]]</td>
<td v-if="form_fields.includes('count')" :class="{'danger' : cd.count == null && !selectedCode(dicts.Method, cd.method, 'vvnc')}">[[cd.count || '-']] [[dicts.CountUnit.find((e) => e.id == cd.unit)?.code]]</td>
</tr>
<tr v-if="countDetailSelectedItem == icd" :class="(invalid ? 'warning' : 'success')">
<td id="countDetailEditLine" colspan="100">
......
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