Skip to content

Commit

Permalink
Show failed ballots as failed, fix #2704
Browse files Browse the repository at this point in the history
  • Loading branch information
sqrrm committed Jun 15, 2019
1 parent abc0909 commit 98b4fe0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,32 @@

import javafx.scene.control.Label;
import javafx.scene.control.TableRow;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;

import lombok.Getter;

import org.jetbrains.annotations.NotNull;

public class ProposalListItem {

@Getter
private EvaluatedProposal evaluatedProposal;
@Getter
private final Proposal proposal;
private final Vote vote;
private final boolean isMyBallotIncluded;
private final BsqFormatter bsqFormatter;

private TableRow tableRow;


ProposalListItem(EvaluatedProposal evaluatedProposal, Ballot ballot, BsqFormatter bsqFormatter) {
ProposalListItem(EvaluatedProposal evaluatedProposal, Ballot ballot, boolean isMyBallotIncluded,
BsqFormatter bsqFormatter) {
this.evaluatedProposal = evaluatedProposal;
proposal = evaluatedProposal.getProposal();
vote = ballot.getVote();

this.isMyBallotIncluded = isMyBallotIncluded;
this.bsqFormatter = bsqFormatter;
}

Expand All @@ -68,16 +74,26 @@ public Label getMyVoteIcon() {
Label myVoteIcon;
if (vote != null) {
if ((vote).isAccepted()) {
myVoteIcon = FormBuilder.getIcon(AwesomeIcon.THUMBS_UP);
myVoteIcon.getStyleClass().add("dao-accepted-icon");
myVoteIcon = getIcon(AwesomeIcon.THUMBS_UP, "dao-accepted-icon");
} else {
myVoteIcon = FormBuilder.getIcon(AwesomeIcon.THUMBS_DOWN);
myVoteIcon.getStyleClass().add("dao-rejected-icon");
myVoteIcon = getIcon(AwesomeIcon.THUMBS_DOWN, "dao-rejected-icon");
}
} else {
myVoteIcon = FormBuilder.getIcon(AwesomeIcon.MINUS);
myVoteIcon.getStyleClass().add("dao-ignored-icon");
myVoteIcon = getIcon(AwesomeIcon.MINUS, "dao-ignored-icon");
}
if (!isMyBallotIncluded) {
Label notIncluded = FormBuilder.getIcon(AwesomeIcon.BAN_CIRCLE);
return new Label("", new HBox(10, new StackPane(myVoteIcon, notIncluded),
getIcon(AwesomeIcon.MINUS, "dao-ignored-icon")));
}
return myVoteIcon;
}

@NotNull
private Label getIcon(AwesomeIcon awesomeIcon, String s) {
Label myVoteIcon;
myVoteIcon = FormBuilder.getIcon(awesomeIcon);
myVoteIcon.getStyleClass().add(s);
return myVoteIcon;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,9 @@ private void createProposalsTable() {
})
.map(evaluatedProposal -> new ProposalListItem(evaluatedProposal,
ballotByProposalTxIdMap.get(evaluatedProposal.getProposalTxId()),
voteListItemList.stream()
.anyMatch(voteListItem ->
bsqWalletService.getTransaction(voteListItem.getBlindVoteTxId()) != null),
bsqFormatter))
.collect(Collectors.toList()));
GUIUtil.setFitToRowsForTableView(proposalsTableView, 25, 28, 6, 6);
Expand Down

0 comments on commit 98b4fe0

Please sign in to comment.