Integradas sugerencias de la vista recibidas de Marcos, se ha tenido que
integrar con el uso de las firmas de EJB de MagicDrw, además de eliminar el uso de propiedades sueltas en pro del objeto seleccionado, y también se ha hecho algún cambio extra para que la botonera de la interfaz quede más integrada.
This commit is contained in:
@@ -1,56 +1,84 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
|
||||||
xmlns:ui="http://java.sun.com/jsf/facelets"
|
|
||||||
xmlns:f="http://java.sun.com/jsf/core"
|
|
||||||
xmlns:h="http://java.sun.com/jsf/html"
|
|
||||||
xmlns:p="http://primefaces.org/ui" xmlns:o="http://omnifaces.org/ui">
|
xmlns:p="http://primefaces.org/ui" xmlns:o="http://omnifaces.org/ui">
|
||||||
|
|
||||||
<ui:composition template="../header.xhtml">
|
<ui:composition template="../header.xhtml">
|
||||||
<ui:define name="content">
|
<ui:define name="content">
|
||||||
<h:form id="frmQuestions">
|
<h:form id="frmQuestions">
|
||||||
<p:growl id="msgs" showDetail="true" closable="true"
|
<p:growl id="mesgs" showDetail="true" closable="true" autoupdate="true" />
|
||||||
autoupdate="true" />
|
|
||||||
<p:panel id="panelQuestions" header="Preguntas">
|
<p:panel id="panelQuestions" header="Preguntas">
|
||||||
<div class="ui-g ui-fluid">
|
<div class="ui-g ui-fluid">
|
||||||
<div class="ui-g-3 ui-md-3">
|
<div class="ui-g-4">
|
||||||
<p:commandButton rendered="#{Questions.showCreate}" action="#{Questions.create}" value="Nuevo" update="panelDetail"></p:commandButton>
|
<p:panel id="panelQuestionList" header="Lista de preguntas">
|
||||||
<p:orderList value="#{Questions.pendingQuestions}" var="pq"
|
<f:facet name="actions">
|
||||||
controlsLocation="none" itemValue="#{pq}">
|
<h:commandLink action="#{Questions.init}" update="frmQuestions" styleClass="ui-panel-titlebar-icon ui-corner-all ui-state-default"><h:outputText styleClass="ui-icon pi pi-refresh" /></h:commandLink>
|
||||||
<o:converter converterId="omnifaces.ListConverter"
|
<h:commandLink rendered="#{Questions.patient}" action="#{Questions.create}" update="frmQuestions" styleClass="ui-panel-titlebar-icon ui-corner-all ui-state-default"><h:outputText styleClass="ui-icon pi pi-plus" /></h:commandLink>
|
||||||
list="#{Questions.pendingQuestions}" />
|
</f:facet>
|
||||||
<p:ajax event="select" listener="#{Questions.onSelect}"
|
<p:orderList value="#{Questions.pendingQuestions}" var="pq" controlsLocation="none" itemValue="#{pq}" responsive="true">
|
||||||
update="panelDetail"></p:ajax >
|
<o:converter converterId="omnifaces.ListConverter" list="#{Questions.pendingQuestions}" />
|
||||||
<p:ajax event="unselect" listener="#{Questions.onUnSelect}"
|
<p:ajax event="select" listener="#{Questions.onSelect}" update="frmQuestions"></p:ajax>
|
||||||
update="panelDetail"></p:ajax>
|
<p:ajax event="unselect" listener="#{Questions.onUnSelect}" update="frmQuestions"></p:ajax>
|
||||||
<p:column>
|
<p:column>
|
||||||
<h:graphicImage name="images/#{pq.status}.png"
|
<h:graphicImage name="images/#{pq.status}.png" alt="#{pq.status}" styleClass="ui-theme" />
|
||||||
alt="#{pq.status}" styleClass="ui-theme" />
|
|
||||||
</p:column>
|
</p:column>
|
||||||
<p:column>
|
<p:column headerText="Título">
|
||||||
<h:outputText value="#{pq.title}" />
|
<h:outputText value="#{pq.title}" />
|
||||||
</p:column>
|
</p:column>
|
||||||
</p:orderList>
|
</p:orderList>
|
||||||
</div>
|
|
||||||
<div class="ui-g-1 ui-md-1"></div>
|
|
||||||
<div class="ui-g-8 ui-md-8">
|
|
||||||
<p:panel id="panelDetail" visible="#{Questions.showPanelDetail}" header="Pregunta de #{Questions.selected.patient.name} #{Questions.selected.patient.surname} ">
|
|
||||||
<!-- Creación de pregunta -->
|
|
||||||
<p:inputText rendered="#{Questions.selected.status == 'NEW'}" value="#{Questions.selected.title}"></p:inputText>
|
|
||||||
<p:textEditor rendered="#{Questions.selected.status == 'NEW'}" value="#{Questions.selected.message}" ></p:textEditor>
|
|
||||||
|
|
||||||
<!-- Respuesta a una pregunta -->
|
|
||||||
<h:outputText rendered="#{Questions.selected.status != 'NEW'}">#{Questions.selected.title}</h:outputText>
|
|
||||||
<h:outputText rendered="#{Questions.selected.status != 'NEW'}" value="#{Questions.selected.message}" escape="false"></h:outputText>
|
|
||||||
<p:panel rendered="#{Questions.selected.status != 'NEW'}" style="border: 0px !important;">
|
|
||||||
<h3>Respuesta:</h3>
|
|
||||||
<p:textEditor rendered="#{Questions.selected.status == 'PENDING'}" value="#{Questions.selected.response}"></p:textEditor>
|
|
||||||
<h:outputText rendered="#{Questions.selected.status == 'ANSWERED'}" value="#{Questions.selected.response}" escape="false"></h:outputText>
|
|
||||||
</p:panel>
|
</p:panel>
|
||||||
<br/>
|
</div>
|
||||||
<p:commandButton rendered="#{Questions.askButton}" value="Preguntar" action="#{Questions.askQuestion}" update="frmQuestions" icon="pi pi-save" ></p:commandButton>
|
<div class="ui-g-8">
|
||||||
<p:commandButton rendered="#{Questions.answerButton}" value="Responder" action="#{Questions.answerQuestion}" update="frmQuestions" icon="pi pi-save" ></p:commandButton>
|
<p:panel id="panelAddQuestion" rendered="#{Questions.addNewMode}" header="Añadir nueva pregunta">
|
||||||
|
<div class="ui-g ui-fluid">
|
||||||
|
<div class="ui-g-12">
|
||||||
|
<h3>Título:</h3>
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-12">
|
||||||
|
<p:inputText value="#{Questions.selected.title}" required="true" requiredMessage="Es necesario especificar el título de la pregunta" />
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-12">
|
||||||
|
<h3>Pregunta:</h3>
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-12">
|
||||||
|
<p:textEditor value="#{Questions.selected.message}" required="true" requiredMessage="Es necesario especificar el texto de la pregunta" />
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-4" />
|
||||||
|
<div class="ui-g-4">
|
||||||
|
<p:commandButton value="Preguntar" action="#{Questions.addNewQuestion}" update="frmQuestions" icon="pi pi-save" />
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-4" />
|
||||||
|
</div>
|
||||||
|
</p:panel>
|
||||||
|
<p:panel id="panelDetail" rendered="#{Questions.showPanelDetail}" header="Pregunta de #{Questions.selected.patient.displayName}">
|
||||||
|
<!-- Responder pregunta -->
|
||||||
|
<div class="ui-g ui-fluid">
|
||||||
|
<div class="ui-g-12">
|
||||||
|
<h3>Título:</h3>
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-12">
|
||||||
|
<p:inputText value="#{Questions.selected.title}" readonly="true" />
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-12">
|
||||||
|
<h3>Pregunta:</h3>
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-12">
|
||||||
|
<p:textEditor value="#{Questions.selected.message}" toolbarVisible="false" readonly="true" />
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-12">
|
||||||
|
<h3>Respuesta:</h3>
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-12">
|
||||||
|
<p:textEditor value="#{Questions.selected.response}" toolbarVisible="#{Questions.respuestaEditable}" readonly="#{not Questions.respuestaEditable}" required="true" requiredMessage="Es necesario especificar una respuesta." />
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-4" />
|
||||||
|
<div class="ui-g-4">
|
||||||
|
<p:commandButton value="Responder" rendered="#{Questions.respuestaEditable}" action="#{Questions.save}" update="frmQuestions" icon="pi pi-save" />
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-4" />
|
||||||
|
</div>
|
||||||
</p:panel>
|
</p:panel>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import java.io.Serializable;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
import javax.faces.application.FacesMessage;
|
||||||
import javax.faces.view.ViewScoped;
|
import javax.faces.view.ViewScoped;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
@@ -23,8 +24,10 @@ public class QuestionsMBean extends ManagedBeanBase implements Serializable {
|
|||||||
|
|
||||||
private int userID;
|
private int userID;
|
||||||
private UserType userType;
|
private UserType userType;
|
||||||
private List<QuestionTO> allQuestions;
|
private List<QuestionTO> pendingQuestions;
|
||||||
protected QuestionTO selected;
|
private Integer id;
|
||||||
|
private QuestionTO selected;
|
||||||
|
private boolean addNewMode;
|
||||||
|
|
||||||
public QuestionsMBean() {
|
public QuestionsMBean() {
|
||||||
}
|
}
|
||||||
@@ -34,78 +37,40 @@ public class QuestionsMBean extends ManagedBeanBase implements Serializable {
|
|||||||
// Inicialización de variables y propiedades van aquí.
|
// Inicialización de variables y propiedades van aquí.
|
||||||
this.userType = SessionUtils.getUserType();
|
this.userType = SessionUtils.getUserType();
|
||||||
this.userID = Integer.valueOf(SessionUtils.getUserId());
|
this.userID = Integer.valueOf(SessionUtils.getUserId());
|
||||||
|
|
||||||
|
this.addNewMode = false;
|
||||||
this.selected = null;
|
this.selected = null;
|
||||||
|
|
||||||
this.loadQuestions();
|
this.loadQuestions();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printSelected(String asd) {
|
|
||||||
if(asd!=null) {
|
|
||||||
asd = "'" + asd + "'";
|
|
||||||
}else {
|
|
||||||
asd = "";
|
|
||||||
}
|
|
||||||
System.out.println("Selected " + asd + ": ");
|
|
||||||
System.out.println(this.selected);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<QuestionTO> getPendingQuestions() {
|
public List<QuestionTO> getPendingQuestions() {
|
||||||
return allQuestions;
|
return pendingQuestions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPendingQuestions(List<QuestionTO> value) {
|
public void setPendingQuestions(List<QuestionTO> value) {
|
||||||
this.allQuestions = value;
|
this.pendingQuestions = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cargará las preguntas enviadas al médico o escritas por el paciente, esto irá
|
* Cargará las preguntas enviadas al médico o escritas por el paciente, esto irá
|
||||||
* en función del tipo de usuario en sesión
|
* en función del tipo de usuario en sesión
|
||||||
*/
|
*/
|
||||||
private void loadQuestions() {
|
private void loadQuestions() {
|
||||||
this.printSelected("");
|
if (this.userType == UserType.FAMILY_DOCTOR) {
|
||||||
if (userType == UserType.FAMILY_DOCTOR) {
|
|
||||||
// Listar las preguntas destinadas a él
|
// Listar las preguntas destinadas a él
|
||||||
// El método disponible del API básico es referente al doctor
|
// El método disponible del API básico es referente al doctor
|
||||||
this.allQuestions = getRemoteManagerMedicalTest().listAllPendingQuestions(userID);
|
this.pendingQuestions = getRemoteManagerMedicalTest().listAllPendingQuestions(userID);
|
||||||
} else if (userType == UserType.PATIENT) {
|
} else if (this.userType == UserType.PATIENT) {
|
||||||
// Listar las preguntas realiadas por él
|
// Listar las preguntas realiadas por él
|
||||||
// Para reutilizar la misma view, necesitaremos nuevos métodos para el API de
|
// Para reutilizar la misma view, necesitaremos nuevos métodos para el API de
|
||||||
// cara a recoger sus preguntas realizadas.
|
// cara a recoger sus preguntas realizadas.
|
||||||
this.allQuestions = getRemoteManagerMedicalTest().listAllMyQuestions(userID);
|
this.pendingQuestions = getRemoteManagerMedicalTest().listAllMyQuestions(userID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getShowCreate() {
|
|
||||||
return userType == UserType.PATIENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isShowCreate() {
|
|
||||||
return this.getShowCreate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setShowCreate() {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getDisabledMessage() {
|
|
||||||
if (this.selected != null) {
|
|
||||||
return this.selected.getStatus() != QuestionStatus.NEW;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isDisabledMessage() {
|
|
||||||
return this.getDisabledMessage();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDisabledMessage(boolean bval) {
|
|
||||||
// Nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onSelect(SelectEvent event) {
|
public void onSelect(SelectEvent event) {
|
||||||
this.printSelected("onSelect antes");
|
this.addNewMode = false;
|
||||||
this.selected = (QuestionTO) event.getObject();
|
this.selected = (QuestionTO) event.getObject();
|
||||||
this.printSelected("onSelect despues");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onUnSelect(SelectEvent event) {
|
public void onUnSelect(SelectEvent event) {
|
||||||
@@ -113,76 +78,55 @@ public class QuestionsMBean extends ManagedBeanBase implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setSelected(QuestionTO selected) {
|
public void setSelected(QuestionTO selected) {
|
||||||
this.printSelected("setSelected antes");
|
|
||||||
this.selected = selected;
|
this.selected = selected;
|
||||||
this.printSelected("setSelected despues");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public QuestionTO getSelected() {
|
public QuestionTO getSelected() {
|
||||||
return this.selected;
|
return this.selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void answerQuestion() {
|
public void save() {
|
||||||
// Es un selected recuperado de la lista
|
|
||||||
getRemoteManagerMedicalTest().answerQuestion(this.selected.getId(), this.selected.getResponse());
|
getRemoteManagerMedicalTest().answerQuestion(this.selected.getId(), this.selected.getResponse());
|
||||||
this.init();
|
this.loadQuestions();
|
||||||
}
|
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Datos guardados", "La respuesta se registrado correctamente en el sistema.");
|
||||||
|
this.selected = null;
|
||||||
public void askQuestion() {
|
|
||||||
// Es un question nuevo
|
|
||||||
QuestionTO q = this.selected;
|
|
||||||
getRemoteManagerMedicalTest().askQuestion(q.getPatient().getId(), q.getTitle(), q.getMessage());
|
|
||||||
this.init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void create() {
|
public void create() {
|
||||||
this.printSelected("create start");
|
this.addNewMode = true;
|
||||||
String template = "";
|
|
||||||
this.selected = new QuestionTO();
|
this.selected = new QuestionTO();
|
||||||
this.selected.setId(-1);
|
this.selected.setId(-1);
|
||||||
this.selected.setTitle(template);
|
this.selected.setTitle("");
|
||||||
this.selected.setMessage(template);
|
this.selected.setMessage("");
|
||||||
this.selected.setResponse(template);
|
|
||||||
this.selected.setStatus(QuestionStatus.NEW);
|
|
||||||
this.selected.getPatient().setId(Integer.parseInt(SessionUtils.getloggedOnUser().getId()));
|
|
||||||
this.selected.getPatient().setName(SessionUtils.getloggedOnUser().getName());
|
|
||||||
this.printSelected("create end");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getShowPanelDetail() {
|
public void addNewQuestion() {
|
||||||
return this.selected != null;
|
getRemoteManagerMedicalTest().askQuestion(userID, this.selected.getTitle(), this.selected.getMessage());
|
||||||
|
this.loadQuestions();
|
||||||
|
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Datos guardados", "La pregunta se registrado correctamente en el sistema.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShowPanelDetail() {
|
public boolean isShowPanelDetail() {
|
||||||
return this.getShowPanelDetail();
|
return this.selected != null && this.addNewMode == false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setShowPanelDetail() {
|
public boolean isPatient() {
|
||||||
//
|
return (this.userType == UserType.PATIENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getAskButton() {
|
public boolean isFamilyDoctor() {
|
||||||
return this.selected == null ? (userType == UserType.PATIENT)
|
return (this.userType == UserType.FAMILY_DOCTOR);
|
||||||
: (userType == UserType.PATIENT && this.selected.getStatus() == QuestionStatus.NEW);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAskButton() {
|
public boolean isAddNewMode() {
|
||||||
return this.getAskButton();
|
return addNewMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAskButton() {
|
public boolean isRespuestaEditable() {
|
||||||
|
return (this.userType == UserType.FAMILY_DOCTOR && this.selected != null && this.selected.getStatus() == QuestionStatus.PENDING);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getAnswerButton() {
|
public void setAddNewMode(boolean addNewMode) {
|
||||||
return this.selected == null ? (userType == UserType.FAMILY_DOCTOR)
|
this.addNewMode = addNewMode;
|
||||||
: (userType == UserType.FAMILY_DOCTOR && this.selected.getStatus() == QuestionStatus.PENDING);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAnswerButton() {
|
|
||||||
return this.getAnswerButton();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAnswerButton() {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user