Bug fix: now the maximum number of attachments is limited to 10.

git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/share-updates@122424 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-01-21 14:05:02 +00:00
parent e4f5ed7702
commit a2ad132914
4 changed files with 23 additions and 8 deletions

View File

@ -36,7 +36,7 @@ public class AttachmentPreviewer extends Composite {
//private static final String DELETE_ATTACHMENT = "Delete this attachment?";
private static final String RETRY_TO_UPLOAD = "Retry to upload this attachment on the server.";
@UiField
HTMLPanel attachmentContainer;
@ -75,14 +75,14 @@ public class AttachmentPreviewer extends Composite {
this.imagePreview.setUrl(urlImagePreview);
this.fileNameLabel.setTitle(fileName);
this.imagePreview.setTitle(fileName);
fileName = fileName.length() > 36 ? fileName.substring(0, 33) + " ..." : fileName;
this.fileNameLabel.setText(fileName);
// style the delete button
this.deleteAttachment.setStyleName("su-deleteAttachment");
this.deleteAttachment.setTitle("Cancel");
// save parent
this.parent = parent;
@ -105,6 +105,7 @@ public class AttachmentPreviewer extends Composite {
// remove the file from the List of AttachedFiles
parent.remove(this);
shareUpdateForm.removeAttachedFile(this);
parent.resizeLastElementWidth();
}
@ -147,6 +148,7 @@ public class AttachmentPreviewer extends Composite {
// we have to remove the AttachmentPreview object (that is, this object) and
// remove the file from the List of AttachedFiles
parent.remove(thisPreviewer);
parent.resizeLastElementWidth();
shareUpdateForm.removeAttachedFile(thisPreviewer);
}
@ -154,11 +156,11 @@ public class AttachmentPreviewer extends Composite {
attachmentResult.add(retryButton);
}
public void changeAttachmentWidth(int newWidth, Unit unit){
attachmentContainer.getElement().getStyle().setWidth(newWidth, unit);
}
}

View File

@ -40,4 +40,17 @@ public class Placeholder extends FlowPanel {
add((Widget)atPrev);
}
}
/**
* When a user delete an attachment we ask the last to adapt to the new free space if it can.
*/
public void resizeLastElementWidth() {
WidgetCollection listOfChildren = this.getChildren();
// if the number is odd
if(listOfChildren.size()%2 != 0)
((AttachmentPreviewer) listOfChildren.get(listOfChildren.size() -1)).changeAttachmentWidth(579, Unit.PX);
}
}

View File

@ -856,7 +856,7 @@ public class ShareUpdateForm extends Composite {
// check limit for number of files
var numberOfAlreadyAttachedFiles = instance.@org.gcube.portlets.user.shareupdates.client.view.ShareUpdateForm::numberOfAttachments()();
numberOfAlreadyAttachedFiles += files.length;
var limitExceeded = (files.length > @org.gcube.portlets.user.shareupdates.client.view.ShareUpdateForm::MAX_NUMBER_ATTACHMENTS);
var limitExceeded = (numberOfAlreadyAttachedFiles > @org.gcube.portlets.user.shareupdates.client.view.ShareUpdateForm::MAX_NUMBER_ATTACHMENTS);
if(limitExceeded){

View File

@ -124,7 +124,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
}
public String getDevelopmentUser() {
String user = TEST_USER;
// user = "costantino.perciante";
user = "costantino.perciante";
return user;
}
/**