From 2cc3008dc5152fa6920c7a162637b36d6bfca415 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Sat, 25 Apr 2020 18:45:12 +0400 Subject: [PATCH] complete dashboard --- .../ulstu/paper/controller/DashboardView.java | 48 ++++++++++ .../META-INF/resources/paper/dashboard.xhtml | 92 ++++++++++++++++--- 2 files changed, 127 insertions(+), 13 deletions(-) diff --git a/src/main/java/ru/ulstu/paper/controller/DashboardView.java b/src/main/java/ru/ulstu/paper/controller/DashboardView.java index fd7fa28..6e2e30f 100644 --- a/src/main/java/ru/ulstu/paper/controller/DashboardView.java +++ b/src/main/java/ru/ulstu/paper/controller/DashboardView.java @@ -1,12 +1,16 @@ package ru.ulstu.paper.controller; +import ru.ulstu.core.util.FacesUtil; import ru.ulstu.paper.model.Paper; import ru.ulstu.paper.service.PaperService; +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.Arrays; import java.util.List; @Named @@ -15,8 +19,15 @@ public class DashboardView { @Inject private PaperService paperService; + @Inject + private UserService userService; + private List papers; + private List selectedPapers = new ArrayList<>(); + + private String newPaperTitle; + @PostConstruct public void init() { papers = paperService.findAllActiveByCurrentUser(); @@ -25,4 +36,41 @@ public class DashboardView { public List getPapers() { return papers; } + + public void create() { + paperService.createByTitle(newPaperTitle); + FacesUtil.showInfoMessage("Статья создана", newPaperTitle); + newPaperTitle = ""; + papers = paperService.findAllActiveByCurrentUser(); + } + + public void deleteSelected() { + paperService.delete(selectedPapers); + papers = paperService.findAllActiveByCurrentUser(); + FacesUtil.showInfoMessage("Было удалено статей: " + selectedPapers.size(), ""); + } + + public List getPaperStatuses() { + return Arrays.asList(Paper.PaperStatus.values()); + } + + public String getNewPaperTitle() { + return newPaperTitle; + } + + public void setNewPaperTitle(String newPaperTitle) { + this.newPaperTitle = newPaperTitle; + } + + public List getSelectedPapers() { + return selectedPapers; + } + + public void setSelectedPapers(List selectedPapers) { + this.selectedPapers = selectedPapers; + } + + public String getCurrentUser() { + return userService.getCurrentUser().getUserAbbreviate(); + } } diff --git a/src/main/resources/META-INF/resources/paper/dashboard.xhtml b/src/main/resources/META-INF/resources/paper/dashboard.xhtml index 6137a8f..8a67bb5 100644 --- a/src/main/resources/META-INF/resources/paper/dashboard.xhtml +++ b/src/main/resources/META-INF/resources/paper/dashboard.xhtml @@ -5,19 +5,85 @@ xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:f="http://xmlns.jcp.org/jsf/core"> - - - - #{paper.title} - - - - - - - - - + + + +
+
+
+ + +
+
+ + +
+
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + #{paper.title} + + + + + + + + + + + + + + + +
+