Commit 1094427d authored by hypsug0's avatar hypsug0
Browse files

feat: can't add more sighting if all taxa not filled

parent 891a05ed
......@@ -1074,7 +1074,7 @@ const SightingObject = (session_id) => {
is_doubtful: false,
comment: null,
extra_data: null,
countdetails: [{ ...CountDetailObject() }],
countdetails: [],
updated_by: null,
created_by: null,
}
......@@ -1355,13 +1355,12 @@ Vue.component('userSelectOne', {
this.apiCall(null, this.model)
}
},
apiCall(q= null, id= null) {
const qsParams = [];
let qs;
apiCall(q = null, id = null) {
const qsParams = []
let qs
if (id) {
qs = `id=${id}`
}
else {
} else {
qsParams.push(`q=${escape(q)}`)
if (session) {
qs.push(`session=${this.session}`)
......@@ -1378,7 +1377,6 @@ Vue.component('userSelectOne', {
.catch(function (error) {
console.error(error)
})
},
search: _debounce((loading, search, vm) => {
$http
......@@ -1395,7 +1393,7 @@ Vue.component('userSelectOne', {
},
mounted() {
this.onInit()
}
},
})
const sigthingFormApp = (id_session, type_contact) => {
......@@ -1491,18 +1489,44 @@ const sigthingFormApp = (id_session, type_contact) => {
return !(this.initialDataLoaded && this.dictsLoaded)
},
addNewSighting() {
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
console.log('test', this.data.find(e => e.codesp == null))
if (!this.data.find(e => e.codesp == null)) {
const newSighting = { ...this.newSighting }
const newCountDetail = { ...this.newCountDetail }
const allCountDetails = []
this.data.forEach((es) =>
allCountDetails.push(...es.countdetails)
)
console.debug('<allCountDetails>', allCountDetails)
const lastCountDetail =
allCountDetails[allCountDetails.length - 1]
if (lastCountDetail) {
// const lastCountDetail = allCountDetail[allCountDetail.length - 1]
console.debug(
'<addNewCountDetail> has countdetails items'
)
console.debug(
'newObject before',
lastCountDetail,
newCountDetail
)
newCountDetail.time = lastCountDetail.time
newCountDetail.method = lastCountDetail.method
newCountDetail.precision = lastCountDetail.precision
newCountDetail.unit = lastCountDetail.unit
if (type_contact == 'vm') {
newCountDetail.count = 1
}
console.log('newObject after', newCountDetail)
}
newSighting.countdetails.push(newCountDetail)
this.data.push(newSighting)
this.selectedItem = this.data.length - 1
this.countDetailSelectedItem = 0
}
else {
alert('Vous ne pouvez pas entrez d autre taxon si tous ne sont pas complétés')
}
},
// refactorForSelect(dict, contact) {
// const dict = this.filteredDict(dict, contact)
......@@ -1515,7 +1539,10 @@ const sigthingFormApp = (id_session, type_contact) => {
)
if (this.data[is].countdetails.length > 0) {
console.debug('<addNewCountDetail> has countdetails items')
const lastCountDetail = this.data[is].countdetails[this.data[is].countdetails.length-1]
const lastCountDetail = this.data[is].countdetails[
this.data[is].countdetails.length - 1
]
// const lastCountDetail = this.data[is].countdetails.slice(-1)
console.debug(
'newObject before',
lastCountDetail,
......@@ -1525,11 +1552,15 @@ const sigthingFormApp = (id_session, type_contact) => {
newCountDetail.method = lastCountDetail.method
newCountDetail.precision = lastCountDetail.precision
newCountDetail.unit = lastCountDetail.unit
if (type_contact == 'vm') {
newCountDetail.count = 1
}
console.log('newObject after', newCountDetail)
console.log('countdetails', this.data[is].countdetails)
}
this.data[is].countdetails.push(newCountDetail)
this.countDetailSelectedItem =
this.data[is].countdetails.length - 1
},
delCountDetail(is, icd) {
this.data[is].countdetails.splice(icd, 1)
......
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