BookmarkSettings.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <Window ref="window" width="600px" height="95%" @close="close">
  3. <template slot="header">
  4. Настроить закладки
  5. </template>
  6. <div class="column fit">
  7. <div class="row items-center top-panel bg-grey-3">
  8. <q-btn class="q-mr-md" round dense color="blue" icon="la la-check" @click.stop="openSelected" size="16px" :disabled="!selected">
  9. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Открыть выбранную закладку</q-tooltip>
  10. </q-btn>
  11. <q-input class="col q-mr-sm" ref="search" rounded outlined dense bg-color="white" placeholder="Найти" v-model="search">
  12. <template v-slot:append>
  13. <q-icon v-if="search !== ''" name="la la-times" class="cursor-pointer" @click="resetSearch"/>
  14. </template>
  15. </q-input>
  16. <q-btn round dense color="blue" icon="la la-cog" @click.stop="openOptions" size="14px">
  17. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Опции</q-tooltip>
  18. </q-btn>
  19. </div>
  20. <div class="col row">
  21. <div class="left-panel column items-center bg-grey-3">
  22. <q-btn class="q-mb-sm" round dense color="blue" icon="la la-edit" @click.stop="editBookmark" size="14px">
  23. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Редактировать закладку</q-tooltip>
  24. </q-btn>
  25. <q-btn class="q-mb-sm" round dense color="blue" icon="la la-plus" @click.stop="addBookmark" size="14px">
  26. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Добавить закладку</q-tooltip>
  27. </q-btn>
  28. <q-btn class="q-mb-sm" round dense color="blue" icon="la la-minus" @click.stop="delBookmark" size="14px">
  29. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Удалить закладку</q-tooltip>
  30. </q-btn>
  31. <q-btn class="q-mb-sm" round dense color="blue" icon="la la-arrow-up" @click.stop="moveUp" size="14px">
  32. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Переместить вверх</q-tooltip>
  33. </q-btn>
  34. <q-btn class="q-mb-sm" round dense color="blue" icon="la la-arrow-down" @click.stop="moveDown" size="14px">
  35. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Переместить вниз</q-tooltip>
  36. </q-btn>
  37. </div>
  38. <div class="col tree">
  39. <q-tree
  40. :nodes="nodes"
  41. node-key="key"
  42. tick-strategy="leaf"
  43. :selected.sync="selected"
  44. :ticked.sync="ticked"
  45. :expanded.sync="expanded"
  46. selected-color="black"
  47. :filter="search"
  48. no-nodes-label="Закладок пока нет"
  49. no-results-label="Ничего не найдено"
  50. >
  51. <template v-slot:default-header="p">
  52. <div class="q-px-xs" :class="{selected: selected == p.key}">{{ p.node.label }}</div>
  53. </template>
  54. </q-tree>
  55. </div>
  56. </div>
  57. </div>
  58. </Window>
  59. </template>
  60. <script>
  61. //-----------------------------------------------------------------------------
  62. import Vue from 'vue';
  63. import Component from 'vue-class-component';
  64. import Window from '../../share/Window.vue';
  65. import * as lu from '../linkUtils';
  66. const BookmarkSettingsProps = Vue.extend({
  67. props: {
  68. libs: Object,
  69. }
  70. });
  71. export default @Component({
  72. components: {
  73. Window,
  74. },
  75. watch: {
  76. libs: function() {
  77. },
  78. }
  79. })
  80. class BookmarkSettings extends BookmarkSettingsProps {
  81. search = '';
  82. selected = '';
  83. ticked = [];
  84. expanded = [];
  85. created() {
  86. }
  87. mounted() {
  88. }
  89. init() {
  90. this.$refs.window.init();
  91. }
  92. get nodes() {
  93. const result = [];
  94. const expanded = [];
  95. this.links = {};
  96. let i = 0;
  97. this.libs.groups.forEach(group => {
  98. const rkey = `${i}`;
  99. const g = {label: group.r, key: rkey, children: []};
  100. this.links[rkey] = group.r;
  101. let j = 0;
  102. group.list.forEach(link => {
  103. const key = `${i}-${j}`;
  104. g.children.push({
  105. label: (link.c ? link.c + ' ': '') + lu.removeOrigin(link.l),
  106. key
  107. });
  108. this.links[key] = link.l;
  109. if (link.l == this.libs.startLink && expanded.indexOf(rkey) < 0) {
  110. expanded.push(rkey);
  111. }
  112. j++;
  113. });
  114. result.push(g);
  115. i++;
  116. });
  117. this.$nextTick(() => {
  118. this.expanded = expanded;
  119. });
  120. return result;
  121. }
  122. resetSearch() {
  123. this.search = '';
  124. this.$refs.search.focus();
  125. }
  126. openSelected() {
  127. if (!this.selected)
  128. return;
  129. if (this.selected.indexOf('-') < 0) {//rootLink
  130. this.$emit('do-action', {action: 'setRootLink', data: this.links[this.selected]});
  131. } else {//selectedLink
  132. this.$emit('do-action', {action: 'setSelectedLink', data: this.links[this.selected]});
  133. }
  134. //this.close();
  135. }
  136. openOptions() {
  137. }
  138. close() {
  139. this.$emit('close');
  140. }
  141. keyHook(event) {
  142. if (event.type == 'keydown' && event.key == 'Escape') {
  143. this.close();
  144. return true;
  145. }
  146. return false;
  147. }
  148. }
  149. //-----------------------------------------------------------------------------
  150. </script>
  151. <style scoped>
  152. .top-panel {
  153. height: 50px;
  154. border-bottom: 1px solid gray;
  155. padding: 0 10px 0 12px;
  156. }
  157. .left-panel {
  158. width: 60px;
  159. border-right: 1px solid gray;
  160. padding: 10px 0 10px 0;
  161. }
  162. .tree {
  163. padding: 10px;
  164. }
  165. .selected {
  166. text-shadow: 0 0 20px yellow, 0 0 15px yellow, 0 0 10px yellow, 0 0 10px yellow, 0 0 5px yellow;
  167. }
  168. </style>