Skip to content

Commit

Permalink
Gridformcleanup (#6854)
Browse files Browse the repository at this point in the history
* ui cleanup

* cleanup menus

* add gov data
  • Loading branch information
pethers authored Dec 15, 2024
1 parent 86fbba3 commit d41464c
Show file tree
Hide file tree
Showing 7 changed files with 335 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,19 @@ public final class ApplicationMenuItemFactoryImpl extends AbstractMenuItemFactor
private static final PageModeMenuCommand COMMAND_CHARTS_CURRENT_MINISTRIES_LEADER_SCOREBOARD = new PageModeMenuCommand(UserViews.MINISTRY_RANKING_VIEW_NAME,
PageMode.CHARTS, ChartIndicators.CURRENTMINISTRIESLEADERSCORECARD.toString());

/** The Constant COMMAND_CHARTS_CURRENT_PARTIES_LEADER_SCOREBOARD. */
private static final PageModeMenuCommand COMMAND_CHARTS_CURRENT_PARTIES_LEADER_SCOREBOARD = new PageModeMenuCommand(UserViews.PARTY_RANKING_VIEW_NAME, PageMode.CHARTS, ChartIndicators.CURRENTPARTYLEADERSCORECARD.toString());


/** The Constant COMMITTEE_RANKING_TEXT. */
private static final String COMMITTEE_RANKING_TEXT = "Committee Ranking";

/** The Constant DESC_LEADERS_SCOREBOARD. */
private static final String DESC_LEADERS_SCOREBOARD = "Leaders: comparing party leadership impact.";

/** The Constant PART_LEADERS_SCOREBOARD. */
private static final String PART_LEADERS_SCOREBOARD = "Party leaders scoreboard";

/** The Constant COMMITTEE_RANKING_LINK_TEXT. */
private static final String COMMITTEE_RANKING_LINK_TEXT = COMMITTEE_RANKING_TEXT;

Expand Down Expand Up @@ -254,6 +263,7 @@ public void addRankingMenu(final MenuBar menuBar) {
countryMenuItemFactory.createCountryTopicMenu(swedenMenuItem);

rankingsMenuItem.addItem(MINISTRIES_LEADER_SCOREBOARD, VaadinIcons.TROPHY,COMMAND_CHARTS_CURRENT_MINISTRIES_LEADER_SCOREBOARD);
rankingsMenuItem.addItem(PART_LEADERS_SCOREBOARD, VaadinIcons.TROPHY,COMMAND_CHARTS_CURRENT_PARTIES_LEADER_SCOREBOARD);

final MenuItem countryMenuItem = rankingsMenuItem.addItem(COUNTRY_RANKING_LINK_TEXT, VaadinIcons.FLAG, COMMAND_COUNTRY_RANKING_OVERVIEW);
countryMenuItemFactory.createCountryTopicMenu(countryMenuItem);
Expand Down Expand Up @@ -308,6 +318,9 @@ public void createOverviewPage(final VerticalLayout panelContent) {
createButtonLink(grid, MINISTRIES_LEADER_SCOREBOARD, VaadinIcons.TROPHY, COMMAND_CHARTS_CURRENT_MINISTRIES_LEADER_SCOREBOARD,
MINISTRIES_LEADER_SCOREBOARD_DESCRIPTION);

createButtonLink(grid, PART_LEADERS_SCOREBOARD, VaadinIcons.TROPHY,
COMMAND_CHARTS_CURRENT_PARTIES_LEADER_SCOREBOARD, DESC_LEADERS_SCOREBOARD);

createButtonLink(grid, COUNTRY_RANKING_LINK_TEXT, VaadinIcons.FLAG, COMMAND_COUNTRY_RANKING_OVERVIEW, COUNTRY_RANKING_DESCRIPTION);
createButtonLink(grid, MINISTRY_RANKING_LINK_TEXT, VaadinIcons.OFFICE, COMMAND_MINISTRY_RANKING_OVERVIEW, MINISTRY_RANKING_DESCRIPTION);
createButtonLink(grid, MINISTRIES_LINK_TEXT, VaadinIcons.OFFICE, COMMAND_MINISTRY_RANKING_DATAGRID, MINISTRIES_DESCRIPTION);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ public final class CommitteeRankingMenuItemFactoryImpl extends AbstractMenuItemF
/** The Constant POLITICAL_WORK_SUMMARY_TEXT. */
private static final String POLITICAL_WORK_SUMMARY_TEXT = "Political Work Summary";

/** The Constant RANKING_LIST_BY_TOPIC_TEXT. */
private static final String RANKING_LIST_BY_TOPIC_TEXT = "Ranking list by topic";

/** The Constant POLITICAL_WORK_SUMMARY_DESCRIPTION. */
private static final String POLITICAL_WORK_SUMMARY_DESCRIPTION = "Scoreboard over current member size, political days served and total assignments";

Expand Down Expand Up @@ -162,9 +159,7 @@ public void createCommitteeeRankingMenuBar(final MenuBar menuBar) {
public void createCommitteeRankingTopics(final MenuItem committeeMenuItem) {
committeeMenuItem.addItem(OVERVIEW_TEXT, VaadinIcons.GROUP, COMMAND_OVERVIEW);

final MenuItem listByTopic = committeeMenuItem.addItem(RANKING_LIST_BY_TOPIC_TEXT, VaadinIcons.GROUP, null);

final MenuItem listItem = listByTopic.addItem(POLITICAL_WORK_SUMMARY_TEXT,VaadinIcons.GROUP, COMMAND_DATAGRID);
final MenuItem listItem = committeeMenuItem.addItem(POLITICAL_WORK_SUMMARY_TEXT,VaadinIcons.GROUP, COMMAND_DATAGRID);
listItem.setDescription(CURRENT_AND_PAST_MEMBER_AND_SUMMARY_OF_POLTICIAL_DAYS);

final MenuItem chartByTopic = committeeMenuItem.addItem(CHART_BY_TOPIC_TEXT, VaadinIcons.GROUP, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,6 @@ public final class MinistryRankingMenuItemFactoryImpl extends AbstractMenuItemFa
/** The Constant POLITICAL_WORK_SUMMARY_TEXT. */
private static final String POLITICAL_WORK_SUMMARY_TEXT = "Political Work Summary";

/** The Constant RANKING_LIST_BY_TOPIC_TEXT. */
private static final String RANKING_LIST_BY_TOPIC_TEXT = "Ranking list by topic";

/** The Constant CURRENT_MINISTRIES_CURRENT_MEMBERS_DESCRIPTION. */
private static final String CURRENT_MINISTRIES_CURRENT_MEMBERS_DESCRIPTION = "Chart over current ministries by headcount";

Expand Down Expand Up @@ -207,9 +204,7 @@ public void createMinistryRankingTopics(final MenuItem ministryMenuItem) {

ministryMenuItem.addItem(OVERVIEW_TEXT, VaadinIcons.DASHBOARD, COMMAN_OVERVIEW);

final MenuItem listByTopic = ministryMenuItem.addItem(RANKING_LIST_BY_TOPIC_TEXT, VaadinIcons.LIST, null);

final MenuItem listItem = listByTopic.addItem(POLITICAL_WORK_SUMMARY_TEXT, VaadinIcons.BAR_CHART, COMMAND_DATAGRID);
final MenuItem listItem = ministryMenuItem.addItem(POLITICAL_WORK_SUMMARY_TEXT, VaadinIcons.BAR_CHART, COMMAND_DATAGRID);
listItem.setDescription(CURRENT_AND_PAST_MEMBER_AND_SUMMARY_OF_TOTAL_POLTICIAL_DAYS_MEMBERSHIP_DESCRIPTION);

final MenuItem chartByTopic = ministryMenuItem.addItem(CHART_BY_TOPIC_TEXT, VaadinIcons.PIE_CHART, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public final class PartyRankingMenuItemFactoryImpl extends AbstractMenuItemFacto
private static final String PARTY_BY_TOTAL_MEMBERS_BASED_ON_ROLES_IN_DEPARTMENTS_COMMITTEES_AND_PARLIAMENT =
"Party by total members across EU/gov/committees/parliament";
private static final String PARTY_RANKING = "Party Ranking";
private static final String RANKING_LIST_BY_TOPIC_TEXT = "Ranking list by topic";
private static final String TOTAL_MEMBERS = "Total members";

// Political analyst perspective descriptions (~50 chars)
Expand Down Expand Up @@ -104,6 +103,9 @@ public PartyRankingMenuItemFactoryImpl() {
public void createOverviewPage(final VerticalLayout panelContent) {
final ResponsiveRow grid = RowUtil.createGridLayout(panelContent);

createButtonLink(grid, PART_LEADERS_SCOREBOARD, VaadinIcons.TROPHY,
COMMAND_CHARTS_CURRENT_PARTIES_LEADER_SCOREBOARD, DESC_LEADERS_SCOREBOARD);

createButtonLink(grid, TOTAL_MEMBERS, VaadinIcons.USERS,
COMMAND_DATAGRID, DESC_ALL_PARTIES_ROLES);

Expand All @@ -116,8 +118,6 @@ public void createOverviewPage(final VerticalLayout panelContent) {
createButtonLink(grid, CURRENT_PARTIES_ACTIVE_IN_PARLIAMENT_HEAD_COUNT, VaadinIcons.INSTITUTION,
COMMAND_CHARTS_CURRENT_PARTIES, DESC_PARLIAMENT_HEADCOUNT);

createButtonLink(grid, PART_LEADERS_SCOREBOARD, VaadinIcons.TROPHY,
COMMAND_CHARTS_CURRENT_PARTIES_LEADER_SCOREBOARD, DESC_LEADERS_SCOREBOARD);

createButtonLink(grid, ALL_PARTIES_TOTAL_DAYS_SERVED_IN_PARLIAMENT, VaadinIcons.CLOCK,
COMMAND_CHARTS_ALL_PARTIES, DESC_DAYS_SERVED_PARLIAMENT);
Expand Down Expand Up @@ -153,10 +153,10 @@ public void createPartyRankingMenuBar(final MenuBar menuBar) {
public void createPartyRankingTopics(final MenuItem partynMenuItem) {
partynMenuItem.addItem(OVERVIEW_TEXT, VaadinIcons.DASHBOARD, COMMAND_OVERVIEW);

final MenuItem listByTopic = partynMenuItem.addItem(RANKING_LIST_BY_TOPIC_TEXT, VaadinIcons.LIST, null);
partynMenuItem.addItem(PART_LEADERS_SCOREBOARD, VaadinIcons.TROPHY,COMMAND_CHARTS_CURRENT_PARTIES_LEADER_SCOREBOARD);

// Total members using USERS icon for multiple people
final MenuItem listItem = listByTopic.addItem(TOTAL_MEMBERS, VaadinIcons.USERS, COMMAND_DATAGRID);
final MenuItem listItem = partynMenuItem.addItem(TOTAL_MEMBERS, VaadinIcons.USERS, COMMAND_DATAGRID);
listItem.setDescription(PARTY_BY_TOTAL_MEMBERS_BASED_ON_ROLES_IN_DEPARTMENTS_COMMITTEES_AND_PARLIAMENT);

final MenuItem chartByTopic = partynMenuItem.addItem(CHART_BY_TOPIC_TEXT, VaadinIcons.CHART, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public final class PoliticianRankingMenuItemFactoryImpl extends AbstractMenuItem
private static final String PAGE_VISIT_HISTORY_TEXT = "Page Visit History";
private static final String POLITICAL_EXPERIENCE_SUMMARY = "Political Experience Summary";
private static final String POLITICIAN_RANKING = "Politician Ranking";
private static final String RANKING_LIST_BY_TOPIC_TEXT = "Ranking list by topic";

// Description for total experience detail (tooltip)
private static final String CURRENT_AND_PAST_ASSIGNMENTS_DESCRIPTION =
Expand Down Expand Up @@ -146,11 +145,8 @@ public void createPoliticianRankingTopics(final MenuItem politicianMenuItem) {
// Overview: DASHBOARD for a general overview panel
politicianMenuItem.addItem(OVERVIEW_TEXT, VaadinIcons.DASHBOARD, COMMAND_OVERVIEW);

// Ranking list by topic: LIST icon for enumerations
final MenuItem listByTopic = politicianMenuItem.addItem(RANKING_LIST_BY_TOPIC_TEXT, VaadinIcons.LIST, null);

// Political experience summary: USER_CLOCK indicating experience over time
final MenuItem listItem = listByTopic.addItem(POLITICAL_EXPERIENCE_SUMMARY, VaadinIcons.USER_CLOCK, COMMAND_DATAGRID);
final MenuItem listItem = politicianMenuItem.addItem(POLITICAL_EXPERIENCE_SUMMARY, VaadinIcons.USER_CLOCK, COMMAND_DATAGRID);
listItem.setDescription(CURRENT_AND_PAST_ASSIGNMENTS_DESCRIPTION);

// Chart by topic: CHART icon for visual data representation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package com.hack23.cia.web.impl.ui.application.views.user.country.pagemode;

import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;

Expand All @@ -38,22 +37,22 @@
import com.hack23.cia.web.impl.ui.application.action.ViewAction;
import com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.WorldIndicatorChartDataManager;
import com.hack23.cia.web.impl.ui.application.views.common.viewnames.PageMode;
import com.vaadin.icons.VaadinIcons;
import com.vaadin.server.Responsive;
import com.vaadin.shared.ui.ContentMode;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Layout;
import com.vaadin.ui.MenuBar;
import com.vaadin.ui.Panel;
import com.vaadin.ui.VerticalLayout;


/**
* The Class WorldIndicatorsPageModContentFactoryImpl.
*/
@Component
public final class WorldIndicatorsPageModContentFactoryImpl extends AbstractCountryPageModContentFactoryImpl {

private static final List<String> AS_LIST = Arrays.asList("indicatorName",
"sourceValue",
"sourceOrganization");

/** The chart data manager. */
@Autowired
private WorldIndicatorChartDataManager chartDataManager;
Expand All @@ -70,59 +69,116 @@ public WorldIndicatorsPageModContentFactoryImpl() {
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
final VerticalLayout panelContent = createPanelContent();
getCountryMenuItemFactory().createCountryTopicMenu(menuBar);
createPageHeader(panel, panelContent,"Country Indicator","Country Indicator","Compare key performance indicators across multiple countries.");
createPageHeader(panel, panelContent, "Country Indicator", "Country Indicator",
"Compare key performance indicators across multiple countries.");
final String pageId = getPageId(parameters);

final String indicator = parameters.substring(PageMode.INDICATORS.toString().length()+"/".length());
final String indicator = parameters.substring(PageMode.INDICATORS.toString().length() + "/".length());

createDataIndicatorSummaryChartPanel(panelContent,indicator,panel);
createDataIndicatorSummaryChartPanel(panelContent, indicator, panel);

getPageActionEventHelper().createPageEvent(ViewAction.VISIT_COUNTRY_VIEW, ApplicationEventGroup.USER, NAME, parameters, pageId);
getPageActionEventHelper().createPageEvent(ViewAction.VISIT_COUNTRY_VIEW, ApplicationEventGroup.USER, NAME,
parameters, pageId);

return panelContent;

}

/**
* Creates the data indicator summary chart panel.
*
* @param verticalLayout
* the vertical layout
* @param indicator
* the indicator
* @param panel
* the panel
* @param verticalLayout the vertical layout
* @param indicator the indicator
* @param panel the panel
*/
private void createDataIndicatorSummaryChartPanel(final VerticalLayout verticalLayout,final String indicator,final Panel panel) {

final DataContainer<ViewWorldbankIndicatorDataCountrySummary, WorldbankIndicatorDataCountrySummaryEmbeddedId> indicatorDataCountrSummaryDailyDataContainer = getApplicationManager()
private void createDataIndicatorSummaryChartPanel(final VerticalLayout verticalLayout, final String indicator,
final Panel panel) {
final DataContainer<ViewWorldbankIndicatorDataCountrySummary, WorldbankIndicatorDataCountrySummaryEmbeddedId> indicatorDataSummaryContainer = getApplicationManager()
.getDataContainer(ViewWorldbankIndicatorDataCountrySummary.class);


final Optional<ViewWorldbankIndicatorDataCountrySummary> indicatorSummary = indicatorDataCountrSummaryDailyDataContainer
.getAll()
.parallelStream()
final Optional<ViewWorldbankIndicatorDataCountrySummary> indicatorSummary = indicatorDataSummaryContainer
.getAll().parallelStream()
.filter(t -> t != null && t.getEmbeddedId().getIndicatorId().equals(indicator)).findFirst();


ViewWorldbankIndicatorDataCountrySummary indicatorSummaryValue = null;
if (indicatorSummary.isPresent()) {
indicatorSummaryValue = indicatorSummary.get();

getFormFactory().addFormPanelTextFields(verticalLayout,
indicatorSummaryValue,
ViewWorldbankIndicatorDataCountrySummary.class,
AS_LIST);
// Instead of formFactory, we create a card for the indicator summary
final Label sectionHeader = new Label("Indicator Summary");
sectionHeader.addStyleName("section-header");
verticalLayout.addComponent(sectionHeader);

final VerticalLayout card = new VerticalLayout();
card.setMargin(true);
card.setSpacing(true);
card.addStyleName("indicator-summary-card");
Responsive.makeResponsive(card);

// For each field in AS_LIST, we create a row
if (indicatorSummaryValue.getIndicatorName() != null) {
card.addComponent(createInfoRow("Indicator Name:", indicatorSummaryValue.getIndicatorName(),
VaadinIcons.INFO_CIRCLE, "Name of the indicator"));
}
if (indicatorSummaryValue.getSourceValue() != null) {
card.addComponent(createInfoRow("Source Value:", indicatorSummaryValue.getSourceValue(),
VaadinIcons.GLOBE, "Source of this indicator data"));
}
if (indicatorSummaryValue.getSourceOrganization() != null) {
card.addComponent(createInfoRow("Source Organization:", indicatorSummaryValue.getSourceOrganization(),
VaadinIcons.INSTITUTION, "Organization providing this data"));
}

verticalLayout.addComponent(card);
}

final DataContainer<WorldBankData, Serializable> dataContainer = getApplicationManager()
.getDataContainer(WorldBankData.class);
.getDataContainer(WorldBankData.class);

final List<WorldBankData> dataList = dataContainer.findListByEmbeddedProperty(WorldBankData.class,
WorldBankData_.indicator, Indicator.class, Indicator_.id, indicator);

final List<WorldBankData> dataList = dataContainer.findListByEmbeddedProperty(WorldBankData.class, WorldBankData_.indicator, Indicator.class, Indicator_.id, indicator);
chartDataManager.createIndicatorChart(verticalLayout, dataList, indicatorSummaryValue);
}

chartDataManager.createIndicatorChart(verticalLayout,dataList,indicatorSummaryValue);
/**
* Creates a row displaying a caption and value, with optional icon and tooltip.
*
* @param caption the field caption
* @param value the field value
* @param icon a VaadinIcons icon for better visual cue
* @param tooltip optional tooltip to provide more info
* @return a HorizontalLayout representing the info row
*/
private HorizontalLayout createInfoRow(final String caption, final String value, VaadinIcons icon,
final String tooltip) {
final HorizontalLayout layout = new HorizontalLayout();
layout.setSpacing(true);
layout.addStyleName("metric-label");
layout.setWidthUndefined();

if (icon != null) {
final Label iconLabel = new Label(icon.getHtml(), ContentMode.HTML);
iconLabel.addStyleName("card-info-icon");
if (tooltip != null && !tooltip.isEmpty()) {
iconLabel.setDescription(tooltip);
}
layout.addComponent(iconLabel);
}

final Label captionLabel = new Label(caption);
captionLabel.addStyleName("card-info-caption");
if (tooltip != null && !tooltip.isEmpty()) {
captionLabel.setDescription(tooltip);
}
layout.addComponent(captionLabel);

if (value != null && !value.isEmpty()) {
final Label valueLabel = new Label(value);
valueLabel.addStyleName("card-info-value");
layout.addComponent(valueLabel);
}

return layout;
}

@Override
Expand Down
Loading

0 comments on commit d41464c

Please sign in to comment.