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

fix advanced_settings_purposes_default with custom purposes (#241) #242

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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 src/scripts/userview/userview_modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import * as AdvancedSettingsStandard from './view/oil.advanced.settings.standard
import * as AdvancedSettingsTabs from './view/oil.advanced.settings.tabs';
import { logError, logInfo } from '../core/core_log';
import { getCpcType, getTheme, getTimeOutValue, isOptoutConfirmRequired, isPersistMinimumTracking } from './userview_config';
import { gdprApplies, getAdvancedSettingsPurposesDefault, getInfoBannerOnly, isPoiActive } from '../core/core_config';
import { gdprApplies, getAdvancedSettingsPurposesDefault, getInfoBannerOnly, isPoiActive, getCustomPurposeIds } from '../core/core_config';
import { applyPrivacySettings, getPrivacySettings, getSoiConsentData } from './userview_privacy';
import { activateOptoutConfirm } from './userview_optout_confirm';
import { getPurposeIds, loadVendorListAndCustomVendorList } from '../core/core_vendor_lists';
Expand Down Expand Up @@ -96,7 +96,7 @@ export function oilShowPreferenceCenter() {
if (consentData) {
currentPrivacySettings = consentData.getPurposesAllowed();
} else {
currentPrivacySettings = getAdvancedSettingsPurposesDefault() ? getPurposeIds() : [];
currentPrivacySettings = getAdvancedSettingsPurposesDefault() ? [...getPurposeIds(), ...getCustomPurposeIds()] : [];
}
applyPrivacySettings(currentPrivacySettings);
});
Expand Down
14 changes: 6 additions & 8 deletions src/scripts/userview/userview_privacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {getSoiCookie} from '../core/core_cookies';
import {PRIVACY_FULL_TRACKING} from '../core/core_constants';
import {logInfo} from '../core/core_log';
import {forEach} from './userview_modal';
import {getPurposes} from '../core/core_vendor_lists';

export function getSoiConsentData() {
let soiCookie = getSoiCookie();
Expand Down Expand Up @@ -33,19 +32,18 @@ export function getPrivacySettings() {
export function applyPrivacySettings(allowedPurposes) {
logInfo('Apply privacy settings from cookie', allowedPurposes);

for (let i = 1; i <= getPurposes().length; i++) {
document.querySelector(`#as-js-purpose-slider-${i}`).checked = (allowedPurposes.indexOf(i) !== -1);
}

if (allowedPurposes === 1) {
forEach(document.querySelectorAll('.as-js-purpose-slider'), (domNode) => {
domNode && (domNode.checked = true);
});
}

if (allowedPurposes === 0) {
} else if (allowedPurposes === 0) {
forEach(document.querySelectorAll('.as-js-purpose-slider'), (domNode) => {
domNode && (domNode.checked = false);
});
} else if (allowedPurposes) {
allowedPurposes.map(function(allowedPurpose) {
document.querySelector(`#as-js-purpose-slider-${allowedPurpose}`).checked = (allowedPurpose !== -1);
});
}

}