Skip to content

Commit

Permalink
fix advanced_settings_purposes_default with custom purposes (as-ideas…
Browse files Browse the repository at this point in the history
  • Loading branch information
atoiv committed Mar 28, 2019
1 parent 22d365a commit c0a3da2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
5 changes: 3 additions & 2 deletions src/scripts/userview/userview_modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ import {
gdprApplies,
getAdvancedSettingsPurposesDefault,
isPoiActive,
isSubscriberSetCookieActive
isSubscriberSetCookieActive,
getCustomPurposeIds
} from '../core/core_config';
import { applyPrivacySettings, getPrivacySettings, getSoiConsentData } from './userview_privacy';
import { activateOptoutConfirm } from './userview_optout_confirm.js';
Expand Down Expand Up @@ -105,7 +106,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.js';
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_information';

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);
});
}

}

0 comments on commit c0a3da2

Please sign in to comment.