UNPKG

@mikezimm/npmfunctions

Version:
49 lines 2.56 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getThisSitesPreConfigProps = void 0; function getThisSitesPreConfigProps(PreConfiguredProps, thisProps, serverRelativeUrl) { var presets = []; var forces = []; var testServerRelativeUrl = serverRelativeUrl.lastIndexOf('/') === serverRelativeUrl.length ? serverRelativeUrl : serverRelativeUrl + '/'; PreConfiguredProps.preset.map(function (preconfig) { //Added preconfig.location === '*' || so that if it has * it will apply everywhere if (preconfig.location === '*' || testServerRelativeUrl.toLowerCase().indexOf(preconfig.location) > -1) { preconfig.triggered = true; Object.keys(preconfig.props).map(function (prop) { // if ( !thisProps[prop] ) { var className = getPropColorClass(thisProps[prop], preconfig.props[prop], 'yellow'); presets.push({ source: preconfig.source, location: preconfig.location, type: 'preset', prop: prop, value: preconfig.props[prop], status: 'tbd', className: className, triggered: true }); // } }); } }); PreConfiguredProps.forced.map(function (preconfig) { //Added preconfig.location === '*' || so that if it has * it will apply everywhere if (preconfig.location === '*' || testServerRelativeUrl.toLowerCase().indexOf(preconfig.location) > -1) { preconfig.triggered = true; Object.keys(preconfig.props).map(function (prop) { // if ( thisProps[prop] !== preconfig.props[ prop ] ) { var className = getPropColorClass(thisProps[prop], preconfig.props[prop], 'red'); forces.push({ source: preconfig.source, location: preconfig.location, type: 'forced', prop: prop, value: preconfig.props[prop], status: 'tbd', className: className, triggered: true }); // } }); } }); return { presets: presets, forces: forces }; } exports.getThisSitesPreConfigProps = getThisSitesPreConfigProps; function getPropColorClass(actualProp, testProp, notEqualClass, defValue) { if (defValue === void 0) { defValue = 'na'; } var className = 'na'; if (actualProp === testProp) { className = 'green'; } else if (actualProp && (actualProp !== testProp)) { className = notEqualClass; } else { className = defValue; } return className; } //# sourceMappingURL=PreConfigFunctions.js.map