Skip to content

Commit

Permalink
feat(constants): add committee and document view constants for improv…
Browse files Browse the repository at this point in the history
…ed readability
  • Loading branch information
pethers authored Jan 19, 2025
1 parent bac83ce commit f44c2ce
Show file tree
Hide file tree
Showing 42 changed files with 657 additions and 142 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ public Layout createContent(final String parameters, final MenuBar menuBar, fina

if (!decisionSummaries.isEmpty()) {
CardInfoRowUtil.createPageHeader(panel, panelContent,
"Ballot Charts : " + decisionSummaries.get(0).getTitle() + " - "
BallotViewConstants.CHARTS_TITLE_PREFIX + decisionSummaries.get(0).getTitle() + " - "
+ decisionSummaries.get(0).getSubTitle(),
"Ballot Trends and Visualizations",
"Provides insights into election trends by visualizing ballot data, assisting in strategic decision-making and voter engagement analysis.");
BallotViewConstants.CHARTS_SUBTITLE,
BallotViewConstants.CHARTS_DESCRIPTION);
} else {
CardInfoRowUtil.createPageHeader(panel, panelContent, "Ballot Charts : " + ballots.get(0).getEmbeddedId().getConcern(),
"Ballot Trends and Visualizations",
"Provides insights into election trends by visualizing ballot data, assisting in strategic decision-making and voter engagement analysis.");

CardInfoRowUtil.createPageHeader(panel, panelContent,
BallotViewConstants.CHARTS_TITLE_PREFIX + ballots.get(0).getEmbeddedId().getConcern(),
BallotViewConstants.CHARTS_SUBTITLE,
BallotViewConstants.CHARTS_DESCRIPTION);
}

final TabSheet tabsheet = new TabSheet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,16 @@ public Layout createContent(final String parameters, final MenuBar menuBar, fina
String mainTitle;
String subTitle;
if (useDecisionSummaries) {
mainTitle = "Ballot Overview " + decisionSummaries.get(0).getTitle() + " - "
mainTitle = BallotViewConstants.OVERVIEW_MAIN_TITLE_PREFIX + decisionSummaries.get(0).getTitle() + " - "
+ decisionSummaries.get(0).getSubTitle();
} else {
final ViewRiksdagenVoteDataBallotSummary firstBallot = ballots.get(FIRST_OBJECT);
mainTitle = "Ballot Overview " + firstBallot.getEmbeddedId().getConcern();
mainTitle = BallotViewConstants.OVERVIEW_MAIN_TITLE_PREFIX + firstBallot.getEmbeddedId().getConcern();
}
subTitle = "Ballot Details";
subTitle = BallotViewConstants.OVERVIEW_CARD_BALLOT_INFO;

CardInfoRowUtil.createPageHeader(panel, panelContent, mainTitle, subTitle,
"Explore and analyze ballot results and voting statistics.");
BallotViewConstants.OVERVIEW_PAGE_DESCRIPTION);

// Card panel
final Panel cardPanel = new Panel();
Expand All @@ -161,7 +161,7 @@ public Layout createContent(final String parameters, final MenuBar menuBar, fina
panelContent.addComponent(cardPanel);
panelContent.setExpandRatio(cardPanel, ContentRatio.GRID);

CardInfoRowUtil.createCardHeader(cardContent,"Ballot Information");
CardInfoRowUtil.createCardHeader(cardContent, BallotViewConstants.OVERVIEW_CARD_BALLOT_INFO);

// Two-column layout
final HorizontalLayout attributesLayout = new HorizontalLayout();
Expand All @@ -170,27 +170,27 @@ public Layout createContent(final String parameters, final MenuBar menuBar, fina
cardContent.addComponent(attributesLayout);

// Left column: Ballot Profile (Textual and identifying attributes)
final VerticalLayout profileDetailsLayout = CardInfoRowUtil.createSectionLayout("Ballot Profile");
final VerticalLayout profileDetailsLayout = CardInfoRowUtil.createSectionLayout(BallotViewConstants.OVERVIEW_CARD_BALLOT_PROFILE);

// Right column: Voting Statistics (Numeric and outcome attributes)
final VerticalLayout serviceStatsLayout = CardInfoRowUtil.createSectionLayout("Voting Statistics");
final VerticalLayout serviceStatsLayout = CardInfoRowUtil.createSectionLayout(BallotViewConstants.OVERVIEW_CARD_VOTING_STATS);

attributesLayout.addComponents(profileDetailsLayout, serviceStatsLayout);

// Populate fields depending on data
if (useDecisionSummaries) {
final ViewRiksdagenCommitteeBallotDecisionSummary ds = decisionSummaries.get(FIRST_OBJECT);
// Show essential profile fields
profileDetailsLayout.addComponent(CardInfoRowUtil.createInfoRow("Vote Date:", String.valueOf(ds.getVoteDate()), VaadinIcons.CALENDAR, "Date of the vote"));
profileDetailsLayout.addComponent(CardInfoRowUtil.createInfoRow("Title:", ds.getTitle(), VaadinIcons.FILE_TEXT_O, "Title of the ballot"));
profileDetailsLayout.addComponent(CardInfoRowUtil.createInfoRow("SubTitle:", ds.getSubTitle(), VaadinIcons.FILE_TEXT, "Subtitle of the ballot"));
profileDetailsLayout.addComponent(CardInfoRowUtil.createInfoRow("Decision Type:", ds.getDecisionType(), VaadinIcons.QUESTION_CIRCLE, "Type of decision"));
profileDetailsLayout.addComponent(CardInfoRowUtil.createInfoRow(BallotViewConstants.FIELD_VOTE_DATE, String.valueOf(ds.getVoteDate()), VaadinIcons.CALENDAR, "Date of the vote"));
profileDetailsLayout.addComponent(CardInfoRowUtil.createInfoRow(BallotViewConstants.FIELD_TITLE, ds.getTitle(), VaadinIcons.FILE_TEXT_O, "Title of the ballot"));
profileDetailsLayout.addComponent(CardInfoRowUtil.createInfoRow(BallotViewConstants.FIELD_SUBTITLE, ds.getSubTitle(), VaadinIcons.FILE_TEXT, "Subtitle of the ballot"));
profileDetailsLayout.addComponent(CardInfoRowUtil.createInfoRow(BallotViewConstants.FIELD_DECISION_TYPE, ds.getDecisionType(), VaadinIcons.QUESTION_CIRCLE, "Type of decision"));

// Stats fields
serviceStatsLayout.addComponent(CardInfoRowUtil.createInfoRow("Concern:", ds.getEmbeddedId().getConcern(), VaadinIcons.CLIPBOARD, "Concern or topic of the ballot"));
serviceStatsLayout.addComponent(CardInfoRowUtil.createInfoRow("Ballot Type:", ds.getBallotType(), VaadinIcons.BULLETS, "Type of ballot"));
serviceStatsLayout.addComponent(CardInfoRowUtil.createInfoRow("Winner:", ds.getWinner(), VaadinIcons.TROPHY, "Winner or outcome"));
serviceStatsLayout.addComponent(CardInfoRowUtil.createInfoRow("Approved:", String.valueOf(ds.isApproved()), VaadinIcons.CHECK, "Whether the proposal was approved"));
serviceStatsLayout.addComponent(CardInfoRowUtil.createInfoRow(BallotViewConstants.FIELD_CONCERN, ds.getEmbeddedId().getConcern(), VaadinIcons.CLIPBOARD, "Concern or topic of the ballot"));
serviceStatsLayout.addComponent(CardInfoRowUtil.createInfoRow(BallotViewConstants.FIELD_BALLOT_TYPE, ds.getBallotType(), VaadinIcons.BULLETS, "Type of ballot"));
serviceStatsLayout.addComponent(CardInfoRowUtil.createInfoRow(BallotViewConstants.FIELD_WINNER, ds.getWinner(), VaadinIcons.TROPHY, "Winner or outcome"));
serviceStatsLayout.addComponent(CardInfoRowUtil.createInfoRow(BallotViewConstants.FIELD_APPROVED, String.valueOf(ds.isApproved()), VaadinIcons.CHECK, "Whether the proposal was approved"));

// Optional: If still too crowded, remove againstProposal fields
// serviceStatsLayout.addComponent(createInfoRow("Against Proposal Parties:", ds.getAgainstProposalParties(), VaadinIcons.WARNING, "Parties against the proposal"));
Expand All @@ -199,21 +199,21 @@ public Layout createContent(final String parameters, final MenuBar menuBar, fina
// Non-decision scenario
final ViewRiksdagenVoteDataBallotSummary bs = ballots.get(FIRST_OBJECT);
// Profile fields
profileDetailsLayout.addComponent(CardInfoRowUtil.createInfoRow("Ballot ID:", bs.getEmbeddedId().getBallotId(), VaadinIcons.CLIPBOARD_USER, "Ballot identification"));
profileDetailsLayout.addComponent(CardInfoRowUtil.createInfoRow("RM:", bs.getRm(), VaadinIcons.CALENDAR, "Session (RM) identifier"));
profileDetailsLayout.addComponent(CardInfoRowUtil.createInfoRow("Vote Date:", String.valueOf(bs.getVoteDate()), VaadinIcons.CALENDAR, "Date of the vote"));
profileDetailsLayout.addComponent(CardInfoRowUtil.createInfoRow("Issue:", bs.getEmbeddedId().getIssue(), VaadinIcons.CLIPBOARD_TEXT, "The specific issue voted upon"));
profileDetailsLayout.addComponent(CardInfoRowUtil.createInfoRow("Concern:", bs.getEmbeddedId().getConcern(), VaadinIcons.CLIPBOARD, "Concern or topic of the ballot"));
profileDetailsLayout.addComponent(CardInfoRowUtil.createInfoRow("Ballot Type:", bs.getBallotType(), VaadinIcons.BULLETS, "Type of ballot"));
profileDetailsLayout.addComponent(CardInfoRowUtil.createInfoRow("Label:", bs.getLabel(), VaadinIcons.FILE_TEXT, "Short label or description"));
profileDetailsLayout.addComponent(CardInfoRowUtil.createInfoRow(BallotViewConstants.FIELD_BALLOT_ID, bs.getEmbeddedId().getBallotId(), VaadinIcons.CLIPBOARD_USER, "Ballot identification"));
profileDetailsLayout.addComponent(CardInfoRowUtil.createInfoRow(BallotViewConstants.FIELD_RM, bs.getRm(), VaadinIcons.CALENDAR, "Session (RM) identifier"));
profileDetailsLayout.addComponent(CardInfoRowUtil.createInfoRow(BallotViewConstants.FIELD_VOTE_DATE, String.valueOf(bs.getVoteDate()), VaadinIcons.CALENDAR, "Date of the vote"));
profileDetailsLayout.addComponent(CardInfoRowUtil.createInfoRow(BallotViewConstants.FIELD_ISSUE, bs.getEmbeddedId().getIssue(), VaadinIcons.CLIPBOARD_TEXT, "The specific issue voted upon"));
profileDetailsLayout.addComponent(CardInfoRowUtil.createInfoRow(BallotViewConstants.FIELD_CONCERN, bs.getEmbeddedId().getConcern(), VaadinIcons.CLIPBOARD, "Concern or topic of the ballot"));
profileDetailsLayout.addComponent(CardInfoRowUtil.createInfoRow(BallotViewConstants.FIELD_BALLOT_TYPE, bs.getBallotType(), VaadinIcons.BULLETS, "Type of ballot"));
profileDetailsLayout.addComponent(CardInfoRowUtil.createInfoRow(BallotViewConstants.FIELD_LABEL, bs.getLabel(), VaadinIcons.FILE_TEXT, "Short label or description"));

// Stats fields
serviceStatsLayout.addComponent(CardInfoRowUtil.createInfoRow("Total Votes:", String.valueOf(bs.getTotalVotes()), VaadinIcons.GROUP, "Total number of votes cast"));
serviceStatsLayout.addComponent(CardInfoRowUtil.createInfoRow("Yes Votes:", String.valueOf(bs.getYesVotes()), VaadinIcons.THUMBS_UP, "Number of 'yes' votes"));
serviceStatsLayout.addComponent(CardInfoRowUtil.createInfoRow("No Votes:", String.valueOf(bs.getNoVotes()), VaadinIcons.THUMBS_DOWN, "Number of 'no' votes"));
serviceStatsLayout.addComponent(CardInfoRowUtil.createInfoRow("Abstain Votes:", String.valueOf(bs.getAbstainVotes()), VaadinIcons.SPLIT, "Number of abstentions"));
serviceStatsLayout.addComponent(CardInfoRowUtil.createInfoRow("Absent Votes:", String.valueOf(bs.getAbsentVotes()), VaadinIcons.EXIT_O, "Number of absent voters"));
serviceStatsLayout.addComponent(CardInfoRowUtil.createInfoRow("Approved:", String.valueOf(bs.isApproved()), VaadinIcons.CHECK, "Whether the proposal was approved"));
serviceStatsLayout.addComponent(CardInfoRowUtil.createInfoRow(BallotViewConstants.FIELD_TOTAL_VOTES, String.valueOf(bs.getTotalVotes()), VaadinIcons.GROUP, "Total number of votes cast"));
serviceStatsLayout.addComponent(CardInfoRowUtil.createInfoRow(BallotViewConstants.FIELD_YES_VOTES, String.valueOf(bs.getYesVotes()), VaadinIcons.THUMBS_UP, "Number of 'yes' votes"));
serviceStatsLayout.addComponent(CardInfoRowUtil.createInfoRow(BallotViewConstants.FIELD_NO_VOTES, String.valueOf(bs.getNoVotes()), VaadinIcons.THUMBS_DOWN, "Number of 'no' votes"));
serviceStatsLayout.addComponent(CardInfoRowUtil.createInfoRow(BallotViewConstants.FIELD_ABSTAIN_VOTES, String.valueOf(bs.getAbstainVotes()), VaadinIcons.SPLIT, "Number of abstentions"));
serviceStatsLayout.addComponent(CardInfoRowUtil.createInfoRow(BallotViewConstants.FIELD_ABSENT_VOTES, String.valueOf(bs.getAbsentVotes()), VaadinIcons.EXIT_O, "Number of absent voters"));
serviceStatsLayout.addComponent(CardInfoRowUtil.createInfoRow(BallotViewConstants.FIELD_APPROVED, String.valueOf(bs.isApproved()), VaadinIcons.CHECK, "Whether the proposal was approved"));
}

// Spacer before Party Ballot Summary
Expand All @@ -224,8 +224,10 @@ public Layout createContent(final String parameters, final MenuBar menuBar, fina

// Party Ballot Summary table
getGridFactory().createBasicBeanItemNestedPropertiesGrid(panelContent,
ViewRiksdagenVoteDataBallotPartySummary.class, partyBallotList, PARTY_BALLOT_SUMMARY,
NESTED_PROPERTIES, COLUMN_ORDER, HIDE_COLUMNS, LISTENER, EMBEDDED_ID_PARTY, null);
ViewRiksdagenVoteDataBallotPartySummary.class, partyBallotList,
BallotViewConstants.GRID_PARTY_BALLOT_SUMMARY,
NESTED_PROPERTIES, COLUMN_ORDER, HIDE_COLUMNS, LISTENER,
BallotViewConstants.GRID_EMBEDDED_ID_PARTY, null);

// Overview layout after table
final VerticalLayout overviewLayout = new VerticalLayout();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.hack23.cia.web.impl.ui.application.views.user.ballot.pagemode;

/**
* Constants for the ballot view pages.
*/
public interface BallotViewConstants {
// Overview page constants
String OVERVIEW_MAIN_TITLE_PREFIX = "Ballot Overview ";
String OVERVIEW_PAGE_DESCRIPTION = "Explore and analyze ballot results and voting statistics.";
String OVERVIEW_CARD_BALLOT_INFO = "Ballot Information";
String OVERVIEW_CARD_BALLOT_PROFILE = "Ballot Profile";
String OVERVIEW_CARD_VOTING_STATS = "Voting Statistics";

// Grid constants
String GRID_PARTY_BALLOT_SUMMARY = "Party Ballot Summary";
String GRID_EMBEDDED_ID_PARTY = "embeddedId.party";

// Field labels
String FIELD_VOTE_DATE = "Vote Date:";
String FIELD_TITLE = "Title:";
String FIELD_SUBTITLE = "Subtitle:"; // Fixed: Added missing constant
String FIELD_DECISION_TYPE = "Decision Type:";
String FIELD_CONCERN = "Concern:";
String FIELD_BALLOT_TYPE = "Ballot Type:";
String FIELD_WINNER = "Winner:";
String FIELD_APPROVED = "Approved:";
String FIELD_BALLOT_ID = "Ballot ID:";
String FIELD_RM = "RM:";
String FIELD_ISSUE = "Issue:";
String FIELD_LABEL = "Label:";
String FIELD_TOTAL_VOTES = "Total Votes:";
String FIELD_YES_VOTES = "Yes Votes:";
String FIELD_NO_VOTES = "No Votes:";
String FIELD_ABSTAIN_VOTES = "Abstain Votes:";
String FIELD_ABSENT_VOTES = "Absent Votes:";

// Charts page constants
String CHARTS_TITLE_PREFIX = "Ballot Charts : ";
String CHARTS_SUBTITLE = "Ballot Trends and Visualizations";
String CHARTS_DESCRIPTION = "Provides insights into election trends by visualizing ballot data, assisting in strategic decision-making and voter engagement analysis.";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.hack23.cia.web.impl.ui.application.views.user.committee.pagemode;

public interface CommitteeActionConstants {
// Decision Flow
String DF_YEAR_SELECTOR = "Select year";

// Decision Data
String DD_TITLE_HEADER = "Daily Committee Decisions ";
String DD_TITLE = "Summary of Decision Types";
String DD_DESCRIPTION = "Displays a summary of daily committee decision-making activity.";

// Decision Summary
String DS_TITLE_HEADER = "Committee Decision Summary";
String DS_TITLE = "Decision Summary";
String DS_DESCRIPTION = "Overview of decisions made by the committee.";

// Ballot Decision
String BD_TITLE_HEADER = "Committee Ballot Decision Summary ";
String BD_TITLE = "Ballot Decision Summary";
String BD_DESCRIPTION = "Summary of ballot decisions made by the specified committee.";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.hack23.cia.web.impl.ui.application.views.user.committee.pagemode;

public interface CommitteeBallotConstants {
String BALLOT_ID = "ballotId";
String COMMITTEE_BALLOT_DECISION_SUMMARY = "Committee Ballot Decision Summary";

String[] BALLOT_COLUMN_ORDER = { "voteDate", "embeddedId.concern", "embeddedId.id",
"committeeReport", "embeddedId.issue", "rm", "title", "subTitle", "endNumber", "org", "createdDate",
"publicDate", "ballotId", "decisionType", "againstProposalParties", "againstProposalNumber", "winner",
"ballotType", "label", "avgBornYear", "totalVotes", "yesVotes", "noVotes", "abstainVotes", "absentVotes",
"approved", "noWinner", "percentageYes", "percentageNo", "percentageAbsent", "percentageAbstain",
"percentageMale" };

String[] BALLOT_HIDE_COLUMNS = { "embeddedId", "embeddedId.id", "endNumber", "org",
"createdDate", "publicDate", "ballotId", "decisionType", "label", "againstProposalNumber", "avgBornYear",
"percentageMale", "approved", "noWinner", "ballotType", "percentageYes", "percentageNo", "percentageAbsent",
"percentageAbstain" };

String[] BALLOT_NESTED_PROPERTIES = { "embeddedId.concern", "embeddedId.issue",
"embeddedId.id" };
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ public Layout createContent(final String parameters, final MenuBar menuBar, fina
final ViewRiksdagenCommittee viewRiksdagenCommittee = getItem(parameters);
getCommitteeMenuItemFactory().createCommitteeeMenuBar(menuBar, pageId);

CardInfoRowUtil.createPageHeader(panel, panelContent, "Committee Ballot Decision Summary " + viewRiksdagenCommittee.getEmbeddedId().getDetail(), "Ballot Decision Summary", "Summary of ballot decisions made by the specified committee.");
CardInfoRowUtil.createPageHeader(panel, panelContent,
CommitteeViewConstants.BD_TITLE_HEADER + viewRiksdagenCommittee.getEmbeddedId().getDetail(),
CommitteeViewConstants.BD_TITLE,
CommitteeViewConstants.BD_DESCRIPTION);

final DataContainer<ViewRiksdagenCommitteeBallotDecisionSummary, ViewRiksdagenCommitteeBallotDecisionPartyEmbeddedId> committeeBallotDecisionPartyDataContainer = getApplicationManager()
.getDataContainer(ViewRiksdagenCommitteeBallotDecisionSummary.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,6 @@
public final class CommitteeCurrentMembersHistoryPageModContentFactoryImpl
extends AbstractCommitteePageModContentFactoryImpl {

private static final String[] COLUMN_ORDER = { "roleCode", "roleId", "personId", "firstName",
"lastName", "party", "active", "totalDaysServed", "detail", "fromDate", "toDate" };

/** The Constant CURRENT_MEMBERS. */
private static final String CURRENT_MEMBERS = "Current Members";

private static final String[] HIDE_COLUMNS = { "roleId", "personId", "detail", "active" };

private static final PageItemPropertyClickListener LISTENER = new PageItemPropertyClickListener(
UserViews.POLITICIAN_VIEW_NAME, "personId");

Expand All @@ -74,7 +66,10 @@ public Layout createContent(final String parameters, final MenuBar menuBar, fina
final ViewRiksdagenCommittee viewRiksdagenCommittee = getItem(parameters);
getCommitteeMenuItemFactory().createCommitteeeMenuBar(menuBar, pageId);

CardInfoRowUtil.createPageHeader(panel, panelContent, "Committee History " + viewRiksdagenCommittee.getEmbeddedId().getDetail(), "Current Members History", "Tracks and presents historical data about committee members' participation.");
CardInfoRowUtil.createPageHeader(panel, panelContent,
CommitteeViewConstants.CM_TITLE_HEADER + viewRiksdagenCommittee.getEmbeddedId().getDetail(),
CommitteeViewConstants.CM_TITLE,
CommitteeViewConstants.CM_DESCRIPTION);

final DataContainer<ViewRiksdagenCommitteeRoleMember, String> committeeRoleMemberDataContainer = getApplicationManager()
.getDataContainer(ViewRiksdagenCommitteeRoleMember.class);
Expand All @@ -83,7 +78,10 @@ public Layout createContent(final String parameters, final MenuBar menuBar, fina
committeeRoleMemberDataContainer.findListByProperty(
new Object[] { viewRiksdagenCommittee.getEmbeddedId().getDetail(), Boolean.TRUE },
ViewRiksdagenCommitteeRoleMember_.detail, ViewRiksdagenCommitteeRoleMember_.active),
CURRENT_MEMBERS, COLUMN_ORDER, HIDE_COLUMNS, LISTENER, null, null);
CommitteeGridConstants.CURRENT_MEMBERS_GRID_NAME,
CommitteeGridConstants.MEMBER_HISTORY_COLUMN_ORDER,
CommitteeGridConstants.CURRENT_MEMBERS_HIDDEN_COLUMNS,
LISTENER, null, null);

getPageActionEventHelper().createPageEvent(ViewAction.VISIT_COMMITTEE_VIEW, ApplicationEventGroup.USER, NAME,
parameters, pageId);
Expand Down
Loading

0 comments on commit f44c2ce

Please sign in to comment.