Работа над BookmarkSettings

This commit is contained in:
Book Pauk
2020-11-03 23:04:06 +07:00
parent 607f2ff407
commit f69cc6f1b1
2 changed files with 31 additions and 5 deletions

View File

@@ -103,11 +103,14 @@ class BookmarkSettings extends BookmarkSettingsProps {
get nodes() { get nodes() {
const result = []; const result = [];
this.expanded = []; const expanded = [];
this.links = {};
let i = 0; let i = 0;
this.libs.groups.forEach(group => { this.libs.groups.forEach(group => {
const rkey = `${i}`; const rkey = `${i}`;
const g = {label: group.r, key: rkey, children: []}; const g = {label: group.r, key: rkey, children: []};
this.links[rkey] = group.r;
let j = 0; let j = 0;
group.list.forEach(link => { group.list.forEach(link => {
const key = `${i}-${j}`; const key = `${i}-${j}`;
@@ -115,8 +118,10 @@ class BookmarkSettings extends BookmarkSettingsProps {
label: (link.c ? link.c + ' ': '') + lu.removeOrigin(link.l), label: (link.c ? link.c + ' ': '') + lu.removeOrigin(link.l),
key key
}); });
if (link.l == this.libs.startLink && this.expanded.indexOf(rkey) < 0) {
this.expanded.push(rkey); this.links[key] = link.l;
if (link.l == this.libs.startLink && expanded.indexOf(rkey) < 0) {
expanded.push(rkey);
} }
j++; j++;
@@ -126,6 +131,10 @@ class BookmarkSettings extends BookmarkSettingsProps {
i++; i++;
}); });
this.$nextTick(() => {
this.expanded = expanded;
});
return result; return result;
} }
@@ -135,6 +144,15 @@ class BookmarkSettings extends BookmarkSettingsProps {
} }
openSelected() { openSelected() {
if (!this.selected)
return;
if (this.selected.indexOf('-') < 0) {//rootLink
this.$emit('do-action', {action: 'setRootLink', data: this.links[this.selected]});
} else {//selectedLink
this.$emit('do-action', {action: 'setSelectedLink', data: this.links[this.selected]});
}
//this.close();
} }
openOptions() { openOptions() {

View File

@@ -47,7 +47,7 @@
<q-btn class="q-mr-xs" round dense color="blue" icon="la la-home" @click="goToLink(libs.startLink)" size="12px"> <q-btn class="q-mr-xs" round dense color="blue" icon="la la-home" @click="goToLink(libs.startLink)" size="12px">
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Вернуться на стартовую страницу</q-tooltip> <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Вернуться на стартовую страницу</q-tooltip>
</q-btn> </q-btn>
<q-btn round dense color="blue" icon="la la-angle-double-down" @click="openBookUrlInFrame" size="12px"> <q-btn round dense color="blue" icon="la la-angle-double-down" @click="openBookUrlInFrame" size="12px" :disabled="!bookUrl">
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Загрузить URL во фрейм</q-tooltip> <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Загрузить URL во фрейм</q-tooltip>
</q-btn> </q-btn>
</template> </template>
@@ -97,7 +97,7 @@
</template> </template>
</Dialog> </Dialog>
</div> </div>
<BookmarkSettings v-if="bookmarkSettingsActive" ref="bookmarkSettings" :libs="libs" @close="closeBookmarkSettings"></BookmarkSettings> <BookmarkSettings v-if="bookmarkSettingsActive" ref="bookmarkSettings" :libs="libs" @do-action="doAction" @close="closeBookmarkSettings"></BookmarkSettings>
</Window> </Window>
</template> </template>
@@ -292,6 +292,14 @@ class ExternalLibs extends Vue {
this.updateSelectedLink(); this.updateSelectedLink();
} }
doAction(event) {
switch (event.action) {
case 'setLibs': this.commitLibs(event.data); break;
case 'setRootLink': this.rootLink = event.data; this.rootLinkInput(); break;
case 'setSelectedLink': this.selectedLink = event.data; this.selectedLinkInput(); break;
}
}
get mode() { get mode() {
return this.$store.state.config.mode; return this.$store.state.config.mode;
} }