From fb8522acef6a933c0a837910da6f7728f30f06b0 Mon Sep 17 00:00:00 2001 From: Tor-Einar Skog <tor-einar.skog@bioforsk.no> Date: Thu, 11 Feb 2016 15:56:46 +0100 Subject: [PATCH] Observation data system Beta 2 --- .../servlet/ObservationController.java | 26 +++- .../controller/session/ObservationBean.java | 15 +++ .../nibio/vips/logic/entity/Observation.java | 1 + .../ObservationDataSchema.java | 120 ++++++++++++++++++ .../ObservationDataSchemaPK.java | 97 ++++++++++++++ .../ObservationDataService.java | 78 +++++++++++- .../vips/logic/i18n/vipslogictexts.properties | 6 + .../logic/i18n/vipslogictexts_bs.properties | 6 + .../logic/i18n/vipslogictexts_hr.properties | 6 + .../logic/i18n/vipslogictexts_nb.properties | 6 + .../logic/i18n/vipslogictexts_sr.properties | 6 + .../formdefinitions/observationForm.json | 6 - src/main/webapp/js/objectGISInfoMap.js | 8 +- src/main/webapp/templates/observationForm.ftl | 6 +- src/main/webapp/templates/observationList.ftl | 10 ++ 15 files changed, 375 insertions(+), 22 deletions(-) create mode 100644 src/main/java/no/nibio/vips/observationdata/ObservationDataSchema.java create mode 100644 src/main/java/no/nibio/vips/observationdata/ObservationDataSchemaPK.java diff --git a/src/main/java/no/nibio/vips/logic/controller/servlet/ObservationController.java b/src/main/java/no/nibio/vips/logic/controller/servlet/ObservationController.java index dde0a0b3..06fb3bad 100644 --- a/src/main/java/no/nibio/vips/logic/controller/servlet/ObservationController.java +++ b/src/main/java/no/nibio/vips/logic/controller/servlet/ObservationController.java @@ -64,7 +64,23 @@ public class ObservationController extends HttpServlet { // for everyone if(action == null) { - List<Observation> observations = SessionControllerGetter.getObservationBean().getObservations(user.getOrganizationId().getOrganizationId()); + List<Observation> observations = null; + Integer statusTypeId = -1; + try + { + statusTypeId = Integer.valueOf(request.getParameter("statusTypeId")); + } + catch(NumberFormatException nfe) {} + + if(statusTypeId < 0) + { + observations = SessionControllerGetter.getObservationBean().getObservations(user.getOrganizationId().getOrganizationId()); + } + else + { + observations = SessionControllerGetter.getObservationBean().getObservations(user.getOrganizationId().getOrganizationId(), statusTypeId); + } + request.setAttribute("selectedStatusTypeId", statusTypeId); request.setAttribute("observations", observations); request.setAttribute("userHasObserverPrivilege", SessionControllerGetter.getUserBean().authorizeUser(user, VipsLogicRole.OBSERVER, VipsLogicRole.ORGANIZATION_ADMINISTRATOR, VipsLogicRole.SUPERUSER)); // If this is a redirect from a controller, with a message to be passed on @@ -84,8 +100,8 @@ public class ObservationController extends HttpServlet { request.setAttribute("mapLayers", SessionControllerGetter.getUserBean().getMapLayerJSONForUser(user)); request.setAttribute("defaultMapCenter",user.getOrganizationId().getDefaultMapCenter()); request.setAttribute("defaultMapZoom", user.getOrganizationId().getDefaultMapZoom()); - List<Organism> allOrganisms = em.createNamedQuery("Organism.findAll").getResultList(); - request.setAttribute("allOrganisms", allOrganisms); + List<Organism> allPests = em.createNamedQuery("Organism.findAllPests").getResultList(); + request.setAttribute("allPests", allPests); // Hierarchy categories request.setAttribute("hierarchyCategories", SessionControllerGetter.getOrganismBean().getHierarchyCategoryNames(SessionLocaleUtil.getCurrentLocale(request))); request.setAttribute("observationMethods", em.createNamedQuery("ObservationMethod.findAll", ObservationMethod.class).getResultList()); @@ -120,8 +136,8 @@ public class ObservationController extends HttpServlet { //System.out.println(observation.getGeoinfo()); request.setAttribute("defaultMapCenter",user.getOrganizationId().getDefaultMapCenter()); request.setAttribute("defaultMapZoom", user.getOrganizationId().getDefaultMapZoom()); - List<Organism> allOrganisms = em.createNamedQuery("Organism.findAll").getResultList(); - request.setAttribute("allOrganisms", allOrganisms); + List<Organism> allPests = em.createNamedQuery("Organism.findAllPests").getResultList(); + request.setAttribute("allPests", allPests); // Hierarchy categories request.setAttribute("hierarchyCategories", SessionControllerGetter.getOrganismBean().getHierarchyCategoryNames(SessionLocaleUtil.getCurrentLocale(request))); request.setAttribute("observationMethods", em.createNamedQuery("ObservationMethod.findAll", ObservationMethod.class).getResultList()); diff --git a/src/main/java/no/nibio/vips/logic/controller/session/ObservationBean.java b/src/main/java/no/nibio/vips/logic/controller/session/ObservationBean.java index 6cc7cb02..bcb1b8fe 100644 --- a/src/main/java/no/nibio/vips/logic/controller/session/ObservationBean.java +++ b/src/main/java/no/nibio/vips/logic/controller/session/ObservationBean.java @@ -52,6 +52,21 @@ public class ObservationBean { return retVal; } + public List<Observation> getObservations(Integer organizationId, Integer statusTypeId) + { + Organization organization= em.find(Organization.class, organizationId); + /*List<VipsLogicUser> users = em.createNamedQuery("VipsLogicUser.findByOrganizationId", VipsLogicUser.class) + .setParameter("organizationId", organization) + .getResultList();*/ + + List<Observation> retVal = this.getObservationsWithGeoInfo(em.createNamedQuery("Observation.findByOrganizationIdAndStatusTypeId") + .setParameter("organizationId", organization) + .setParameter("statusTypeId", statusTypeId) + .getResultList()); + + return retVal; + } + public Observation getObservation(Integer observationId) { Observation retVal = em.find(Observation.class, observationId); diff --git a/src/main/java/no/nibio/vips/logic/entity/Observation.java b/src/main/java/no/nibio/vips/logic/entity/Observation.java index 1375e6a9..06601f84 100644 --- a/src/main/java/no/nibio/vips/logic/entity/Observation.java +++ b/src/main/java/no/nibio/vips/logic/entity/Observation.java @@ -57,6 +57,7 @@ import org.hibernate.annotations.TypeDefs; @NamedQuery(name = "Observation.findAll", query = "SELECT o FROM Observation o"), @NamedQuery(name = "Observation.findByObservationId", query = "SELECT o FROM Observation o WHERE o.observationId = :observationId"), @NamedQuery(name = "Observation.findByUserId", query = "SELECT o FROM Observation o WHERE o.userId IN(:userId)"), + @NamedQuery(name = "Observation.findByOrganizationIdAndStatusTypeId", query = "SELECT o FROM Observation o WHERE o.userId IN(SELECT v.userId FROM VipsLogicUser v WHERE v.organizationId = :organizationId OR v.organizationId IN(SELECT o.organizationId FROM Organization o WHERE o.parentOrganizationId = :organizationId)) AND o.statusTypeId= :statusTypeId"), @NamedQuery(name = "Observation.findByOrganism", query = "SELECT o FROM Observation o WHERE o.organism = :organism"), @NamedQuery(name = "Observation.findByTimeOfObservation", query = "SELECT o FROM Observation o WHERE o.timeOfObservation = :timeOfObservation") }) diff --git a/src/main/java/no/nibio/vips/observationdata/ObservationDataSchema.java b/src/main/java/no/nibio/vips/observationdata/ObservationDataSchema.java new file mode 100644 index 00000000..df6143ea --- /dev/null +++ b/src/main/java/no/nibio/vips/observationdata/ObservationDataSchema.java @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2016 NIBIO <http://www.nibio.no/>. + * + * This file is part of VIPSLogic. + * VIPSLogic is free software: you can redistribute it and/or modify + * it under the terms of the NIBIO Open Source License as published by + * NIBIO, either version 1 of the License, or (at your option) any + * later version. + * + * VIPSLogic is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * NIBIO Open Source License for more details. + * + * You should have received a copy of the NIBIO Open Source License + * along with VIPSLogic. If not, see <http://www.nibio.no/licenses/>. + * + */ + +package no.nibio.vips.observationdata; + +import java.io.Serializable; +import javax.persistence.Column; +import javax.persistence.EmbeddedId; +import javax.persistence.Entity; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.Table; +import javax.xml.bind.annotation.XmlRootElement; +import no.nibio.vips.logic.util.StringJsonUserType; +import org.hibernate.annotations.Type; +import org.hibernate.annotations.TypeDef; +import org.hibernate.annotations.TypeDefs; + +/** + * @copyright 2016 <a href="http://www.nibio.no/">NIBIO</a> + * @author Tor-Einar Skog <tor-einar.skog@nibio.no> + */ +@Entity +@Table(name = "observation_data_schema") +@XmlRootElement +@TypeDefs( {@TypeDef( name= "StringJsonObject", typeClass = StringJsonUserType.class)}) +@NamedQueries({ + @NamedQuery(name = "ObservationDataSchema.findAll", query = "SELECT o FROM ObservationDataSchema o"), + @NamedQuery(name = "ObservationDataSchema.findByPK", query = "SELECT o FROM ObservationDataSchema o WHERE o.observationDataSchemaPK.organizationId = :organizationId AND o.observationDataSchemaPK.organismId = :organismId"), + @NamedQuery(name = "ObservationDataSchema.findByOrganizationId", query = "SELECT o FROM ObservationDataSchema o WHERE o.observationDataSchemaPK.organizationId = :organizationId"), + @NamedQuery(name = "ObservationDataSchema.findByOrganismId", query = "SELECT o FROM ObservationDataSchema o WHERE o.observationDataSchemaPK.organismId = :organismId")}) +public class ObservationDataSchema implements Serializable { + + private static final long serialVersionUID = 1L; + @EmbeddedId + protected ObservationDataSchemaPK observationDataSchemaPK; + @Type(type = "StringJsonObject") + @Column(name = "data_schema") + private String dataSchema; + @Type(type = "StringJsonObject") + @Column(name = "data_model") + private String dataModel; + + public ObservationDataSchema() { + } + + public ObservationDataSchema(ObservationDataSchemaPK observationDataSchemaPK) { + this.observationDataSchemaPK = observationDataSchemaPK; + } + + public ObservationDataSchema(int organizationId, int organismId) { + this.observationDataSchemaPK = new ObservationDataSchemaPK(organizationId, organismId); + } + + public ObservationDataSchemaPK getObservationDataSchemaPK() { + return observationDataSchemaPK; + } + + public void setObservationDataSchemaPK(ObservationDataSchemaPK observationDataSchemaPK) { + this.observationDataSchemaPK = observationDataSchemaPK; + } + + public String getDataSchema() { + return dataSchema; + } + + public void setDataSchema(String dataSchema) { + this.dataSchema = dataSchema; + } + + public String getDataModel() { + return dataModel; + } + + public void setDataModel(String dataModel) { + this.dataModel = dataModel; + } + + @Override + public int hashCode() { + int hash = 0; + hash += (observationDataSchemaPK != null ? observationDataSchemaPK.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object object) { + // TODO: Warning - this method won't work in the case the id fields are not set + if (!(object instanceof ObservationDataSchema)) { + return false; + } + ObservationDataSchema other = (ObservationDataSchema) object; + if ((this.observationDataSchemaPK == null && other.observationDataSchemaPK != null) || (this.observationDataSchemaPK != null && !this.observationDataSchemaPK.equals(other.observationDataSchemaPK))) { + return false; + } + return true; + } + + @Override + public String toString() { + return "no.nibio.vips.observationdata.ObservationDataSchema[ observationDataSchemaPK=" + observationDataSchemaPK + " ]"; + } + +} diff --git a/src/main/java/no/nibio/vips/observationdata/ObservationDataSchemaPK.java b/src/main/java/no/nibio/vips/observationdata/ObservationDataSchemaPK.java new file mode 100644 index 00000000..14ff5197 --- /dev/null +++ b/src/main/java/no/nibio/vips/observationdata/ObservationDataSchemaPK.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2016 NIBIO <http://www.nibio.no/>. + * + * This file is part of VIPSLogic. + * VIPSLogic is free software: you can redistribute it and/or modify + * it under the terms of the NIBIO Open Source License as published by + * NIBIO, either version 1 of the License, or (at your option) any + * later version. + * + * VIPSLogic is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * NIBIO Open Source License for more details. + * + * You should have received a copy of the NIBIO Open Source License + * along with VIPSLogic. If not, see <http://www.nibio.no/licenses/>. + * + */ + +package no.nibio.vips.observationdata; + +import java.io.Serializable; +import javax.persistence.Basic; +import javax.persistence.Column; +import javax.persistence.Embeddable; +import javax.validation.constraints.NotNull; + +/** + * @copyright 2016 <a href="http://www.nibio.no/">NIBIO</a> + * @author Tor-Einar Skog <tor-einar.skog@nibio.no> + */ +@Embeddable +public class ObservationDataSchemaPK implements Serializable { + + @Basic(optional = false) + @NotNull + @Column(name = "organization_id") + private int organizationId; + @Basic(optional = false) + @NotNull + @Column(name = "organism_id") + private int organismId; + + public ObservationDataSchemaPK() { + } + + public ObservationDataSchemaPK(int organizationId, int organismId) { + this.organizationId = organizationId; + this.organismId = organismId; + } + + public int getOrganizationId() { + return organizationId; + } + + public void setOrganizationId(int organizationId) { + this.organizationId = organizationId; + } + + public int getOrganismId() { + return organismId; + } + + public void setOrganismId(int organismId) { + this.organismId = organismId; + } + + @Override + public int hashCode() { + int hash = 0; + hash += (int) organizationId; + hash += (int) organismId; + return hash; + } + + @Override + public boolean equals(Object object) { + // TODO: Warning - this method won't work in the case the id fields are not set + if (!(object instanceof ObservationDataSchemaPK)) { + return false; + } + ObservationDataSchemaPK other = (ObservationDataSchemaPK) object; + if (this.organizationId != other.organizationId) { + return false; + } + if (this.organismId != other.organismId) { + return false; + } + return true; + } + + @Override + public String toString() { + return "no.nibio.vips.observationdata.ObservationDataSchemaPK[ organizationId=" + organizationId + ", organismId=" + organismId + " ]"; + } + +} diff --git a/src/main/java/no/nibio/vips/observationdata/ObservationDataService.java b/src/main/java/no/nibio/vips/observationdata/ObservationDataService.java index 7325237e..db79860e 100644 --- a/src/main/java/no/nibio/vips/observationdata/ObservationDataService.java +++ b/src/main/java/no/nibio/vips/observationdata/ObservationDataService.java @@ -19,10 +19,27 @@ package no.nibio.vips.observationdata; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.ibm.icu.util.ULocale; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; +import java.util.ResourceBundle; +import javax.persistence.EntityManager; +import javax.persistence.NoResultException; +import javax.persistence.PersistenceContext; +import javax.servlet.http.HttpServletRequest; import javax.ws.rs.GET; import javax.ws.rs.Path; +import javax.ws.rs.PathParam; import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; +import no.nibio.vips.logic.i18n.SessionLocaleUtil; /** * @copyright 2016 <a href="http://www.nibio.no/">NIBIO</a> @@ -30,23 +47,76 @@ import javax.ws.rs.core.Response; */ @Path("rest/observationdata") public class ObservationDataService { + @PersistenceContext(unitName="VIPSLogic-PU") + EntityManager em; + + @Context + private HttpServletRequest httpServletRequest; + + @GET @Path("schema/{organizationId}/{organismId}") @Produces("application/json;charset=UTF-8") - public Response getSchema(){ + public Response getSchema(@PathParam("organizationId") Integer organizationId,@PathParam("organismId") Integer organismId){ // Try to find schema for given organism/organization + ObservationDataSchema ods = null; + try + { + ods = em.createNamedQuery("ObservationDataSchema.findByPK", ObservationDataSchema.class) + .setParameter("organizationId", organizationId) + .setParameter("organismId", organismId) + .getSingleResult(); + + ResourceBundle bundle = SessionLocaleUtil.getI18nBundle(httpServletRequest); + + // We iterate the schema, replacing default field labels with + // translated ones + // First: Convert to Jackson JsonNode tree + ObjectMapper m = new ObjectMapper(); + JsonNode rootNode = m.readTree(ods.getDataSchema()); + Iterator<Entry<String, JsonNode>> nodeIterator = rootNode.fields(); + + String fieldKeyPrefix = "observationDataField_"; + // Loop through each field + while (nodeIterator.hasNext()) { + Map.Entry<String, JsonNode> schemaPropertyField = (Map.Entry<String, JsonNode>) nodeIterator.next(); + // Get the property field key (e.g. "counting2") + String fieldKey = schemaPropertyField.getKey(); + // Find a translation. + if(bundle.containsKey(fieldKeyPrefix + fieldKey)) + { + // If found, replace with translation + // Get the property field (e.g. {"title":"Counting 2"} ) + JsonNode schemaProperty = schemaPropertyField.getValue(); + ((ObjectNode)schemaProperty).put("title", bundle.getString(fieldKeyPrefix + fieldKey)); + ((ObjectNode)rootNode).replace(fieldKey, schemaProperty); + } + } + return Response.ok().entity(rootNode).build(); + + }catch(IOException | NoResultException ex){} + // If not found, return standard nominator/denominator (unit) form - return Response.ok().entity(this.getStandardSchema()).build(); + return Response.ok().entity(ods != null ? ods.getDataSchema() : this.getStandardSchema()).build(); } @GET @Path("model/{organizationId}/{organismId}") @Produces("application/json;charset=UTF-8") - public Response getModel(){ + public Response getModel(@PathParam("organizationId") Integer organizationId,@PathParam("organismId") Integer organismId){ + // Try to find schema for given organism/organization + ObservationDataSchema ods = null; + try + { + ods = em.createNamedQuery("ObservationDataSchema.findByPK", ObservationDataSchema.class) + .setParameter("organizationId", organizationId) + .setParameter("organismId", organismId) + .getSingleResult(); + }catch(NoResultException nre){} // If not found, return standard nominator/denominator (unit) form - return Response.ok().entity(this.getStandardModel()).build(); + return Response.ok().entity(ods != null ? ods.getDataModel() : this.getStandardModel()).build(); } private String getStandardSchema(){ diff --git a/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts.properties b/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts.properties index 20b43bf1..1e939ee3 100644 --- a/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts.properties +++ b/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts.properties @@ -321,3 +321,9 @@ vipsLogicRole_4=Observation authority statusTypeIdTitle_1=Pending statusTypeIdTitle_2=Rejected statusTypeIdTitle_3=Approved +observationDataField_counting1=Counting 1 +observationDataField_counting2=Counting 2 +allCategories=All categories +pending=Pending +approved=Approved +rejected=Rejected diff --git a/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts_bs.properties b/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts_bs.properties index b04b3622..bee6d7ba 100644 --- a/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts_bs.properties +++ b/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts_bs.properties @@ -321,3 +321,9 @@ vipsLogicRole_4=Observation authority statusTypeIdTitle_1=Pending statusTypeIdTitle_2=Rejected statusTypeIdTitle_3=Approved +observationDataField_counting1=Counting 1 +observationDataField_counting2=Counting 2 +allCategories=All categories +pending=Pending +approved=Approved +rejected=Rejected diff --git a/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts_hr.properties b/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts_hr.properties index 1d8f692b..1a107c8a 100644 --- a/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts_hr.properties +++ b/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts_hr.properties @@ -320,3 +320,9 @@ vipsLogicRole_4=Observation authority statusTypeIdTitle_1=Pending statusTypeIdTitle_2=Rejected statusTypeIdTitle_3=Approved +observationDataField_counting1=Counting 1 +observationDataField_counting2=Counting 2 +allCategories=All categories +pending=Pending +approved=Approved +rejected=Rejected diff --git a/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts_nb.properties b/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts_nb.properties index 3b0a668b..ba275d0c 100644 --- a/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts_nb.properties +++ b/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts_nb.properties @@ -321,3 +321,9 @@ vipsLogicRole_4=Observasjonsgodkjenner statusTypeIdTitle_1=Venter p\u00e5 godkjenning statusTypeIdTitle_2=Avvist statusTypeIdTitle_3=Godkjent +observationDataField_counting1=Telling 1 +observationDataField_counting2=Telling 2 +allCategories=Alle kategorier +pending=Venter +approved=Godkjent +rejected=Avsl\u00e5tt diff --git a/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts_sr.properties b/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts_sr.properties index 30b0987b..9a755495 100644 --- a/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts_sr.properties +++ b/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts_sr.properties @@ -321,3 +321,9 @@ vipsLogicRole_4=Observation authority statusTypeIdTitle_1=Pending statusTypeIdTitle_2=Rejected statusTypeIdTitle_3=Approved +observationDataField_counting1=Counting 1 +observationDataField_counting2=Counting 2 +allCategories=All categories +pending=Pending +approved=Approved +rejected=Rejected diff --git a/src/main/webapp/formdefinitions/observationForm.json b/src/main/webapp/formdefinitions/observationForm.json index bf111db0..cb5a6a64 100644 --- a/src/main/webapp/formdefinitions/observationForm.json +++ b/src/main/webapp/formdefinitions/observationForm.json @@ -50,12 +50,6 @@ "fieldType" : "HIDDEN", "required" : false }, - { - "name" : "observationMethodId", - "dataType" : "STRING", - "fieldType" : "SELECT_SINGLE", - "required" : true - }, { "name" : "observationHeading", "dataType" : "STRING", diff --git a/src/main/webapp/js/objectGISInfoMap.js b/src/main/webapp/js/objectGISInfoMap.js index 89a98c8f..848c2e0f 100755 --- a/src/main/webapp/js/objectGISInfoMap.js +++ b/src/main/webapp/js/objectGISInfoMap.js @@ -68,14 +68,14 @@ function initMap(containerId, center, zoomLevel, displayMarker, drawnObjs, choos // Create the DOM structure var theContainer = el(containerId); theContainer.innerHTML = [ - "<div>", + "<div class='form-group'>", " <label>",getI18nMsg("mapDrawTypeLabel"),"</label>", - " <select id='type'>", + " <select class='form-control' id='type' style='width: auto; display: inline;'>", " <option value='Point'>",getI18nMsg("point"),"</option>", " <option value='Polygon'>",getI18nMsg("polygon"),"</option>", " </select>", - " <button id='delete' type='button'>",getI18nMsg("clearAll"),"</button>", - " <button id='deleteOne' type='button'>",getI18nMsg("clearOne"),"</button>", + " <button type='button' id='delete' class='btn btn-danger' type='button'>",getI18nMsg("clearAll"),"</button>", + " <button type='button' id='deleteOne' class='btn btn-warning' type='button'>",getI18nMsg("clearOne"),"</button>", "</div>", "<div id='", olMapDivId ,"' class='map'></div>", "<div id='alert_placeholder'></div>" diff --git a/src/main/webapp/templates/observationForm.ftl b/src/main/webapp/templates/observationForm.ftl index ad908f63..e2ea2a4c 100755 --- a/src/main/webapp/templates/observationForm.ftl +++ b/src/main/webapp/templates/observationForm.ftl @@ -134,7 +134,7 @@ <select class="form-control" name="organismId" <#if observation.organism?has_content>readonly="readonly"<#else>onchange="initObservationData(this.options[this.options.selectedIndex].value,organizationId);" onblur="validateField(this);"</#if>> <option value="-1">${i18nBundle.pleaseSelect} ${i18nBundle.organism?lower_case}</option> - <#list allOrganisms?sort_by("latinName") as organism> + <#list allPests?sort_by("latinName") as organism> <option value="${organism.organismId}" <#if (observation.organism?has_content && observation.organism.organismId == organism.organismId)>selected="selected"</#if> >${organism.latinName!""}/${organism.getLocalName(currentLocale.language)!""} (${hierarchyCategories.getName(organism.hierarchyCategoryId)})</option> @@ -169,7 +169,7 @@ <input type="number" class="form-control" name="denominator" placeholder="${i18nBundle.denominator}" value="${(observation.denominator?c)!"1"}" onblur="validateField(this);"/> <span class="help-block" id="${formId}_denominator_validation"></span> </div--> - <div class="form-group"> + <!--div class="form-group"> <label for="observationMethodId">${i18nBundle.observationMethodId}</label> <select class="form-control" name="observationMethodId" onblur="validateField(this);"> <#list observationMethods as observationMethod> @@ -179,7 +179,7 @@ </#list> </select> <span class="help-block" id="${formId}_observationMethodId_validation"></span> - </div> + </div--> <div class="form-group"> <label for="observationHeading">${i18nBundle.observationHeading}</label> <input type="text" class="form-control" name="observationHeading" placeholder="" value="${observation.observationHeading!""}" onblur="validateField(this);"/> diff --git a/src/main/webapp/templates/observationList.ftl b/src/main/webapp/templates/observationList.ftl index 6f28ff32..44893509 100644 --- a/src/main/webapp/templates/observationList.ftl +++ b/src/main/webapp/templates/observationList.ftl @@ -26,11 +26,19 @@ <div class="alert alert-success">${i18nBundle(messageKey)}</div> </#if> <a href="/observation?action=newObservationForm" class="btn btn-default" role="button">${i18nBundle.addNew}</a> + + <select class="form-control" name="statusTypeId" onchange="window.location.href='/observation?statusTypeId=' + this.options[this.options.selectedIndex].value;"> + <#list [-1,1,2,3] as statusTypeId> + <option value="${statusTypeId}" <#if statusTypeId == selectedStatusTypeId>selected="selected"</#if>><#switch statusTypeId><#case -1>${i18nBundle.allCategories}<#break><#case 1>${i18nBundle.pending}<#break><#case 2>${i18nBundle.rejected}<#break><#case 3>${i18nBundle.approved}</#switch></option> + </#list> + </select> <div class="table-responsive"> <table class="table table-striped"> <thead> <th>${i18nBundle.timeOfObservation}</th> <th>${i18nBundle.organism}</th> + <th>${i18nBundle.heading}</th> + <th>${i18nBundle.status}</th> <th></th> </thead> <tbody> @@ -38,6 +46,8 @@ <tr> <td>${observation.timeOfObservation?string("yyyy-MM-dd HH:mmZ")}</td> <td>${observation.organism.latinName!""}/${observation.organism.getLocalName(currentLocale.language)!""}</td> + <td>${observation.observationHeading}</td> + <td><#switch observation.statusTypeId><#case 1>${i18nBundle.pending}<#break><#case 2>${i18nBundle.rejected}<#break><#case 3>${i18nBundle.approved}</#switch></td> <td><#if userHasObserverPrivilege><a href="/observation?action=editObservationForm&observationId=${observation.observationId}" class="btn btn-default" role="button">${i18nBundle.edit}</a></#if></td> </tr> </#list> -- GitLab