mirror of
https://github.com/getredash/redash.git
synced 2026-05-10 15:00:16 -04:00
32 lines
736 B
JavaScript
32 lines
736 B
JavaScript
import { isFunction, each, extend } from 'lodash';
|
|
|
|
export function routesToAngularRoutes(routes, template) {
|
|
const result = {};
|
|
template = extend({}, template); // convert to object
|
|
each(routes, ({ path, title, key }) => {
|
|
result[path] = extend({
|
|
title,
|
|
// keep `resolve` from `template` (if exists)
|
|
resolve: extend({
|
|
currentPage: () => key,
|
|
}, template.resolve),
|
|
}, template);
|
|
});
|
|
return result;
|
|
}
|
|
|
|
function doCancelEvent(event) {
|
|
event.stopPropagation();
|
|
event.preventDefault();
|
|
}
|
|
|
|
export function cancelEvent(handler) {
|
|
if (isFunction(handler)) {
|
|
return (event, ...rest) => {
|
|
doCancelEvent(event);
|
|
return handler(...rest);
|
|
};
|
|
}
|
|
return doCancelEvent;
|
|
}
|