syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From skylar...@apache.org
Subject syncope git commit: [SYNCOPE-1096] 'download' and 'remove' buttons are now properly hidden or shown while editing a binary attribute
Date Mon, 07 Aug 2017 12:30:24 GMT
Repository: syncope
Updated Branches:
  refs/heads/2_0_X a623680a7 -> b4b1ec89e


[SYNCOPE-1096] 'download' and 'remove' buttons are now properly hidden or shown while editing
a binary attribute


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/b4b1ec89
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/b4b1ec89
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/b4b1ec89

Branch: refs/heads/2_0_X
Commit: b4b1ec89eb3784fe0d7cdfbbceabda82f9e1af5d
Parents: a623680
Author: skylark17 <matteo.alessandroni@tirasa.net>
Authored: Mon Aug 7 14:29:57 2017 +0200
Committer: skylark17 <matteo.alessandroni@tirasa.net>
Committed: Mon Aug 7 14:29:57 2017 +0200

----------------------------------------------------------------------
 .../markup/html/form/BinaryFieldPanel.java      | 29 ++++++++++++++------
 1 file changed, 21 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/b4b1ec89/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/BinaryFieldPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/BinaryFieldPanel.java
b/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/BinaryFieldPanel.java
index a871d30..eae8a2d 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/BinaryFieldPanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/BinaryFieldPanel.java
@@ -80,6 +80,10 @@ public class BinaryFieldPanel extends FieldPanel<String> {
 
     private final AbstractBinaryPreviewer previewer;
 
+    private final Label previewLabel;
+
+    private final IndicatingAjaxLink<Void> resetLink;
+
     public BinaryFieldPanel(final String id, final String name, final IModel<String>
model, final String mimeType) {
         super(id, name, model);
         this.mimeType = mimeType;
@@ -125,7 +129,8 @@ public class BinaryFieldPanel extends FieldPanel<String> {
         field = new TextField<>("textField", model);
         add(field.setLabel(new Model<>(name)).setOutputMarkupId(true));
 
-        uploadForm.add(new Label("preview", StringUtils.isBlank(mimeType) ? StringUtils.EMPTY
: "(" + mimeType + ")"));
+        previewLabel = new Label("preview", StringUtils.isBlank(mimeType) ? StringUtils.EMPTY
: "(" + mimeType + ")");
+        uploadForm.add(previewLabel);
 
         fileDownload = new AjaxDownload(name, true) {
 
@@ -187,15 +192,16 @@ public class BinaryFieldPanel extends FieldPanel<String> {
                         uploadForm.addOrReplace(fileUpload);
                     }
 
+                    setVisiblePhotoButtons(StringUtils.isNotBlank(uploaded));
                     downloadLink.setEnabled(StringUtils.isNotBlank(uploaded));
 
-                    target.add(container);
+                    target.add(uploadForm);
                 }
             }
         });
         uploadForm.add(fileUpload);
 
-        IndicatingAjaxLink<Void> resetLink = new IndicatingAjaxLink<Void>("resetLink")
{
+        resetLink = new IndicatingAjaxLink<Void>("resetLink") {
 
             private static final long serialVersionUID = -7978723352517770644L;
 
@@ -205,7 +211,7 @@ public class BinaryFieldPanel extends FieldPanel<String> {
                 target.add(field);
                 downloadLink.setEnabled(false);
                 container.addOrReplace(emptyFragment);
-                uploadForm.addOrReplace(container);
+                setVisiblePhotoButtons(false);
                 target.add(uploadForm);
             }
 
@@ -230,6 +236,12 @@ public class BinaryFieldPanel extends FieldPanel<String> {
         uploadForm.addOrReplace(container);
     }
 
+    private void setVisiblePhotoButtons(final boolean visible) {
+        previewLabel.setVisible(visible);
+        resetLink.setVisible(visible);
+        downloadLink.setVisible(visible);
+    }
+
     @Override
     public BinaryFieldPanel clone() {
         return (BinaryFieldPanel) super.clone();
@@ -238,13 +250,14 @@ public class BinaryFieldPanel extends FieldPanel<String> {
     @Override
     public FieldPanel<String> setNewModel(final IModel<String> model) {
         field.setModel(model);
+        String modelObj = model.getObject();
 
-        if (StringUtils.isNotBlank(model.getObject())) {
+        if (StringUtils.isNotBlank(modelObj)) {
             final Component panelPreview;
             if (previewer == null) {
                 panelPreview = PREVIEW_UTILS.getDefaultPreviewer(mimeType);
             } else {
-                panelPreview = previewer.preview(model.getObject());
+                panelPreview = previewer.preview(modelObj);
             }
 
             if (panelPreview != null) {
@@ -252,8 +265,8 @@ public class BinaryFieldPanel extends FieldPanel<String> {
             }
         }
 
-        downloadLink.setEnabled(StringUtils.isNotBlank(model.getObject()));
-        uploadForm.addOrReplace(downloadLink);
+        downloadLink.setEnabled(StringUtils.isNotBlank(modelObj));
+        setVisiblePhotoButtons(StringUtils.isNotBlank(modelObj));
         return this;
     }
 }


Mime
View raw message