Skip to content

Commit

Permalink
feat(bats): add dashboard, list and edit views
Browse files Browse the repository at this point in the history
  • Loading branch information
groupsky committed Jan 2, 2023
1 parent 1ed0e38 commit 8573404
Show file tree
Hide file tree
Showing 7 changed files with 495 additions and 0 deletions.
5 changes: 5 additions & 0 deletions client/assets/icons/bats.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions client/scripts/configs/forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,32 @@ const forms = module.exports = {
'source'
]
},
bats: {
model: 'FormBats',
serverModel: 'formBats',
label: 'FORM_LABEL_BATS',
translatePrefix: 'BATS',
speciesType: 'bats',
hasCount: true,
longLabel: 'FORM_BATS_LONG',
shortLabel: 'FORM_BATS_SHORT',
hasStats: true,
filters: [
'auto_location',
'{user:int}',
'species',
'from_date',
'to_date',
'latitude',
'longitude',
'radius',
'tab',
'threat',
'organization',
'moderatorReview',
'source'
]
},
ciconia: {
model: 'FormCiconia',
serverModel: 'formCiconia',
Expand Down
88 changes: 88 additions & 0 deletions client/scripts/models/form_bats.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
const angular = require('angular')
const LocalCache = require('./mixins/local_cache')
const countPendingReview = require('./mixins/countPendingReview')

const COPY_PERSIST_PROPS = Object.fromEntries([
'latitude',
'longitude',
'geolocationAccuracy',
'nameWaterBody',

// common fields
'observationMethodology',
'source',
'observationDateTime',
'monitoringCode',
'endDateTime',
'startDateTime',
'observers',
'rain',
'temperature',
'windDirection',
'windSpeed',
'cloudiness',
'cloudsType',
'visibility',
'mto',
'notes',
'threats',
'track',
'location',
'user',
'organization',

// form fields
'metodology',
'tCave',
'hCave',
'typloc',
'habitats'
].map(k => [k, true]))

require('../app').factory('FormBats', /* @ngInject */function ($resource, ENDPOINT_URL, db) {
const FormBats = $resource(ENDPOINT_URL + '/bats/:id', {
id: '@id'
}, {
// api methods
export: { method: 'POST', url: ENDPOINT_URL + '/export/bats' },
countPendingReview
})

// instance methods
angular.extend(FormBats.prototype, {
afterCreate: function () {
this.initDefaults()
},
getUser: function () {
return db.users[this.user]
},
getSpecies: function () {
return db.species.fishes && db.species.fishes[this.species]
},
hasSource: true,
preCopy: function () {
Object
.keys(this)
.filter(key => !key.startsWith('$') && !(key in COPY_PERSIST_PROPS))
.forEach(key => delete this[key])
},
postCopy: function () {
this.initDefaults()
},
initDefaults: function () {
this.confidential = false
this.moderatorReview = false
},
hasNotes: true
})

// class methods
angular.extend(FormBats, {
})

LocalCache.inject(FormBats, {
name: 'bats'
})

return FormBats
})
1 change: 1 addition & 0 deletions client/views/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ <h1 class="page-header" translate>DASHBOARD_TITLE</h1>
<dashboard-form-card form="::dashboard.forms.plants"></dashboard-form-card>
<dashboard-form-card form="::dashboard.forms.fishes"></dashboard-form-card>
<dashboard-form-card form="::dashboard.forms.birdsMigrations"></dashboard-form-card>
<dashboard-form-card form="::dashboard.forms.bats"></dashboard-form-card>
<dashboard-form-card form="::dashboard.forms.ciconia"></dashboard-form-card>
<dashboard-form-card form="::dashboard.forms.threats"></dashboard-form-card>
</div>
166 changes: 166 additions & 0 deletions client/views/monitorings/bats.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
<form name="smartform"
role="form"
confirm-on-exit="smartform.$dirty"
confirm-message-window="{{'MONITORING_DETAIL_UNSAVED_DATA_ALERT_TITLE' | translate}}"
confirm-message-route="{{'MONITORING_DETAIL_UNSAVED_DATA_ALERT_MESSAGE' | translate}}">
<div class="actions actions-detail">
<form-detail-buttons monitoring-detail-controller="monitoringDetailController"></form-detail-buttons>
</div>
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">
<span ng-if="monitoringDetailController.data.id" translate>MONITORING_DETAIL_TITLE_EDIT</span>
<span ng-if="!monitoringDetailController.data.id" translate>MONITORING_DETAIL_TITLE_NEW</span>
</h1>
</div>
</div>

<div ng-include="'/views/monitorings/common2.html'"></div>

<div ng-include="'/views/monitorings/common.html'"></div>

<div class="row">
<div class="col-md-7 col-lg-6" ng-include="'/views/monitorings/fields/geolocation.html'"></div>

<div class="col-md-5 col-lg-6">
<div class="row">
<div class="col-md-12">
<field name="species" type="species" nomenclature="bats" required="true"
label="{{'FIELD_SPECIES' | translate}}"
model="monitoringDetailController.data.species"></field>
</div>
<div class="col-md-6 col-lg-6" ng-include="'/views/monitorings/fields/confidential.html'"></div>
<div class="col-md-6 col-lg-6" ng-include="'/views/monitorings/fields/moderatorReview.html'"></div>
<div class="col-md-6 col-lg-6">
<field name="count" type="int" min="1" required="true"
label="{{'FIELD_COUNT' | translate}}"
model="monitoringDetailController.data.count"></field>
</div>
<div class="col-md-6 col-lg-6">
<field name="metodology" type="single-choice" nomenclature="bats_methodology"
label="{{'BATS_DETAIL_METODOLOGY' | translate}}"
model="monitoringDetailController.data.metodology"></field>
</div>
<div class="col-md-6 col-lg-6">
<field name="tCave" type="float"
label="{{'BATS_DETAIL_T_CAVE' | translate}}"
model="monitoringDetailController.data.tCave"></field>
</div>
<div class="col-md-6 col-lg-6">
<field name="hCave" type="float"
label="{{'BATS_DETAIL_H_CAVE' | translate}}"
model="monitoringDetailController.data.hCave"></field>
</div>
<div class="col-md-6 col-lg-6">
<field name="typloc" type="single-choice" nomenclature="bats_type_location"
label="{{'BATS_DETAIL_TYPE_LOCATION' | translate}}"
model="monitoringDetailController.data.typloc"></field>
</div>
<div class="col-md-6 col-lg-6">
<field name="sublocality" type="text"
label="{{'BATS_DETAIL_SUBLOCALITY' | translate}}"
model="monitoringDetailController.data.sublocality"></field>
</div>
<div class="col-md-6 col-lg-6">
<field name="swarming" type="bool"
label="{{'BATS_DETAIL_SWARMING' | translate}}"
help="{{'BATS_DETAIL_SWARMING_HELP' | translate}}"
model="monitoringDetailController.data.swarming"></field>
</div>
<div class="col-md-6 col-lg-6">
<field name="age" type="single-choice" nomenclature="bats_age"
label="{{'BATS_DETAIL_AGE' | translate}}"
help="{{'BATS_DETAIL_AGE_HELP' | translate}}"
model="monitoringDetailController.data.age"></field>
</div>
<div class="col-md-6 col-lg-6">
<field name="sex" type="single-choice" nomenclature="bats_sex"
label="{{'BATS_DETAIL_SEX' | translate}}"
help="{{'BATS_DETAIL_SEX_HELP' | translate}}"
model="monitoringDetailController.data.sex"></field>
</div>
<div class="col-md-6 col-lg-6">
<field name="habitats" type="single-choice" nomenclature="bats_habitat"
label="{{'BATS_DETAIL_HABITAT' | translate}}"
model="monitoringDetailController.data.habitats"></field>
</div>
</div>
</div>
</div>

<div class="row">
<div class="col-md-6 col-lg-6">
<field name="condition" type="single-choice" nomenclature="bats_condition"
label="{{'BATS_DETAIL_CONDITION' | translate}}"
help="{{'BATS_DETAIL_CONDITION_HELP' | translate}}"
model="monitoringDetailController.data.condition"></field>
</div>
<div class="col-md-6 col-lg-6">
<field name="typeCond" type="single-choice" nomenclature="bats_type_condition"
label="{{'BATS_DETAIL_TYPE_CONDITION' | translate}}"
model="monitoringDetailController.data.typeCond"></field>
</div>
<div class="col-md-6 col-lg-6">
<field name="reproductiveStatus" type="single-choice" nomenclature="bats_reproductive_status"
label="{{'BATS_DETAIL_REPRODUCTIVE_STATUS' | translate}}"
model="monitoringDetailController.data.reproductiveStatus"></field>
</div>
<div class="col-md-6 col-lg-6">
<field name="ring" type="single-choice" nomenclature="bats_ring"
label="{{'BATS_DETAIL_RING' | translate}}"
model="monitoringDetailController.data.ring"></field>
</div>
<div class="col-md-6 col-lg-6">
<field name="ringN" type="text"
label="{{'BATS_DETAIL_RING_N' | translate}}"
model="monitoringDetailController.data.ringN"></field>
</div>
<div class="col-md-6 col-lg-6">
<field name="bodyLength" type="float"
label="{{'BATS_DETAIL_BODY_LENGTH' | translate}}"
model="monitoringDetailController.data.bodyLength"></field>
</div>
<div class="col-md-6 col-lg-6">
<field name="tailLength" type="float"
label="{{'BATS_DETAIL_TAIL_LENGTH' | translate}}"
model="monitoringDetailController.data.tailLength"></field>
</div>
<div class="col-md-6 col-lg-6">
<field name="earLength" type="float"
label="{{'BATS_DETAIL_EAR_LENGTH' | translate}}"
model="monitoringDetailController.data.earLength"></field>
</div>
<div class="col-md-6 col-lg-6">
<field name="forearmLength" type="float"
label="{{'BATS_DETAIL_FOREARM_LENGTH' | translate}}"
model="monitoringDetailController.data.forearmLength"></field>
</div>
<div class="col-md-6 col-lg-6">
<field name="lengthThirdDigit" type="float"
label="{{'BATS_DETAIL_LENGTH_THIRD_DIGIT' | translate}}"
model="monitoringDetailController.data.lengthThirdDigit"></field>
</div>
<div class="col-md-6 col-lg-6">
<field name="lengthFifthDigit" type="float"
label="{{'BATS_DETAIL_LENGTH_FIFTH_DIGIT' | translate}}"
model="monitoringDetailController.data.lengthFifthDigit"></field>
</div>
<div class="col-md-6 col-lg-6">
<field name="lengthWS" type="float"
label="{{'BATS_DETAIL_LENGTH_WS' | translate}}"
model="monitoringDetailController.data.lengthWS"></field>
</div>
<div class="col-md-6 col-lg-6">
<field name="weight" type="float"
label="{{'BATS_DETAIL_WEIGHT' | translate}}"
model="monitoringDetailController.data.weight"></field>
</div>
</div>

<div ng-include="'/views/monitorings/footer.html'"></div>

<div class="row">
<form-pictures ng-model="monitoringDetailController.data.pictures"></form-pictures>
</div>

</form>
Loading

0 comments on commit 8573404

Please sign in to comment.