silverstripe-framework/admin/client/dist/js/config.js
Damian Mooyman dbd17bd49a API Remove routing from silverstripe-component
BUG Fix page routing in subdirectory
BUG Fix top level admin sections not causing ajax load
2016-04-21 08:43:03 +12:00

84 lines
2.2 KiB
JavaScript

(function (global, factory) {
if (typeof define === "function" && define.amd) {
define('ss.config', ['exports'], factory);
} else if (typeof exports !== "undefined") {
factory(exports);
} else {
var mod = {
exports: {}
};
factory(mod.exports);
global.ssConfig = mod.exports;
}
})(this, function (exports) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
var _createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
var Config = function () {
function Config() {
_classCallCheck(this, Config);
}
_createClass(Config, null, [{
key: 'getSection',
value: function getSection(key) {
return window.ss.config.sections[key];
}
}, {
key: 'getTopLevelRoutes',
value: function getTopLevelRoutes() {
var topLevelRoutes = [];
Object.keys(window.ss.config.sections).forEach(function (key) {
var route = window.ss.config.sections[key].route;
var topLevelMatch = route.match(/^admin\/[^\/]+(\/?)$/);
if (!topLevelMatch) {
return;
}
if (!topLevelMatch[1]) {
route += '/';
}
var isUnique = topLevelRoutes.indexOf(route) === -1;
if (isUnique) {
topLevelRoutes.push(route);
}
});
return topLevelRoutes;
}
}]);
return Config;
}();
exports.default = Config;
});