Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | 1184x 1184x 1184x 1186x 1726816x 1184x 216818x 1186x 1186x 1186x 216818x 1184x 214026x 2792x 3x | 'use strict';
define(
['jquery', 'pim/security-context'],
function ($, SecurityContext) {
var promise = null;
/**
* Filters form extensions by ACL
*
* @param {Object} extensions
*/
const filterByGranted = (extensions) => {
return extensions.filter(extension => {
return null === extension.aclResourceId || SecurityContext.isGranted(extension.aclResourceId)
})
}
const loadConfig = function () {
if (null === promise) {
promise = $.when(
$.get('/js/extensions.json'),
SecurityContext.initialize()
)
.then(([config]) => {
config.extensions = filterByGranted(config.extensions)
return config;
})
.fail(() => {
throw Error(`It seems that your web server is not well
configured as we were not able to load the frontend
configuration. The most likely reason is that the
mod_rewrite module is not installed/enabled.`)
});
}
return promise;
};
return {
/**
* Returns configuration for extensions.
*
* @return {Promise}
*/
getExtensionMap() {
return loadConfig().then(({extensions}) => extensions)
},
/**
* Returns configuration for attribute fields.
*
* @return {Promise}
*/
getAttributeFields() {
return loadConfig().then(({attribute_fields}) => attribute_fields)
},
/**
* Clear cache of form registry
*/
clear() {
promise = null;
}
};
}
);
|