composer require ldc/web-status-checker-laravel remove Old static status checker Fix ImportMedia WIP commands OK many fixes Fix and try to optimize folder component Fix front icons + actions based on icons Favico front fix alert Fix Media upload on depot fix folder component buttons Full front fix with perf due tu vuejs Download medias Navigate within medias superfix Move media + loader isLocked boolean and remove media fix Folder scroll fix arcadia link color red Fix panier show external Tons of fixes back as front REwrited all
45 lines
1.9 KiB
JavaScript
45 lines
1.9 KiB
JavaScript
export default {
|
|
methods: {
|
|
route(routeName, parameters = []) {
|
|
let route = Object.keys(window._routes).indexOf(routeName) !== -1 ?
|
|
window._routes[routeName] : null;
|
|
if (!route) {
|
|
return route;
|
|
}
|
|
// copy parameters
|
|
let iParameters = Object.assign({}, parameters);
|
|
let origin = window.location.origin;
|
|
let pathname = route.replace(origin, '');
|
|
let hash = window.location.hash;
|
|
|
|
// replace in path name
|
|
for (let paramName in iParameters) {
|
|
let paramValue = parameters[paramName];
|
|
if (pathname.indexOf(paramName) !== -1) {
|
|
pathname = pathname.replace(paramName, paramValue);
|
|
}
|
|
delete parameters[paramName];
|
|
}
|
|
|
|
// search, dont copy if target url is different than actual
|
|
let search = pathname == window.location.pathname ? window.location.search : ''
|
|
|
|
for (let paramName in parameters) {
|
|
let paramValue = parameters[paramName];
|
|
if (search.indexOf(paramName + "=") >= 0) {
|
|
prefix = search.substring(0, search.indexOf(paramName + "="));
|
|
suffix = search.substring(search.indexOf(paramName + "="));
|
|
suffix = suffix.substring(suffix.indexOf("=") + 1);
|
|
suffix = (suffix.indexOf("&") >= 0) ? suffix.substring(suffix.indexOf("&")) : '';
|
|
search = prefix + paramName + "=" + paramValue + suffix;
|
|
} else if (search.indexOf("?") < 0) {
|
|
search += "?" + paramName + "=" + paramValue
|
|
} else {
|
|
search += "&" + paramName + "=" + paramValue
|
|
}
|
|
}
|
|
return origin + pathname + search + hash;
|
|
}
|
|
},
|
|
}
|
|
|