ref #6169 message count indicator, edit reference button and impoved layout
authorAndreas Kohlbecker <a.kohlbecker@bgbm.org>
Tue, 4 Apr 2017 08:44:36 +0000 (10:44 +0200)
committerAndreas Kohlbecker <a.kohlbecker@bgbm.org>
Tue, 4 Apr 2017 08:44:36 +0000 (10:44 +0200)
src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/ButtonFactory.java [new file with mode: 0644]
src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/RegistrationItem.java
src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/RegistrationStyles.java
src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/TypeStateLabel.java
src/main/java/eu/etaxonomy/cdm/vaadin/event/AbstractEntityEvent.java
src/main/java/eu/etaxonomy/cdm/vaadin/event/ReferenceEvent.java
src/main/java/eu/etaxonomy/cdm/vaadin/model/registration/RegistrationWorkingSet.java
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/registration/RegistrationWorkflowPresenter.java
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkflowViewBean.java
src/main/webapp/VAADIN/themes/edit-valo/edit-valo.scss

diff --git a/src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/ButtonFactory.java b/src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/ButtonFactory.java
new file mode 100644 (file)
index 0000000..552f75a
--- /dev/null
@@ -0,0 +1,18 @@
+/**
+* Copyright (C) 2017 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.cdm.vaadin.component.registration;
+
+/**
+ * @author a.kohlbecker
+ * @since Apr 3, 2017
+ *
+ */
+public class ButtonFactory {
+
+}
index 38f8daeddee0afc31e36772a79adee1a8ed2b383..094bb72b545e0a1548c77665d6745274e2c1b692 100644 (file)
@@ -8,13 +8,14 @@
 */
 package eu.etaxonomy.cdm.vaadin.component.registration;
 
-import static eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStyles.STYLE_LABEL_NOWRAP;
+import static eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStyles.LABEL_NOWRAP;
 
 import org.joda.time.DateTime;
 import org.joda.time.format.ISODateTimeFormat;
 
 import com.vaadin.server.ExternalResource;
 import com.vaadin.server.FontAwesome;
+import com.vaadin.server.Resource;
 import com.vaadin.shared.ui.label.ContentMode;
 import com.vaadin.ui.Alignment;
 import com.vaadin.ui.Button;
@@ -25,6 +26,8 @@ import com.vaadin.ui.Link;
 import com.vaadin.ui.themes.ValoTheme;
 
 import eu.etaxonomy.cdm.model.common.TimePeriod;
+import eu.etaxonomy.cdm.vaadin.event.EntityEventType;
+import eu.etaxonomy.cdm.vaadin.event.ReferenceEvent;
 import eu.etaxonomy.cdm.vaadin.event.ShowDetailsEvent;
 import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet;
 import eu.etaxonomy.cdm.vaadin.presenter.registration.RegistrationDTO;
@@ -62,7 +65,7 @@ public class RegistrationItem extends GridLayout {
     private Link identifierLink = new Link();
     private Label citationSummaryLabel = new Label();
     private Button blockedByButton = new Button(FontAwesome.WARNING);
-    private Button messageButton = new Button(FontAwesome.COMMENT);
+    private Button messageButton;
     private Button openButton = new Button(FontAwesome.COGS);
     private Label createdLabel = new Label();
     private Label publishedLabel = new Label();
@@ -94,7 +97,7 @@ public class RegistrationItem extends GridLayout {
         setWidth(100, Unit.PERCENTAGE);
         addStyleName("registration-list-item");
 
-        typeStateLabel.setStyleName(STYLE_LABEL_NOWRAP);
+        typeStateLabel.setStyleName(LABEL_NOWRAP);
         typeStateLabel.setVisible(false);
         addComponent(typeStateLabel, 0, 0);
         setComponentAlignment(typeStateLabel, Alignment.TOP_LEFT);
@@ -104,11 +107,13 @@ public class RegistrationItem extends GridLayout {
         setComponentAlignment(identifierLink, Alignment.TOP_CENTER);
         setColumnExpandRatio(1, 1.0f);
 
+        messageButton = new Button(FontAwesome.COMMENT);
         CssLayout buttonGroup = new CssLayout(blockedByButton, messageButton, openButton);
         blockedByButton.setStyleName(ValoTheme.BUTTON_TINY);
         blockedByButton.setEnabled(false);
         messageButton.setStyleName(ValoTheme.BUTTON_TINY);
         messageButton.setEnabled(false);
+
         openButton.setStyleName(ValoTheme.BUTTON_TINY);
         openButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
         openButton.setVisible(false);
@@ -120,20 +125,20 @@ public class RegistrationItem extends GridLayout {
         citationSummaryLabel.setContentMode(ContentMode.HTML);
         addComponent(citationSummaryLabel, 0, 1, 1, 3);
 
-        createdLabel.setStyleName(STYLE_LABEL_NOWRAP);
+        createdLabel.setStyleName(LABEL_NOWRAP);
         createdLabel.setContentMode(ContentMode.HTML);
         createdLabel.setWidthUndefined();
         addComponent(createdLabel, 2, 1);
         setComponentAlignment(createdLabel, Alignment.BOTTOM_RIGHT);
 
-        publishedLabel.setStyleName(STYLE_LABEL_NOWRAP);
+        publishedLabel.setStyleName(LABEL_NOWRAP);
         publishedLabel.setContentMode(ContentMode.HTML);
         publishedLabel.setWidthUndefined();
         publishedLabel.setVisible(false);
         addComponent(publishedLabel, 2, 2);
         setComponentAlignment(publishedLabel, Alignment.BOTTOM_RIGHT);
 
-        releasedLabel.setStyleName(STYLE_LABEL_NOWRAP);
+        releasedLabel.setStyleName(LABEL_NOWRAP);
         releasedLabel.setContentMode(ContentMode.HTML);
         releasedLabel.setWidthUndefined();
         releasedLabel.setVisible(false);
@@ -144,26 +149,42 @@ public class RegistrationItem extends GridLayout {
 
     public void setItem(RegistrationDTO regDto, AbstractView<?> parentView){
         this.parentView = parentView;
-        updateUI(regDto.getCitationString(), regDto.getCreated(), regDto.getDatePublished(), regDto.getMessages().size(), regDto);
+
+        NavigationEvent openButtonEvent = new NavigationEvent(
+                RegistrationWorkflowViewBean.NAME,
+                RegistrationWorkflowViewBean.ACTION_EDIT,
+                Integer.toString(regDto.getId())
+                );
+
+        updateUI(regDto.getCitationString(), regDto.getCreated(), regDto.getDatePublished(), regDto.getMessages().size(),
+                openButtonEvent, null, regDto);
     }
 
     public void setWorkingSet(RegistrationWorkingSet workingSet, AbstractView<?> parentView){
         this.parentView = parentView;
-        updateUI(workingSet.getCitation(), workingSet.getCreated(), null, workingSet.messagesCount(), null);
+        ReferenceEvent openButtonEvent;
+        if(workingSet.getCitationId() != null){
+            openButtonEvent = new ReferenceEvent(EntityEventType.EDIT, workingSet.getCitationId());
+        } else {
+            openButtonEvent = new ReferenceEvent(EntityEventType.ADD);
+        }
+        updateUI(workingSet.getCitation(), workingSet.getCreated(), null, workingSet.messagesCount(),
+                openButtonEvent, FontAwesome.EDIT, null);
     }
 
 
     /**
      *
      */
-    private void updateUI(String citationString,  DateTime created, TimePeriod datePublished,  int messagesCount, RegistrationDTO regDto) {
+    private void updateUI(String citationString,  DateTime created, TimePeriod datePublished,  int messagesCount,
+            Object openButtonEvent, Resource openButtonIcon, RegistrationDTO regDto) {
 
         StringBuffer labelMarkup = new StringBuffer();
         DateTime registrationDate = null;
 
         if(messagesCount > 0){
             getMessageButton().setEnabled(true);
-            getMessageButton().addStyleName(ValoTheme.BUTTON_FRIENDLY);
+            // getMessageButton().addStyleName(RegistrationStyles.STYLE_FRIENDLY_FOREGROUND);
             getMessageButton().addClickListener(e -> {
                 ShowDetailsEvent detailsEvent;
                 if(regDto != null){
@@ -182,9 +203,22 @@ public class RegistrationItem extends GridLayout {
                 publishEvent(detailsEvent);
                 }
             );
+            getMessageButton().setCaption("<span class=\"" + RegistrationStyles.BUTTON_BADGE +"\"> " + messagesCount + "</span>");
+            getMessageButton().setCaptionAsHtml(true);
         }
 
         labelMarkup.append(citationString);
+
+        if(openButtonEvent != null){
+            // Buttons
+            getOpenButton().setVisible(true);
+            getOpenButton().addClickListener(e -> publishEvent(openButtonEvent));
+        }
+
+        if(openButtonIcon != null){
+            getOpenButton().setIcon(openButtonIcon);
+        }
+
         if(regDto != null){
             labelMarkup.append("</br>").append(regDto.getSummary());
 
@@ -195,17 +229,10 @@ public class RegistrationItem extends GridLayout {
             getIdentifierLink().setVisible(true);
             getIdentifierLink().setCaption(regDto.getIdentifier());
 
-            // Buttons
-            getOpenButton().setVisible(true);
-            getOpenButton().addClickListener(e -> publishEvent(new NavigationEvent(
-                    RegistrationWorkflowViewBean.NAME,
-                    RegistrationWorkflowViewBean.ACTION_EDIT,
-                    Integer.toString(regDto.getId())
-                    )));
-
             registrationDate = regDto.getRegistrationDate();
         }
 
+
         getCitationSummaryLabel().setValue(labelMarkup.toString());
         updateDateLabels(created, datePublished, registrationDate);
     }
index 641f1b8e20f512e2943c0e4fbfa2974a90119e9d..82a85a2e6823015c1e6966df466e0924a949e091 100644 (file)
@@ -15,6 +15,11 @@ package eu.etaxonomy.cdm.vaadin.component.registration;
  */
 public class RegistrationStyles {
 
-    public static final String STYLE_LABEL_NOWRAP = "label-nowrap";
+    public static final String LABEL_NOWRAP = "label-nowrap";
+
+    public static final String FRIENDLY_FOREGROUND = "friendly-foreground";
+
+    public static final String BUTTON_BADGE = "button-badge";
+
 
 }
index c2c78cc7820fa118ee9096073a9532ab9c7b0ed5..6f9d549b1758a6f4985cb2643778b2dbb045c430 100644 (file)
@@ -9,7 +9,7 @@
 package eu.etaxonomy.cdm.vaadin.component.registration;
 
 
-import static eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStyles.STYLE_LABEL_NOWRAP;
+import static eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStyles.LABEL_NOWRAP;
 
 import org.apache.commons.lang.StringUtils;
 
@@ -37,7 +37,7 @@ public class TypeStateLabel extends Label {
      *
      */
     public TypeStateLabel() {
-        setStyleName(STYLE_LABEL_NOWRAP);
+        setStyleName(LABEL_NOWRAP);
     }
 
     /**
index 6ca9ce5f6f3d7ce3c973b7835f6b846227ce7aa7..ffa7b569f0f316216019feeaaa4ba362c2faee9f 100644 (file)
@@ -18,11 +18,18 @@ public abstract class AbstractEntityEvent {
 
     private EntityEventType eventType;
 
-    public AbstractEntityEvent(EntityEventType eventType) {
+    private Integer entityId = null;
+
+    public AbstractEntityEvent(EntityEventType eventType, Integer entityId) {
         this.eventType = eventType;
         if(eventType == null){
             throw new NullPointerException();
         }
+        this.setEntityId(entityId);
+    }
+
+    public AbstractEntityEvent(EntityEventType eventType) {
+        this(eventType, null);
     }
 
     public EntityEventType getEventType() {
@@ -39,4 +46,18 @@ public abstract class AbstractEntityEvent {
         return eventType.equals(EntityEventType.REMOVE);
     }
 
+    /**
+     * @return the entityId
+     */
+    public Integer getEntityId() {
+        return entityId;
+    }
+
+    /**
+     * @param entityId the entityId to set
+     */
+    private void setEntityId(Integer entityId) {
+        this.entityId = entityId;
+    }
+
 }
index 1f17a409c114b574ec765fc2a5a70ad256031aa9..8799bad1012880e57c8440192081a6bc94f6ffc8 100644 (file)
@@ -15,9 +15,22 @@ package eu.etaxonomy.cdm.vaadin.event;
  */
 public class ReferenceEvent extends AbstractEntityEvent {
 
-
+    /**
+     * @param eventType
+     */
     public ReferenceEvent(EntityEventType eventType) {
         super(eventType);
     }
 
+    /**
+     * @param eventType
+     * @param entityId
+     */
+    public ReferenceEvent(EntityEventType eventType, Integer entityId) {
+        super(eventType, entityId);
+    }
+
+
+
+
 }
index 9133c2018d4bde719973d8450ecaf3f209ab85f3..0cf0c83999ab18cae6ced03f6ad4c051fc4986d8 100644 (file)
@@ -30,7 +30,7 @@ public class RegistrationWorkingSet {
 
     private List<RegistrationDTO> registrationDTOs = new ArrayList<>();
 
-    private int citationId = -1;
+    private Integer citationId = null;
 
     private DateTime created = null;
 
@@ -74,7 +74,7 @@ public class RegistrationWorkingSet {
             problems = new ArrayList<>();
         }
         for(RegistrationDTO regDto : candidates){
-                if(citationId == -1){
+                if(citationId == null){
                     citationId = regDto.getCitationID();
                     citation = regDto.getCitation();
                 } else {
@@ -155,7 +155,7 @@ public class RegistrationWorkingSet {
     /**
      * @return the citationId
      */
-    public int getCitationId() {
+    public Integer getCitationId() {
         return citationId;
     }
 
index 046d73bbb72e4807655a12490f87761166a8adcc..406054cab86919f0bce363935893942140d4d106 100644 (file)
@@ -95,7 +95,7 @@ public class RegistrationWorkflowPresenter extends AbstractPresenter<Registratio
     }
 
     @EventListener(classes=ShowDetailsEvent.class, condition = "#event.entityType == T(eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet)")
-    public void onShowDetailsEvent(ShowDetailsEvent<?,?> event) { // WARNING don't use more specific generic type arguments
+    public void onShowRegistrationWorkingSetMessages(ShowDetailsEvent<?,?> event) { // WARNING don't use more specific generic type arguments
         List<String> messages = new ArrayList<>();
         for(RegistrationDTO dto : workingset.getRegistrationDTOs()){
             dto.getMessages().forEach(m -> messages.add(dto.getSummary() + ": " + m));
@@ -105,4 +105,12 @@ public class RegistrationWorkflowPresenter extends AbstractPresenter<Registratio
         }
     }
 
+    @EventListener(classes=ShowDetailsEvent.class, condition = "#event.entityType == T(eu.etaxonomy.cdm.vaadin.presenter.registration.RegistrationDTO)")
+    public void onShowRegistrationMessages(ShowDetailsEvent<?,?> event) { // WARNING don't use more specific generic type arguments
+        RegistrationDTO regDto = serviceMock.loadDtoById((Integer)event.getIdentifier());
+        if(event.getProperty().equals("messages")){
+            getView().openDetailsPopup("Messages", regDto.getMessages());
+        }
+    }
+
 }
index 5d94e89183804df7d76757e2a2b8071921c08dc3..a7cb45df62fe75c344addd4f6ca911a0d1d0838d 100644 (file)
@@ -20,6 +20,7 @@ import com.vaadin.server.FontAwesome;
 import com.vaadin.server.GenericFontIcon;
 import com.vaadin.server.Page;
 import com.vaadin.spring.annotation.SpringView;
+import com.vaadin.ui.Alignment;
 import com.vaadin.ui.Button;
 import com.vaadin.ui.Component;
 import com.vaadin.ui.CssLayout;
@@ -32,10 +33,12 @@ import com.vaadin.ui.TabSheet.Tab;
 import com.vaadin.ui.themes.ValoTheme;
 
 import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItem;
+import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStyles;
 import eu.etaxonomy.cdm.vaadin.component.registration.TypeStateLabel;
 import eu.etaxonomy.cdm.vaadin.component.registration.WorkflowSteps;
 import eu.etaxonomy.cdm.vaadin.event.EntityEventType;
 import eu.etaxonomy.cdm.vaadin.event.ReferenceEvent;
+import eu.etaxonomy.cdm.vaadin.event.ShowDetailsEvent;
 import eu.etaxonomy.cdm.vaadin.event.TaxonNameEvent;
 import eu.etaxonomy.cdm.vaadin.event.registration.RegistrationWorkflowEvent;
 import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet;
@@ -55,7 +58,9 @@ public class RegistrationWorkflowViewBean extends AbstractPageView<RegistrationW
     implements RegistrationWorkflowView, View {
 
 
-    public static final String CSS_CLASS_WORKFLOW = "workflow-container";
+    public static final String DOM_ID_WORKFLOW = "workflow-container";
+
+    public static final String DOM_ID_WORKINGSET = "workingset";
 
     public static final String SUBHEADER_DEEFAULT = "Advance step by step through the registration workflow.";
 
@@ -82,7 +87,7 @@ public class RegistrationWorkflowViewBean extends AbstractPageView<RegistrationW
 
         workflow = new CssLayout();
         workflow.setSizeFull();
-        workflow.setId(CSS_CLASS_WORKFLOW);
+        workflow.setId(DOM_ID_WORKFLOW);
         getLayout().addComponent(workflow);
     }
 
@@ -114,11 +119,14 @@ public class RegistrationWorkflowViewBean extends AbstractPageView<RegistrationW
     public void setWorkingset(RegistrationWorkingSet workingset) {
 
         CssLayout registration = new CssLayout();
+        registration.setId(DOM_ID_WORKINGSET);
         registration.setWidth(100, Unit.PERCENTAGE);
 
         Panel namesTypesPanel = createNamesAndTypesList(workingset);
+        namesTypesPanel.setStyleName("names-types-list");
         namesTypesPanel.setCaption("Names & Types");
 
+
         registration.addComponent(createWorkflowTabSheet(workingset, null));
         registration.addComponent(new RegistrationItem(workingset, this));
         registration.addComponent(namesTypesPanel);
@@ -174,21 +182,45 @@ public class RegistrationWorkflowViewBean extends AbstractPageView<RegistrationW
      */
     public Panel createNamesAndTypesList(RegistrationWorkingSet workingset) {
         // prepare name and type list
-        GridLayout namesTypesList = new GridLayout(4, workingset.getRegistrationDTOs().size());
+        GridLayout namesTypesList = new GridLayout(3, workingset.getRegistrationDTOs().size());
         int row = 0;
         for(RegistrationDTO dto : workingset.getRegistrationDTOs()) {
-            Button commentButton = new Button(FontAwesome.COMMENT);
-            commentButton.setStyleName(ValoTheme.BUTTON_BORDERLESS);
+
+            Button messageButton = new Button(FontAwesome.COMMENT);
+            messageButton.setStyleName(ValoTheme.BUTTON_TINY); //  + " " + RegistrationStyles.STYLE_FRIENDLY_FOREGROUND);
+            if(dto.getMessages().isEmpty()){
+                messageButton.setEnabled(false);
+            } else {
+                messageButton.addClickListener(e -> eventBus.publishEvent(
+                        new ShowDetailsEvent<RegistrationDTO, Integer>(
+                            e,
+                            RegistrationDTO.class,
+                            dto.getId(),
+                            "messages"
+                            )
+                        )
+                    );
+            }
+            messageButton.setCaption("<span class=\"" + RegistrationStyles.BUTTON_BADGE +"\"> " + dto.getMessages().size() + "</span>");
+            messageButton.setCaptionAsHtml(true);
+
             Button editButton = new Button(FontAwesome.EDIT);
-            editButton.setStyleName(ValoTheme.BUTTON_BORDERLESS);
+            editButton.setStyleName(ValoTheme.BUTTON_TINY + " " + ValoTheme.BUTTON_PRIMARY);
 
             namesTypesList.addComponent(new TypeStateLabel().update(dto.getRegistrationType(), dto.getStatus()), 0, row);
             namesTypesList.addComponent(new Label(dto.getSummary()), 1, row);
-            namesTypesList.addComponent(commentButton, 2, row);
-            namesTypesList.addComponent(editButton, 3, row);
+            CssLayout buttonGroup = new CssLayout();
+            buttonGroup.setStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
+            buttonGroup.addComponent(messageButton);
+            buttonGroup.addComponent(editButton);
+            namesTypesList.addComponent(buttonGroup, 2, row);
+            namesTypesList.setComponentAlignment(buttonGroup, Alignment.TOP_RIGHT);
             row++;
         }
         namesTypesList.setSizeUndefined();
+        namesTypesList.setWidth(100, Unit.PERCENTAGE);
+        namesTypesList.setColumnExpandRatio(0, 0.1f);
+        namesTypesList.setColumnExpandRatio(1, 0.9f);
         Panel namesTypesPanel = new Panel(namesTypesList);
         namesTypesPanel.setHeight("300px");
         return namesTypesPanel;
index 806626e452636ac282ad699d14aa5eda1a685675..55f689e4844fbef3b1f09a18265ffb276cd2e002 100644 (file)
@@ -132,7 +132,14 @@ $status-ready-color: adjust-color($plain-red, $hue: 180deg);
            display : inline;
         }
     }
+
+   .friendly-foreground {
+        color: $v-friendly-color;
+    }
    
+   .v-button .button-badge {
+         @include valo-badge-style($states: inactive, $background-color: lighten($v-background-color, 10%), $active-color: $v-focus-color);
+    } 
    
    .dashboard-actions {
       margin: 0 10%;
@@ -220,6 +227,13 @@ $status-ready-color: adjust-color($plain-red, $hue: 180deg);
         }
     }
 
+    #workingset {
+            padding: round($v-unit-size / 2);
+            .names-types-list, .registration-list-item {
+                margin-top: round($v-unit-size / 2);
+            }
+    }
+
     // --------------------------------------------------- //
     
     .registration-list-item {