add conferences
parent
5ae17fbe83
commit
b662437afe
@ -0,0 +1,71 @@
|
|||||||
|
package ru.ulstu.conference.controller;
|
||||||
|
|
||||||
|
import ru.ulstu.conference.model.Conference;
|
||||||
|
import ru.ulstu.conference.service.ConferenceService;
|
||||||
|
import ru.ulstu.core.util.FacesUtil;
|
||||||
|
import ru.ulstu.user.service.UserService;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import javax.faces.view.ViewScoped;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Named
|
||||||
|
@ViewScoped
|
||||||
|
public class ConferenceDashboardView {
|
||||||
|
@Inject
|
||||||
|
private ConferenceService conferenceService;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private UserService userService;
|
||||||
|
|
||||||
|
private List<Conference> conferences;
|
||||||
|
|
||||||
|
private List<Conference> selectedConferences = new ArrayList<>();
|
||||||
|
|
||||||
|
private String newConferenceTitle;
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void init() {
|
||||||
|
conferences = conferenceService.findAllActiveByCurrentUser();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Conference> getConferences() {
|
||||||
|
return conferences;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void create() {
|
||||||
|
conferenceService.createByTitle(newConferenceTitle);
|
||||||
|
FacesUtil.showInfoMessage("Статья создана", newConferenceTitle);
|
||||||
|
newConferenceTitle = "";
|
||||||
|
conferences = conferenceService.findAllActiveByCurrentUser();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteSelected() {
|
||||||
|
conferenceService.delete(selectedConferences);
|
||||||
|
conferences = conferenceService.findAllActiveByCurrentUser();
|
||||||
|
FacesUtil.showInfoMessage("Было удалено статей: " + selectedConferences.size(), "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNewConferenceTitle() {
|
||||||
|
return newConferenceTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNewConferenceTitle(String newConferenceTitle) {
|
||||||
|
this.newConferenceTitle = newConferenceTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Conference> getSelectedConferences() {
|
||||||
|
return selectedConferences;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelectedConferences(List<Conference> selectedConferences) {
|
||||||
|
this.selectedConferences = selectedConferences;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCurrentUser() {
|
||||||
|
return userService.getCurrentUser().getUserAbbreviate();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,89 @@
|
|||||||
|
package ru.ulstu.conference.controller;
|
||||||
|
|
||||||
|
import ru.ulstu.conference.model.Conference;
|
||||||
|
import ru.ulstu.conference.service.ConferenceService;
|
||||||
|
import ru.ulstu.core.navigation.Page;
|
||||||
|
import ru.ulstu.core.util.FacesUtil;
|
||||||
|
import ru.ulstu.deadline.model.Deadline;
|
||||||
|
import ru.ulstu.deadline.service.DeadlineService;
|
||||||
|
import ru.ulstu.user.model.User;
|
||||||
|
import ru.ulstu.user.service.UserService;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import javax.faces.view.ViewScoped;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Named
|
||||||
|
@ViewScoped
|
||||||
|
public class ConferenceView implements Serializable {
|
||||||
|
@Inject
|
||||||
|
private ConferenceService conferenceService;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private DeadlineService deadlineService;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private UserService userService;
|
||||||
|
|
||||||
|
private Conference conference;
|
||||||
|
|
||||||
|
private Date newDeadlineDate;
|
||||||
|
|
||||||
|
private String newDeadlineDescription;
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void init() {
|
||||||
|
conference = conferenceService.findOne(Integer.valueOf(FacesUtil.getRequestParams().get("id")));
|
||||||
|
newDeadlineDescription = "";
|
||||||
|
newDeadlineDate = new Date();
|
||||||
|
FacesUtil.showInfoMessage("Статья открыта", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Conference getConference() {
|
||||||
|
return conference;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConference(Conference conference) {
|
||||||
|
this.conference = conference;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<User> getAuthors() {
|
||||||
|
return userService.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String save() {
|
||||||
|
conferenceService.save(conference);
|
||||||
|
FacesUtil.showInfoMessage("Статья сохранена", "");
|
||||||
|
return Page.CONFERENCE_LIST + "?faces-redirect=true";
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getNewDeadlineDate() {
|
||||||
|
return newDeadlineDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNewDeadlineDate(Date newDeadlineDate) {
|
||||||
|
this.newDeadlineDate = newDeadlineDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNewDeadlineDescription() {
|
||||||
|
return newDeadlineDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNewDeadlineDescription(String newDeadlineDescription) {
|
||||||
|
this.newDeadlineDescription = newDeadlineDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteDeadline(Deadline deadline) {
|
||||||
|
conference.getDeadlines().remove(deadline);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addDeadline() {
|
||||||
|
conference.getDeadlines().add(deadlineService.create(newDeadlineDescription, newDeadlineDate));
|
||||||
|
newDeadlineDescription = "";
|
||||||
|
newDeadlineDate = new Date();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
package ru.ulstu.conference.controller;
|
||||||
|
|
||||||
|
import ru.ulstu.conference.model.Conference;
|
||||||
|
import ru.ulstu.conference.service.ConferenceService;
|
||||||
|
import ru.ulstu.core.util.FacesUtil;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import javax.faces.view.ViewScoped;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Named
|
||||||
|
@ViewScoped
|
||||||
|
public class ConferencesView {
|
||||||
|
@Inject
|
||||||
|
private ConferenceService conferenceService;
|
||||||
|
|
||||||
|
private List<Conference> conferences;
|
||||||
|
|
||||||
|
private List<Conference> selectedConferences = new ArrayList<>();
|
||||||
|
|
||||||
|
private String newConferenceTitle;
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void init() {
|
||||||
|
conferences = conferenceService.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void create() {
|
||||||
|
conferenceService.createByTitle(newConferenceTitle);
|
||||||
|
FacesUtil.showInfoMessage("Конференция создана", newConferenceTitle);
|
||||||
|
newConferenceTitle = "";
|
||||||
|
conferences = conferenceService.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteSelected() {
|
||||||
|
conferenceService.delete(selectedConferences);
|
||||||
|
conferences = conferenceService.findAll();
|
||||||
|
FacesUtil.showInfoMessage("Было удалено конференций: " + selectedConferences.size(), "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Conference> getConferences() {
|
||||||
|
return conferences;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNewConferenceTitle() {
|
||||||
|
return newConferenceTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNewConferenceTitle(String newConferenceTitle) {
|
||||||
|
this.newConferenceTitle = newConferenceTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Conference> getSelectedConferences() {
|
||||||
|
return selectedConferences;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelectedConferences(List<Conference> selectedConferences) {
|
||||||
|
this.selectedConferences = selectedConferences;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,124 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||||
|
xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:p="http://primefaces.org/ui"
|
||||||
|
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||||
|
>
|
||||||
|
<ui:composition template="/basicTemplate.xhtml">
|
||||||
|
<ui:define name="header">
|
||||||
|
Редактирование конференции
|
||||||
|
</ui:define>
|
||||||
|
<ui:define name="content">
|
||||||
|
<style>
|
||||||
|
#mainForm\:conferencePanel > tbody > tr {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#mainForm\:conferencePanel > tbody > tr > td {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ui-editor.ui-widget-content {
|
||||||
|
background: white !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<p:panel id="panel" header="Редактирование конференции: #{conferenceView.conference.title}"
|
||||||
|
style="margin-bottom:10px;">
|
||||||
|
<div class="ui-fluid">
|
||||||
|
<div class="ui-g">
|
||||||
|
<div class="ui-md-3 ui-g-12">
|
||||||
|
<h:outputLabel value="Название:"/>
|
||||||
|
</div>
|
||||||
|
<div class="ui-md-7 ui-g-12">
|
||||||
|
<p:inputText id="name" required="true" value="#{conferenceView.conference.title}"/>
|
||||||
|
<p:message for="name"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="ui-md-3 ui-g-12">
|
||||||
|
<h:outputLabel value="Ссылка:"/>
|
||||||
|
</div>
|
||||||
|
<div class="ui-md-7 ui-g-12">
|
||||||
|
<p:inputText id="url" required="true" value="#{conferenceView.conference.url}"/>
|
||||||
|
<p:message for="url"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="ui-md-2 ui-g-12">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="ui-md-3 ui-g-12">
|
||||||
|
<!-- <p:outputLabel for="authors" value="Авторы:"/>-->
|
||||||
|
</div>
|
||||||
|
<div class="ui-md-7 ui-g-12">
|
||||||
|
<!-- <p:selectCheckboxMenu id="authors" value="#{conferenceView.conference.users}" multiple="true"-->
|
||||||
|
<!-- converter="#{conferenceUserConverter}">-->
|
||||||
|
<!-- <f:attribute name="collectionType" value="java.util.HashSet"/>-->
|
||||||
|
<!-- <f:selectItems value="#{conferenceView.authors}"-->
|
||||||
|
<!-- var="author"-->
|
||||||
|
<!-- itemLabel="#{author.userAbbreviate}"-->
|
||||||
|
<!-- itemValue="#{author}"/>-->
|
||||||
|
<!-- </p:selectCheckboxMenu>-->
|
||||||
|
</div>
|
||||||
|
<div class="ui-md-3 ui-g-12">
|
||||||
|
<!-- <p:outputLabel for="authors" value="Ключевые даты:"/>-->
|
||||||
|
</div>
|
||||||
|
<div class="ui-md-7 ui-g-12">
|
||||||
|
<div class="ui-fluid">
|
||||||
|
<div class="ui-g">
|
||||||
|
<ui:repeat value="#{conferenceView.conference.deadlines}" var="deadline">
|
||||||
|
<div class="ui-md-5 ui-g-12">
|
||||||
|
<p:datePicker value="#{deadline.date}" pattern="dd.MM.yyyy"/>
|
||||||
|
</div>
|
||||||
|
<div class="ui-md-5 ui-g-12">
|
||||||
|
<p:inputText value="#{deadline.description}"/>
|
||||||
|
</div>
|
||||||
|
<div class="ui-md-1 ui-g-12">
|
||||||
|
<p:commandButton icon="pi pi-times">
|
||||||
|
<p:ajax update="mainForm" process="@this"
|
||||||
|
listener="#{conferenceView.deleteDeadline(deadline)}"/>
|
||||||
|
</p:commandButton>
|
||||||
|
</div>
|
||||||
|
</ui:repeat>
|
||||||
|
<div class="ui-md-5 ui-g-12">
|
||||||
|
<p:datePicker value="#{conferenceView.newDeadlineDate}" placeholder="Введите дату"
|
||||||
|
pattern="dd.MM.yyyy"/>
|
||||||
|
</div>
|
||||||
|
<div class="ui-md-5 ui-g-12">
|
||||||
|
<p:inputText value="#{conferenceView.newDeadlineDescription}"
|
||||||
|
placeholder="Описание ключевой даты"/>
|
||||||
|
</div>
|
||||||
|
<div class="ui-md-1 ui-g-12">
|
||||||
|
<p:commandButton icon="pi pi-check">
|
||||||
|
<p:ajax update="mainForm" process="@this"
|
||||||
|
listener="#{conferenceView.addDeadline()}"/>
|
||||||
|
</p:commandButton>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="ui-md-3 ui-g-12">
|
||||||
|
<p:outputLabel for="comment" value="Комментарий:"/>
|
||||||
|
</div>
|
||||||
|
<div class="ui-md-7 ui-g-12">
|
||||||
|
<p:editor id="comment" widgetVar="editor2" value="#{conferenceView.conference.description}"
|
||||||
|
height="300"
|
||||||
|
style="margin-bottom:10px" placeholder="Комментарий"/>
|
||||||
|
</div>
|
||||||
|
<div class="ui-md-2 ui-g-12">
|
||||||
|
<p>
|
||||||
|
Конференция создана
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Конференция обновлена
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="ui-md-5 ui-g-12">
|
||||||
|
<p:commandButton action="#{conferenceView.save}" value="Сохранить" ajax="true" process="@form"
|
||||||
|
update="messages @form"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</p:panel>
|
||||||
|
</ui:define>
|
||||||
|
</ui:composition>
|
||||||
|
</html>
|
@ -0,0 +1,10 @@
|
|||||||
|
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
|
||||||
|
xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:p="http://java.sun.com/jsf/html">
|
||||||
|
<span class="fa-stack fa-1x big-icon" title="#{conference.status.statusName}">
|
||||||
|
<i class="fa fa-circle #{conference.status.elementClass} fa-stack-2x"></i>
|
||||||
|
<i class="fa fa-file-text-o fa-stack-1x fa-inverse"></i>
|
||||||
|
</span>
|
||||||
|
<ui:fragment rendered="#{shortMode != true}">
|
||||||
|
<p:outputText value="#{conference.status.statusName}"/>
|
||||||
|
</ui:fragment>
|
||||||
|
</ui:composition>
|
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
|
||||||
|
<changeSet author="orion" id="20200427_164000-1">
|
||||||
|
<addColumn tableName="paper">
|
||||||
|
<column name="conference_id" type="integer"/>
|
||||||
|
</addColumn>
|
||||||
|
<addForeignKeyConstraint baseTableName="paper" baseColumnNames="conference_id" constraintName="fk_conference"
|
||||||
|
referencedTableName="conference" referencedColumnNames="id"/>
|
||||||
|
<dropTable tableName="paper_conference"/>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
|
||||||
|
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
|
||||||
|
<include file="db/0.1.0/changelog-20200427_164000-schema.xml"/>
|
||||||
|
</databaseChangeLog>
|
Loading…
Reference in New Issue