Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide proposal delete button #4739

Merged
merged 2 commits into from
Nov 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@
//TODO merge with vote result ProposalListItem
public class ProposalsListItem {

enum IconButtonTypes {
enum IconButtonType {
REMOVE_PROPOSAL(Res.get("dao.proposal.table.icon.tooltip.removeProposal")),
ACCEPT(Res.get("dao.proposal.display.myVote.accepted")),
REJECT(Res.get("dao.proposal.display.myVote.rejected")),
IGNORE(Res.get("dao.proposal.display.myVote.ignored"));
@Getter
private String title;

IconButtonTypes(String title) {
IconButtonType(String title) {
this.title = title;
}
}
Expand Down Expand Up @@ -127,8 +127,9 @@ public void onPhaseChanged(DaoPhase.Phase phase) {
icon.getStyleClass().addAll("icon", "dao-remove-proposal-icon");
iconButton = new JFXButton("", icon);
boolean isMyProposal = daoFacade.isMyProposal(proposal);
if (isMyProposal)
iconButton.setUserData(IconButtonTypes.REMOVE_PROPOSAL);
if (isMyProposal) {
iconButton.setUserData(IconButtonType.REMOVE_PROPOSAL);
}
iconButton.setVisible(isMyProposal);
iconButton.setManaged(isMyProposal);
iconButton.getStyleClass().add("hidden-icon-button");
Expand All @@ -147,36 +148,36 @@ public void onPhaseChanged(DaoPhase.Phase phase) {
icon = FormBuilder.getIcon(AwesomeIcon.THUMBS_UP);
icon.getStyleClass().addAll("icon", "dao-accepted-icon");
iconButton = new JFXButton("", icon);
iconButton.setUserData(IconButtonTypes.ACCEPT);
iconButton.setUserData(IconButtonType.ACCEPT);
} else {
icon = FormBuilder.getIcon(AwesomeIcon.THUMBS_DOWN);
icon.getStyleClass().addAll("icon", "dao-rejected-icon");
iconButton = new JFXButton("", icon);
iconButton.setUserData(IconButtonTypes.REJECT);
iconButton.setUserData(IconButtonType.REJECT);
}
} else {
icon = FormBuilder.getIcon(AwesomeIcon.MINUS);
icon.getStyleClass().addAll("icon", "dao-ignored-icon");
iconButton = new JFXButton("", icon);
iconButton.setUserData(IconButtonTypes.IGNORE);
iconButton.setUserData(IconButtonType.IGNORE);
}
iconButton.setTooltip(new Tooltip(Res.get("dao.proposal.table.icon.tooltip.changeVote",
((IconButtonTypes) iconButton.getUserData()).getTitle(),
getNext(((IconButtonTypes) iconButton.getUserData()))
((IconButtonType) iconButton.getUserData()).getTitle(),
getNext(((IconButtonType) iconButton.getUserData()))
)));
iconButton.getStyleClass().add("hidden-icon-button");
iconButton.layout();
}
}

private String getNext(IconButtonTypes iconButtonTypes) {
switch (iconButtonTypes) {
private String getNext(IconButtonType iconButtonType) {
switch (iconButtonType) {
case ACCEPT:
return IconButtonTypes.REJECT.getTitle();
return IconButtonType.REJECT.getTitle();
case REJECT:
return IconButtonTypes.IGNORE.getTitle();
return IconButtonType.IGNORE.getTitle();
default:
return IconButtonTypes.ACCEPT.getTitle();
return IconButtonType.ACCEPT.getTitle();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,11 @@ private void updateViews() {

switch (daoFacade.phaseProperty().get()) {
case PROPOSAL:
lastColumn.setText(Res.get("dao.proposal.table.header.remove"));
// We have a bug in removing a proposal which is not trivial to fix (p2p network layer). Until that bug is fixed
// it is better to not show the remove button as it confused users and a removed proposal will reappear with a
// high probability at the vote phase.
//lastColumn.setText(Res.get("dao.proposal.table.header.remove"));
lastColumn.setText("");
break;
case BLIND_VOTE:
lastColumn.setText(Res.get("dao.proposal.table.header.myVote"));
Expand Down Expand Up @@ -841,25 +845,36 @@ public void updateItem(final ProposalsListItem item, boolean empty) {
item.onPhaseChanged(currentPhase);
JFXButton iconButton = item.getIconButton();
if (iconButton != null) {
ProposalsListItem.IconButtonType iconButtonType = (ProposalsListItem.IconButtonType) iconButton.getUserData();
iconButton.setOnAction(e -> {
selectedItem = item;
if (areVoteButtonsVisible) {
if (iconButton.getUserData() == ProposalsListItem.IconButtonTypes.ACCEPT)
if (iconButtonType == ProposalsListItem.IconButtonType.ACCEPT)
onReject();
else if (iconButton.getUserData() == ProposalsListItem.IconButtonTypes.REJECT)
else if (iconButtonType == ProposalsListItem.IconButtonType.REJECT)
onIgnore();
else if (iconButton.getUserData() == ProposalsListItem.IconButtonTypes.IGNORE)
else if (iconButtonType == ProposalsListItem.IconButtonType.IGNORE)
onAccept();
} else {
if (iconButton.getUserData() == ProposalsListItem.IconButtonTypes.REMOVE_PROPOSAL)
if (iconButtonType == ProposalsListItem.IconButtonType.REMOVE_PROPOSAL)
onRemoveProposal();
}
});

if (!areVoteButtonsVisible && iconButton.getUserData() != ProposalsListItem.IconButtonTypes.REMOVE_PROPOSAL) {
if (!areVoteButtonsVisible && iconButtonType != ProposalsListItem.IconButtonType.REMOVE_PROPOSAL) {
iconButton.setMouseTransparent(true);
iconButton.setStyle("-fx-cursor: default;");
}

// We have a bug in removing a proposal which is not trivial to fix (p2p network layer).
// Until that bug is fixed
// it is better to not show the remove button as it confused users and a removed proposal will reappear with a
// high probability at the vote phase. The following lines can be removed once the bug is fixed.
boolean showIcon = iconButtonType != null &&
iconButtonType != ProposalsListItem.IconButtonType.REMOVE_PROPOSAL;
iconButton.setVisible(showIcon);
iconButton.setManaged(showIcon);

setGraphic(iconButton);
} else {
setGraphic(null);
Expand Down