Skip to content

Commit

Permalink
Merge pull request #5338 from jay-hodgson/SWC-6746
Browse files Browse the repository at this point in the history
SWC-6746: just render paragraphs when not editing
  • Loading branch information
jay-hodgson committed Mar 21, 2024
2 parents 5d71789 + 8aaebcb commit 8fa6745
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.gwtbootstrap3.client.ui.TextArea;
import org.gwtbootstrap3.client.ui.TextBox;
import org.gwtbootstrap3.client.ui.Tooltip;
import org.gwtbootstrap3.client.ui.base.TextBoxBase;
import org.gwtbootstrap3.client.ui.constants.ValidationState;
import org.gwtbootstrap3.client.ui.html.Div;
import org.gwtbootstrap3.client.ui.html.Paragraph;
Expand Down Expand Up @@ -64,27 +63,48 @@ public interface Binder
@UiField
TextBox username;

@UiField
Paragraph usernameRenderer;

@UiField
TextBox firstName;

@UiField
Paragraph firstNameRenderer;

@UiField
TextBox lastName;

@UiField
Paragraph lastNameRenderer;

@UiField
TextBox currentPosition;

@UiField
Paragraph currentPositionRenderer;

@UiField
TextBox currentAffiliation;

@UiField
Paragraph currentAffiliationRenderer;

@UiField
TextBox industry;

@UiField
Paragraph industryRenderer;

@UiField
Div emailDiv;

@UiField
Div locationSuggestBoxContainer;

@UiField
Paragraph locationRenderer;

@UiField
FormGroup linkFormGroup;

Expand Down Expand Up @@ -151,7 +171,6 @@ public interface Binder
SuggestBox locationSuggestBox;
private Widget widget;

TextBoxBase[] textBoxes;
com.google.gwt.user.client.ui.TextBoxBase locationTextBox;
boolean isEditing = false;
SynapseJSNIUtils jsniUtils;
Expand Down Expand Up @@ -182,17 +201,6 @@ public UserProfileEditorWidgetViewImpl(
locationTextBox = locationSuggestBox.getTextBox();
locationTextBox.addStyleName("form-control");
locationSuggestBoxContainer.add(locationSuggestBox);
// note, not adding email since it's not editable here.
textBoxes =
new TextBoxBase[] {
username,
firstName,
lastName,
currentPosition,
currentAffiliation,
industry,
link,
};
editProfileButton.addClickHandler(event -> {
presenter.setIsEditingMode(true);
});
Expand All @@ -215,6 +223,7 @@ public Widget asWidget() {
@Override
public void setUsername(String username) {
this.username.setText(username);
usernameRenderer.setText(username);
}

@Override
Expand Down Expand Up @@ -255,6 +264,7 @@ private IsWidget getEmailElement(String email, String paragraphStyles) {
@Override
public void setFirstName(String firstName) {
this.firstName.setText(firstName);
firstNameRenderer.setText(firstName);
}

@Override
Expand All @@ -275,6 +285,7 @@ public String getUsername() {
@Override
public void setLastName(String lastName) {
this.lastName.setText(lastName);
lastNameRenderer.setText(lastName);
}

@Override
Expand Down Expand Up @@ -340,11 +351,13 @@ public String getCurrentPosition() {
@Override
public void setCurrentPosition(String position) {
currentPosition.setText(position);
currentPositionRenderer.setText(position);
}

@Override
public void setCurrentAffiliation(String company) {
currentAffiliation.setText(company);
currentAffiliationRenderer.setText(company);
}

@Override
Expand All @@ -355,6 +368,7 @@ public String getCurrentAffiliation() {
@Override
public void setIndustry(String industry) {
this.industry.setText(industry);
industryRenderer.setText(industry);
}

@Override
Expand All @@ -365,6 +379,7 @@ public String getIndustry() {
@Override
public void setLocation(String location) {
this.locationSuggestBox.setText(location);
locationRenderer.setText(location);
}

@Override
Expand Down Expand Up @@ -395,33 +410,46 @@ public void addKeyDownHandlerToFields(KeyDownHandler keyDownHandler) {
@Override
public void setEditMode(boolean isEditing) {
this.isEditing = isEditing;
for (TextBoxBase tb : textBoxes) {
tb.setReadOnly(!isEditing);
}

bioEditor.setVisible(isEditing);
bioRenderer.setVisible(!isEditing);
locationTextBox.setReadOnly(!isEditing);
firstName.setVisible(isEditing);
firstNameRenderer.setVisible(!isEditing);
firstName.setPlaceholder(isEditing ? "Enter first name" : "");
lastName.setVisible(isEditing);
lastNameRenderer.setVisible(!isEditing);
lastName.setPlaceholder(isEditing ? "Enter last name" : "");
currentAffiliation.setVisible(isEditing);
currentAffiliationRenderer.setVisible(!isEditing);
currentAffiliation.setPlaceholder(
isEditing ? "Enter current affiliation" : ""
);

bioEditor.setPlaceholder("Enter bio");
link.setVisible(isEditing);
linkRenderer.setVisible(!isEditing);
link.setPlaceholder(isEditing ? "Enter link to more info" : "");
locationSuggestBoxContainer.setVisible(isEditing);
locationRenderer.setVisible(!isEditing);
locationTextBox
.getElement()
.setAttribute("placeholder", isEditing ? "Enter City, Country" : "");
currentPosition.setVisible(isEditing);
currentPositionRenderer.setVisible(!isEditing);
currentPosition.setPlaceholder(isEditing ? "Enter current position" : "");
industry.setVisible(isEditing);
industryRenderer.setVisible(!isEditing);
industry.setPlaceholder(isEditing ? "Enter industry/discipline" : "");

editProfileButton.setVisible(!isEditing);
saveProfileButton.setVisible(isEditing);
cancelButton.setVisible(isEditing);
linkRenderer.setVisible(!isEditing);
link.setVisible(isEditing);
changeEmailLink.setVisible(isEditing);
changePasswordLink.setVisible(isEditing);
username.setVisible(isEditing);
usernameRenderer.setVisible(!isEditing);

if (!isEditing) {
DisplayUtils.showLoading(saveProfileButton, false, originalButtonText);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@
<b:FormGroup>
<b:FormLabel for="firstName">First Name</b:FormLabel>
<b:TextBox name="firstName" ui:field="firstName" />
<bh:Paragraph ui:field="firstNameRenderer" visible="false" />
</b:FormGroup>
</b:Column>
<b:Column size="MD_12,LG_6">
<b:FormGroup>
<b:FormLabel for="lastName">Last Name</b:FormLabel>
<b:TextBox name="lastName" ui:field="lastName" />
<bh:Paragraph ui:field="lastNameRenderer" visible="false" />
</b:FormGroup>
</b:Column>
</b:Row>
Expand All @@ -44,6 +46,10 @@
<b:FormGroup>
<b:FormLabel for="currentPosition">Current Position</b:FormLabel>
<b:TextBox name="currentPosition" ui:field="currentPosition" />
<bh:Paragraph
ui:field="currentPositionRenderer"
visible="false"
/>
</b:FormGroup>
</b:Column>
<b:Column size="MD_12,LG_6">
Expand All @@ -55,6 +61,10 @@
name="currentAffiliation"
ui:field="currentAffiliation"
/>
<bh:Paragraph
ui:field="currentAffiliationRenderer"
visible="false"
/>
</b:FormGroup>
</b:Column>
</b:Row>
Expand All @@ -76,6 +86,7 @@
<b:FormGroup ui:field="usernameFormGroup">
<b:FormLabel for="username">Username</b:FormLabel>
<b:TextBox name="username" ui:field="username" />
<bh:Paragraph ui:field="usernameRenderer" visible="false" />
<b:HelpBlock ui:field="usernameHelpBlock" />
</b:FormGroup>
</b:Column>
Expand All @@ -95,12 +106,14 @@
<b:FormGroup>
<b:FormLabel for="industry">Industry/Discipline</b:FormLabel>
<b:TextBox name="industry" ui:field="industry" />
<bh:Paragraph ui:field="industryRenderer" visible="false" />
</b:FormGroup>
</b:Column>
<b:Column size="MD_12,LG_6">
<b:FormGroup>
<b:FormLabel for="location">City, Country</b:FormLabel>
<bh:Div ui:field="locationSuggestBoxContainer" />
<bh:Paragraph ui:field="locationRenderer" visible="false" />
</b:FormGroup>
</b:Column>
</b:Row>
Expand Down Expand Up @@ -144,6 +157,7 @@
>
NotThePassword
</g:PasswordTextBox>

<b:Anchor
addStyleNames="displayInlineBlock"
ui:field="changePasswordLink"
Expand Down

0 comments on commit 8fa6745

Please sign in to comment.