UserHotKeys.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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>
  14. </div>
  15. <!-- body -->
  16. <div class="table-row row" v-for="(action, index) in tableData" :key="index">
  17. <div class="desc q-pa-sm">{{ rstore.readerActions[action] }}</div>
  18. <div class="hotKeys col q-pa-sm">
  19. <q-chip removable color="grey-8" text-color="white" v-for="(code, index) in value[action]" :key="index" @remove="removeCode(action, code)">
  20. {{ code }}
  21. </q-chip>
  22. </div>
  23. </div>
  24. </div>
  25. </template>
  26. <script>
  27. //-----------------------------------------------------------------------------
  28. import Vue from 'vue';
  29. import Component from 'vue-class-component';
  30. import rstore from '../../../../store/modules/reader';
  31. //import * as utils from '../../share/utils';
  32. const UserHotKeysProps = Vue.extend({
  33. props: {
  34. value: Object,
  35. //prop: { type: Number, default: 0 },
  36. }
  37. });
  38. export default @Component({
  39. watch: {
  40. search: function() {
  41. this.updateTableData();
  42. },
  43. value: function() {
  44. this.updateTableData();
  45. }
  46. },
  47. })
  48. class UserHotKeys extends UserHotKeysProps {
  49. search = '';
  50. rstore = {};
  51. tableData = [];
  52. created() {
  53. this.rstore = rstore;
  54. }
  55. mounted() {
  56. this.updateTableData();
  57. }
  58. updateTableData() {
  59. let result = rstore.hotKeys.map(hk => hk.name);
  60. const search = this.search.toLowerCase();
  61. const codesIncludeSearch = (action) => {
  62. for (const code of this.value[action]) {
  63. if (code.toLowerCase().includes(search))
  64. return true;
  65. }
  66. return false;
  67. };
  68. result = result.filter(item => {
  69. return !search ||
  70. rstore.readerActions[item].toLowerCase().includes(search) ||
  71. codesIncludeSearch(item)
  72. });
  73. this.tableData = result;
  74. }
  75. removeCode(action, code) {
  76. }
  77. }
  78. //-----------------------------------------------------------------------------
  79. </script>
  80. <style scoped>
  81. .table {
  82. border-left: 1px solid grey;
  83. border-top: 1px solid grey;
  84. }
  85. .table-row {
  86. border-right: 1px solid grey;
  87. border-bottom: 1px solid grey;
  88. }
  89. .desc {
  90. width: 100px;
  91. }
  92. .hotKeys {
  93. border-left: 1px solid grey;
  94. }
  95. </style>