UserHotKeys.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <div class="table col column no-wrap">
  3. <!-- header -->
  4. <div class="table-row row">
  5. <div class="desc q-pa-sm bg-green-4">Действие</div>
  6. <div class="hotKeys col q-pa-sm bg-green-4 row no-wrap">
  7. <span>Сочетания клавиш</span>
  8. <q-input ref="input" outlined dense rounded bg-color="grey-4"
  9. placeholder="Найти"
  10. v-model="search"
  11. @click.stop
  12. />
  13. <div class="q-ml-sm column justify-center">
  14. <q-btn class="bg-grey-4 text-grey-6" style="height: 35px; width: 35px" rounded flat icon="la la-broom" @click="defaultHotKeyAll">
  15. <q-tooltip :delay="1000" anchor="top middle" self="bottom middle" content-style="font-size: 80%">
  16. Установить все сочетания по умолчанию
  17. </q-tooltip>
  18. </q-btn>
  19. </div>
  20. </div>
  21. </div>
  22. <!-- body -->
  23. <div class="table-row row" v-for="(action, index) in tableData" :key="index">
  24. <div class="desc q-pa-sm">{{ rstore.readerActions[action] }}</div>
  25. <div class="hotKeys col q-pa-sm">
  26. <q-chip removable color="grey-7" text-color="white" v-for="(code, index) in value[action]" :key="index" @remove="removeCode(action, code)">
  27. {{ code }}
  28. </q-chip>
  29. </div>
  30. <div class="column q-pa-xs">
  31. <q-icon
  32. name="la la-plus-circle"
  33. class="button bg-green-8 text-white"
  34. @click="addHotKey(action)"
  35. v-ripple
  36. >
  37. <q-tooltip :delay="1000" anchor="top middle" self="bottom middle" content-style="font-size: 80%">
  38. Добавить сочетание клавиш
  39. </q-tooltip>
  40. </q-icon>
  41. <q-icon
  42. name="la la-broom"
  43. class="button text-grey-5"
  44. @click="defaultHotKey(action)"
  45. v-ripple
  46. >
  47. <q-tooltip :delay="1000" anchor="top middle" self="bottom middle" content-style="font-size: 80%">
  48. По умолчанию
  49. </q-tooltip>
  50. </q-icon>
  51. </div>
  52. </div>
  53. </div>
  54. </template>
  55. <script>
  56. //-----------------------------------------------------------------------------
  57. import Vue from 'vue';
  58. import Component from 'vue-class-component';
  59. import rstore from '../../../../store/modules/reader';
  60. //import * as utils from '../../share/utils';
  61. const UserHotKeysProps = Vue.extend({
  62. props: {
  63. value: Object,
  64. //prop: { type: Number, default: 0 },
  65. }
  66. });
  67. export default @Component({
  68. watch: {
  69. search: function() {
  70. this.updateTableData();
  71. },
  72. value: function() {
  73. this.updateTableData();
  74. }
  75. },
  76. })
  77. class UserHotKeys extends UserHotKeysProps {
  78. search = '';
  79. rstore = {};
  80. tableData = [];
  81. created() {
  82. this.rstore = rstore;
  83. }
  84. mounted() {
  85. this.updateTableData();
  86. }
  87. updateTableData() {
  88. let result = rstore.hotKeys.map(hk => hk.name);
  89. const search = this.search.toLowerCase();
  90. const codesIncludeSearch = (action) => {
  91. for (const code of this.value[action]) {
  92. if (code.toLowerCase().includes(search))
  93. return true;
  94. }
  95. return false;
  96. };
  97. result = result.filter(item => {
  98. return !search ||
  99. rstore.readerActions[item].toLowerCase().includes(search) ||
  100. codesIncludeSearch(item)
  101. });
  102. this.tableData = result;
  103. }
  104. removeCode(action, code) {
  105. }
  106. addHotKey(action) {
  107. }
  108. defaultHotKey(action) {
  109. }
  110. defaultHotKeyAll() {
  111. }
  112. }
  113. //-----------------------------------------------------------------------------
  114. </script>
  115. <style scoped>
  116. .table {
  117. border-left: 1px solid grey;
  118. border-top: 1px solid grey;
  119. }
  120. .table-row {
  121. border-right: 1px solid grey;
  122. border-bottom: 1px solid grey;
  123. }
  124. .desc {
  125. width: 100px;
  126. }
  127. .hotKeys {
  128. border-left: 1px solid grey;
  129. }
  130. .button {
  131. font-size: 25px;
  132. border-radius: 25px;
  133. cursor: pointer;
  134. }
  135. </style>