forked from DGNum/metis
Raccourcit les liens de partage
This commit is contained in:
parent
30259d31bd
commit
6aa3c6820c
2 changed files with 26 additions and 1 deletions
|
@ -9,6 +9,8 @@
|
|||
Toast
|
||||
} from 'sveltestrap';
|
||||
|
||||
import { ancestors } from './calendar';
|
||||
|
||||
export let calendar = null;
|
||||
export let selectedCalendars = [];
|
||||
|
||||
|
@ -33,6 +35,16 @@
|
|||
.finally((isToastOpen = true));
|
||||
};
|
||||
|
||||
const filter = calendars => {
|
||||
let reduced = [];
|
||||
calendars.forEach(c => {
|
||||
if (!ancestors[c].some(p => calendars.includes(p))) {
|
||||
reduced.push(c);
|
||||
}
|
||||
});
|
||||
return reduced;
|
||||
};
|
||||
|
||||
const updateShareLink = () => {
|
||||
const loc = document.location;
|
||||
const search = new URLSearchParams();
|
||||
|
@ -41,7 +53,7 @@
|
|||
if (calendar !== null) {
|
||||
search.append('v', api.view.type);
|
||||
|
||||
selectedCalendars.forEach(c => search.append('c', c));
|
||||
filter(selectedCalendars).forEach(c => search.append('c', c));
|
||||
|
||||
search.append('d', api.getDate().toISOString());
|
||||
}
|
||||
|
|
|
@ -176,6 +176,19 @@ export const calendarTree = {
|
|||
Divers: {}
|
||||
}
|
||||
|
||||
const dfs = (p, t, l) => {
|
||||
for (const [c, s] of Object.entries(t)) {
|
||||
l[c] = p === null ? [] : [p, ...l[p]]
|
||||
dfs(c, s, l)
|
||||
}
|
||||
}
|
||||
|
||||
export const ancestors = (() => {
|
||||
let l = []
|
||||
dfs(null, calendarTree, l)
|
||||
return l
|
||||
})()
|
||||
|
||||
export function getSubCalendars(name, tree = calendarTree) {
|
||||
let ret
|
||||
for (const [cal, subTree] of Object.entries(tree)) {
|
||||
|
|
Loading…
Reference in a new issue