Skip to content

Commit 03c89f5

Browse files
committed
feat(dino-park): adjusting org chart loading
1 parent dc23f28 commit 03c89f5

File tree

2 files changed

+41
-17
lines changed

2 files changed

+41
-17
lines changed

src/components/ui/UserPicture.vue

+7-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
<template>
2-
<div :class="'user-picture' + (modifier ? ' ' + modifier : '')">
3-
<img
4-
v-if="src"
5-
ref="img"
6-
:class="cls"
7-
:src="src"
8-
alt=""
9-
:width="size"
10-
role="presentation"
11-
aria-hidden="true"
12-
/>
2+
<div
3+
:class="['user-picture', modifier ? ' ' + modifier : '', cls]"
4+
v-bind:style="{
5+
backgroundImage: `url(${src})`,
6+
backgroundSize: `${size}px`,
7+
}"
8+
>
139
<DinoType v-if="isStaff" :size="dinoTypeSize" />
1410
</div>
1511
</template>

src/pages/PageOrgchart.vue

+34-6
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,14 @@ export default {
196196
desktopView: false,
197197
dirty: false,
198198
rawJson: null,
199+
chartForHighlightClicked: false,
199200
};
200201
},
201202
async created() {
202203
window.addEventListener('resize', this.updateView);
203204
this.updateView();
204-
this.highlight();
205-
this.fetchData();
205+
await this.fetchData();
206+
await this.highlight();
206207
},
207208
computed: {
208209
username() {
@@ -262,7 +263,7 @@ export default {
262263
263264
orgChartRoot.addEventListener('click', (event) => {
264265
const li = event.target.closest('li');
265-
266+
this.chartForHighlightClicked = true;
266267
if (event.target.closest('button')) {
267268
this.toggle(li);
268269
this.saveOrgTree();
@@ -384,9 +385,36 @@ export default {
384385
});
385386
},
386387
expandAll() {
387-
Object.entries(this.expandables).forEach(([, li]) => {
388-
this.toggle(li, true);
389-
});
388+
const entries = Object.entries(this.expandables);
389+
const loadSet = (idx, num) => {
390+
entries.slice(idx, idx + num).forEach(([, li]) => {
391+
this.toggle(li, true);
392+
});
393+
};
394+
let step = 25,
395+
i = 0,
396+
intervalTime = 1000;
397+
let inter = setInterval(() => {
398+
const run = () => {
399+
if (i < entries.length) {
400+
loadSet(i, step);
401+
i += step;
402+
if (i + step > entries.length) {
403+
step = entries.length - i;
404+
}
405+
} else {
406+
clearInterval(inter);
407+
}
408+
};
409+
if (this.chartForHighlightClicked) {
410+
setTimeout(() => {
411+
run();
412+
this.chartForHighlightClicked = false;
413+
});
414+
} else {
415+
run();
416+
}
417+
}, intervalTime);
390418
this.saveOrgTree();
391419
},
392420
collapseAll() {

0 commit comments

Comments
 (0)