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

cc license update #807

Merged
merged 4 commits into from
Dec 14, 2023
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
4 changes: 2 additions & 2 deletions __tests__/gui/common_cy_functions/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ export function confirmNoChoroplethFilterSelected() {
cy.get(`${mapBottomItems} .map-options .map-options__filter-row:visible`).should('have.length', 1);
cy.get(`${mapBottomItems} .map-options .map-options__filter-row:visible .mapping-options__filter`)
.eq(0)
.find('div.MuiSelect-select em')
.find('div.MuiSelect-select')
.should('have.text', 'Select an attribute');
cy.get(`${mapBottomItems} .map-options .map-options__filter-row:visible .mapping-options__filter`).eq(1).should('have.class', 'disabled');
}
Expand All @@ -463,7 +463,7 @@ export function confirmNoChartFilterSelected() {
cy.get('.rich-data-content .profile-indicator__filter-row:visible').should('have.length', 1);
cy.get('.rich-data-content .profile-indicator__filter-row:visible .profile-indicator__filter')
.eq(0)
.find('div.MuiSelect-select em')
.find('div.MuiSelect-select')
.should('have.text', 'Select an attribute');
cy.get('.rich-data-content .profile-indicator__filter-row:visible .profile-indicator__filter').eq(1).should('have.class', 'disabled');
}
Expand Down
2 changes: 1 addition & 1 deletion __tests__/gui/sharing_2/sharing.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Then(/^I confirm that the chart is not filtered$/, function () {
// cy.get('.rich-data-content .profile-indicator__filter-row:visible:eq(0)').should('have.length', 1);
cy.get('.rich-data-content .profile-indicator__filter-row:visible:eq(0) .profile-indicator__filter')
.eq(0)
.find('div.MuiSelect-select em')
.find('div.MuiSelect-select')
.should('have.text', 'Select an attribute');
cy.get('.rich-data-content .profile-indicator__filter-row:visible:eq(0) .profile-indicator__filter').eq(1).should('have.class', 'disabled');
});
Expand Down
Binary file added cypress/downloads/map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/custom-css/general.scss
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@
}
}

.warning-modal{
position: fixed;
}

// CSS for new filters
.filter-container {
border-radius: 4px;
Expand Down
6 changes: 6 additions & 0 deletions src/js/configurations/geography_sa.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ export class Config {
return false;
}

get pointSearchEnabled(){
if(this.config["point_search_enabled"] != undefined)
return this.config["point_search_enabled"];
return true;
}

get siteWideFiltersEnabled() {
if (this.config["site_wide_filters_enabled"] != undefined)
return this.config["site_wide_filters_enabled"];
Expand Down
27 changes: 16 additions & 11 deletions src/js/elements/header/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ export class Search extends Component {
* constructor of the class
* sets the default values, calls init function(this.setSearchInput)
* */
constructor(parent, api, profileId, minChars) {
constructor(parent, api, profileId, minChars, config) {
super(parent);

minLength = minChars;
this.api = api;
this.profileId = profileId;
this.plate = null;
this.config = config;

this.prepareDomElements();
this.setSearchInput();
Expand All @@ -60,9 +61,11 @@ export class Search extends Component {

this.updateGeoSearchHeader(titleRow);
this.updateGeoSearch();
this.appendSearchSeparator();
this.appendPointsTitle(titleRow);
this.appendPointsNoData();
if (this.config.pointSearchEnabled) {
this.appendSearchSeparator();
this.appendPointsTitle(titleRow);
this.appendPointsNoData();
}
}

updateGeoSearchHeader(titleRow) {
Expand Down Expand Up @@ -282,13 +285,15 @@ export class Search extends Component {
response(data);
})

const mapCenter = self.getMapCenter();
self.api.searchPointsByDistance(self.profileId, searchTerm, mapCenter.lat, mapCenter.lng).then(data => {
self.removePointsNoData();
self.appendPointsHeaderRow();
self.appendPointsTable(searchTerm, data);
self.updatePointsHeaderSummary(data);
})
if (self.config.pointSearchEnabled) {
const mapCenter = self.getMapCenter();
self.api.searchPointsByDistance(self.profileId, searchTerm, mapCenter.lat, mapCenter.lng).then(data => {
self.removePointsNoData();
self.appendPointsHeaderRow();
self.appendPointsTable(searchTerm, data);
self.updatePointsHeaderSummary(data);
})
}
}, 0)
}
})
Expand Down
4 changes: 2 additions & 2 deletions src/js/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ class Application extends Component {
const pointData = new PointData(this, api, mapcontrol.map, profileId, config);
const pointDataTray = new PointDataTray(this, api, profileId, config.watermarkEnabled, config.ccLicenseEnabled);
const mapchip = new MapChip(this, config.choropleth, config.siteWideFiltersEnabled, config.restrictValues, config.defaultFilters);
const search = new Search(this, api, profileId, 2);
const profileLoader = new ProfileLoader(this, formattingConfig, api, profileId, config.config, config.watermarkEnabled, config.siteWideFiltersEnabled, config.restrictValues, config.defaultFilters, config.chartColorRange);
const profileLoader = new ProfileLoader(this, formattingConfig, api, profileId, config.config, config.watermarkEnabled, config.siteWideFiltersEnabled, config.restrictValues, config.defaultFilters, config.chartColorRange, config.ccLicenseEnabled);
const search = new Search(this, api, profileId, 2, config);
const locationInfoBox = new LocationInfoBox(this, formattingConfig);
const zoomToggle = new ZoomToggle(this);
const preferredChildToggle = new PreferredChildToggle(this);
Expand Down
9 changes: 5 additions & 4 deletions src/js/profile/blocks/indicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ export class Indicator extends ContentBlock {
restrictValues = {},
defaultFilters = [],
hiddenIndicators = [],
chartColorRange
chartColorRange,
ccLicenseEnabled = false
) {
super(parent, container, indicator, title, isLast, geography, hiddenIndicators);

this.chartAttribution = chartAttribution;
this._chart = null;
this.prepareDomElements();
this.addIndicatorChart(addLockButton, restrictValues, defaultFilters, chartColorRange);
this.addIndicatorChart(addLockButton, restrictValues, defaultFilters, chartColorRange, ccLicenseEnabled);
}

get previouslySelectedFilters() {
Expand Down Expand Up @@ -60,13 +61,13 @@ export class Indicator extends ContentBlock {
super.prepareDomElements();
}

addIndicatorChart(addLockButton, restrictValues, defaultFilters, chartColorRange) {
addIndicatorChart(addLockButton, restrictValues, defaultFilters, chartColorRange, ccLicenseEnabled) {
let groups = Object.keys(this.indicator.groups);
const configuration = this.indicator.chartConfiguration;

let chartData = this.orderChartData();

let c = new Chart(this, configuration, chartData, groups, this.container, this.title, this.chartAttribution, addLockButton, restrictValues, defaultFilters, chartColorRange);
let c = new Chart(this, configuration, chartData, groups, this.container, this.title, this.chartAttribution, addLockButton, restrictValues, defaultFilters, chartColorRange, ccLicenseEnabled);
this.bubbleEvents(c, [
'profile.chart.saveAsPng', 'profile.chart.valueTypeChanged',
'profile.chart.download_csv', 'profile.chart.download_excel', 'profile.chart.download_json', 'profile.chart.download_kml',
Expand Down
14 changes: 8 additions & 6 deletions src/js/profile/category.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export class Category extends Component {
restrictValues = {},
defaultFilters = [],
hiddenIndicators = [],
chartColorRange
chartColorRange,
ccLicenseEnabled = false
) {
super(parent);

Expand All @@ -49,7 +50,7 @@ export class Category extends Component {

this.prepareDomElements();
this.prepareEvents();
this.addCategory(category, detail, isFirst, addLockButton, restrictValues, defaultFilters, hiddenIndicators, chartColorRange);
this.addCategory(category, detail, isFirst, addLockButton, restrictValues, defaultFilters, hiddenIndicators, chartColorRange, ccLicenseEnabled);
}

get filteredIndicators() {
Expand Down Expand Up @@ -107,7 +108,7 @@ export class Category extends Component {
});
}

addCategory = (category, detail, isFirst, addLockButton, restrictValues, defaultFilters, hiddenIndicators, chartColorRange) => {
addCategory = (category, detail, isFirst, addLockButton, restrictValues, defaultFilters, hiddenIndicators, chartColorRange, ccLicenseEnabled) => {
const newCategorySection = categoryTemplate.cloneNode(true);
const sectionHeader = $('.category-header')[0].cloneNode(true);
const indicatorHeader = $('.sub-category-header')[0].cloneNode(true);
Expand All @@ -130,7 +131,7 @@ export class Category extends Component {
$(newCategorySection).addClass('page-break-before');
}

this.loadSubcategories(newCategorySection, detail, addLockButton, restrictValues, defaultFilters, hiddenIndicators, chartColorRange);
this.loadSubcategories(newCategorySection, detail, addLockButton, restrictValues, defaultFilters, hiddenIndicators, chartColorRange, ccLicenseEnabled);

this.uiElements.push(newCategorySection);

Expand All @@ -144,7 +145,7 @@ export class Category extends Component {
return sectionLink;
}

loadSubcategories = (wrapper, detail, addLockButton, restrictValues, defaultFilters, hiddenIndicators, chartColorRange) => {
loadSubcategories = (wrapper, detail, addLockButton, restrictValues, defaultFilters, hiddenIndicators, chartColorRange, ccLicenseEnabled) => {
let isFirst = true;

for (const subcategoryDetail of sortBy(detail.subcategories, "order")) {
Expand All @@ -162,7 +163,8 @@ export class Category extends Component {
restrictValues,
defaultFilters,
hiddenIndicators,
chartColorRange
chartColorRange,
ccLicenseEnabled
);
sc.isVisible = sc.indicators.filter(
ind => ind.isVisible
Expand Down
44 changes: 32 additions & 12 deletions src/js/profile/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {DataFilterModel} from "../models/data_filter_model";
import {SidePanels} from "../elements/side_panels";
import {configureGroupedBarchart, configureGroupedBarchartDownload} from "./charts/groupedBarChart";
import {isEmpty} from "vega-lite";
import {ConfirmationModal} from "../ui_components/confirmation_modal";

const PERCENTAGE_TYPE = "percentage";
const VALUE_TYPE = "value";
Expand Down Expand Up @@ -44,7 +45,9 @@ export class Chart extends Component {
addLockButton = true,
restrictValues = {},
defaultFilters = [],
chartColorRange) {
chartColorRange,
ccLicenseEnabled = false
) {
//we need the subindicators and groups too even though we have detail parameter. they are used for the default chart data
super(parent);

Expand Down Expand Up @@ -77,6 +80,10 @@ export class Chart extends Component {
addLockButton: addLockButton
});

this.ccLicenseEnabled = ccLicenseEnabled;

this.confirmationModal = new ConfirmationModal(this, ConfirmationModal.COOKIE_NAMES.CC_LICENSE);

this.updateConfig(chartColorRange);

this.addChart(restrictValues, defaultFilters, true, false, null);
Expand Down Expand Up @@ -454,21 +461,34 @@ export class Chart extends Component {
$(this.containerParent).find('.hover-menu__content_list--last a').each(function () {
$(this).off('click');
$(this).on('click', () => {
let exportType = $(this).data('id');
const downloadFn = {
'csv': self.exportAsCsv,
'excel': self.exportAsExcel,
'json': self.exportAsJson,
'kml': self.exportAsKml,
};
self.triggerEvent(`profile.chart.download_${exportType}`, self);

let fileName = self.getChartTitle('-');
downloadFn[exportType](fileName);
if (self.ccLicenseEnabled) {
self.confirmationModal.askForConfirmation()
.then((payload) => {
if (payload.confirmed) {
self.initDownload(self, this);
}
})
} else {
self.initDownload(self, this);
}
})
});
};

initDownload(self, chart) {
let exportType = $(chart).data('id');
const downloadFn = {
'csv': self.exportAsCsv,
'excel': self.exportAsExcel,
'json': self.exportAsJson,
'kml': self.exportAsKml,
};
self.triggerEvent(`profile.chart.download_${exportType}`, self);

let fileName = self.getChartTitle('-');
downloadFn[exportType](fileName);
}

selectedGraphValueTypeChanged = (containerParent, selectedDisplayType) => {
this.graphValueType = selectedDisplayType;
this.triggerEvent("profile.chart.valueTypeChanged", this);
Expand Down
6 changes: 4 additions & 2 deletions src/js/profile/profile_loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ let profileWrapper = null;


export default class ProfileLoader extends Component {
constructor(parent, formattingConfig, _api, _profileId, _config, watermarkEnabled, siteWideFiltersEnabled, restrictValues, defaultFilters, chartColorRange) {
constructor(parent, formattingConfig, _api, _profileId, _config, watermarkEnabled, siteWideFiltersEnabled, restrictValues, defaultFilters, chartColorRange, ccLicenseEnabled) {
super(parent);
this.api = _api;
this.profileId = _profileId;
Expand All @@ -34,6 +34,7 @@ export default class ProfileLoader extends Component {
this._categories = [];
this._hiddenIndicators = [];
this.chartColorRange = chartColorRange;
this.ccLicenseEnabled = ccLicenseEnabled;

new ResizeObserver(() => {
this.setWatermarkVisibility();
Expand Down Expand Up @@ -131,7 +132,8 @@ export default class ProfileLoader extends Component {
this.restrictValues,
this.defaultFilters,
this.hiddenIndicators,
this.chartColorRange
this.chartColorRange,
this.ccLicenseEnabled
);
if (c.subCategories.length > 0) {
let navItem = this.createNavItem(id, category);
Expand Down
14 changes: 8 additions & 6 deletions src/js/profile/subcategory.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export class Subcategory extends Component {
restrictValues = {},
defaultFilters = [],
hiddenIndicators = [],
chartColorRange
chartColorRange,
ccLicenseEnabled = false
) {
super(parent);
scHeaderClone = $(subcategoryHeaderClass)[0].cloneNode(true);
Expand All @@ -46,7 +47,7 @@ export class Subcategory extends Component {
this._hasKeyMetrics = false;

this.addSubCategoryHeaders(wrapper, subcategory, detail, isFirst);
this.addIndicators(wrapper, detail, addLockButton, restrictValues, defaultFilters, hiddenIndicators, chartColorRange);
this.addIndicators(wrapper, detail, addLockButton, restrictValues, defaultFilters, hiddenIndicators, chartColorRange,ccLicenseEnabled);
this.prepareEvents();
}

Expand Down Expand Up @@ -144,7 +145,7 @@ export class Subcategory extends Component {
this._scHeader = scHeader;
}

addIndicatorBlock(container, indicator, title, isLast, addLockButton, restrictValues, defaultFilters, hiddenIndicators, chartColorRange) {
addIndicatorBlock(container, indicator, title, isLast, addLockButton, restrictValues, defaultFilters, hiddenIndicators, chartColorRange,ccLicenseEnabled) {
let block = new Indicator(
this,
container,
Expand All @@ -157,7 +158,8 @@ export class Subcategory extends Component {
restrictValues,
defaultFilters,
hiddenIndicators,
chartColorRange
chartColorRange,
ccLicenseEnabled
);
this.bubbleEvents(block, [
'profile.chart.saveAsPng', 'profile.chart.valueTypeChanged',
Expand All @@ -174,7 +176,7 @@ export class Subcategory extends Component {
return block;
}

addIndicators = (wrapper, detail, addLockButton, restrictValues, defaultFilters, hiddenIndicators, chartColorRange) => {
addIndicators = (wrapper, detail, addLockButton, restrictValues, defaultFilters, hiddenIndicators, chartColorRange,ccLicenseEnabled) => {
let index = 0;
let lastIndex = Object.entries(detail.indicators).length - 1;
let isEmpty = JSON.stringify(detail.indicators) === JSON.stringify({});
Expand All @@ -191,7 +193,7 @@ export class Subcategory extends Component {
$(wrapper).append(indicatorContainer);
let metadata = indicator.metadata;
if (indicator.content_type === ContentBlock.BLOCK_TYPES.Indicator) {
block = this.addIndicatorBlock(indicatorContainer, indicator, title, isLast, addLockButton, restrictValues, defaultFilters, hiddenIndicators, chartColorRange);
block = this.addIndicatorBlock(indicatorContainer, indicator, title, isLast, addLockButton, restrictValues, defaultFilters, hiddenIndicators, chartColorRange,ccLicenseEnabled);
} else if (indicator.content_type === ContentBlock.BLOCK_TYPES.HTMLBlock) {
block = this.addHTMLBlock(indicatorContainer, indicator, title, isLast, hiddenIndicators);
}
Expand Down
Loading
Loading