first commit
This commit is contained in:
28
resources/frontend/core/helpers/common.js
Normal file
28
resources/frontend/core/helpers/common.js
Normal file
@@ -0,0 +1,28 @@
|
||||
export function getParentElement(child, search) {
|
||||
if (child.parentElement.classList.contains(search)) {
|
||||
return child.parentElement;
|
||||
}
|
||||
|
||||
return getParentElement(child.parentElement, search);
|
||||
}
|
||||
|
||||
export function loadSections(context, router, requireSection) {
|
||||
const sections = requireSection
|
||||
.keys()
|
||||
.map(fn => requireSection(fn).default)
|
||||
.map(section => {
|
||||
if (typeof section === 'function') {
|
||||
return section(context, router);
|
||||
}
|
||||
|
||||
return section;
|
||||
});
|
||||
|
||||
sections.forEach(section => {
|
||||
if (Object.prototype.hasOwnProperty.call(section, 'scope') && section.scope === 'company') {
|
||||
context.addCompanySection(section);
|
||||
} else {
|
||||
context.addSettingsSection(section);
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user