saby-customizer 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,8 +5,9 @@ import { GitBranchCardData } from 'saby-customizer/features/git-branch.js'
5
5
 
6
6
  toolbar.addButton({
7
7
  position: 'top',
8
- title: 'Скопировать ссылку на карточку',
8
+ title: 'Скопировать ссылку на карточку (Alt+L)',
9
9
  iconSVG: octicons.link.toSVG({ width: 18 }),
10
+ keysMapping: 'alt-KeyL',
10
11
  onclick: card => {
11
12
  const gitCard = new GitBranchCardData(card.data)
12
13
 
@@ -51,7 +51,6 @@ export class GitBranchCardData {
51
51
 
52
52
  /**
53
53
  * Обновление выбранной версии и обновление карточки задачи
54
- *
55
54
  * @param {string} value Версия
56
55
  */
57
56
  set version(value) {
@@ -70,7 +69,6 @@ export class GitBranchCardData {
70
69
 
71
70
  /**
72
71
  * Обновление доп. имени ветки и обновление карточки задачи
73
- *
74
72
  * @param {string} value Доп. имя ветки
75
73
  */
76
74
  set branchSubName(value) {
@@ -84,7 +82,6 @@ export class GitBranchCardData {
84
82
 
85
83
  /**
86
84
  * Обновление краткого описания и карточки задачи
87
- *
88
85
  * @param {string} value Доп. имя ветки
89
86
  */
90
87
  set description(value) {
@@ -103,7 +100,6 @@ export class GitBranchCardData {
103
100
 
104
101
  /**
105
102
  * Получение имени ветки с учетом выбора вехи и доп. имени ветки
106
- *
107
103
  * @returns {Promise<string>} Имя ветки
108
104
  */
109
105
  async getBranchName() {
@@ -142,7 +138,6 @@ export class GitBranchCardData {
142
138
  if (this.milestones.length) {
143
139
  await this.saveToHistory()
144
140
  }
145
-
146
141
  }
147
142
 
148
143
  /** Сохраняет данные в историю по карточкам для которых копировали имя ветки или описание */
@@ -187,7 +182,6 @@ export class GitBranchCardData {
187
182
 
188
183
  /**
189
184
  * Удаление карточки задачи из истории
190
- *
191
185
  * @param {number} primaryKey Ид записи в истории
192
186
  */
193
187
  async removeFromHistory(primaryKey) {
@@ -407,7 +401,6 @@ class GitBranchCard extends oom.extends(HTMLElement) {
407
401
 
408
402
  /**
409
403
  * Обновление выбранной версии и обновление карточки задачи
410
- *
411
404
  * @param {string} value Версия
412
405
  */
413
406
  set version(value) {
@@ -426,7 +419,6 @@ class GitBranchCard extends oom.extends(HTMLElement) {
426
419
 
427
420
  /**
428
421
  * Обновление доп. имени ветки и обновление карточки задачи
429
- *
430
422
  * @param {string} value Доп. имя ветки
431
423
  */
432
424
  set branchSubName(value) {
@@ -444,7 +436,6 @@ class GitBranchCard extends oom.extends(HTMLElement) {
444
436
 
445
437
  /**
446
438
  * Обновление краткого описания и карточки задачи
447
- *
448
439
  * @param {string} value Доп. имя ветки
449
440
  */
450
441
  set description(value) {
@@ -534,7 +525,6 @@ class GitBranchCard extends oom.extends(HTMLElement) {
534
525
 
535
526
  /**
536
527
  * Обработчик выбора версии из меню
537
- *
538
528
  * @param {number} index Выбранная в меню позиция
539
529
  */
540
530
  selectedVersion(index) {
@@ -787,24 +777,24 @@ class GitBranchCardList extends oom.extends(HTMLElement) {
787
777
 
788
778
  oom.define(GitBranchCard, GitBranchCardList)
789
779
 
790
- keysMapping['alt-KeyB'] = () => PopupDialog.toggle({
791
- key: 'git-branch-dialog',
792
- title: 'Ветки для Git',
793
- Element: GitBranchCardList
794
- })
795
-
796
780
  toolbar.addButton({
797
781
  position: 'right',
798
- title: 'Ветки для Git',
782
+ title: 'История веток для Git (Alt+H)',
799
783
  iconSVG: octicons['git-branch'].toSVG({ width: 24 }),
800
- onclick: keysMapping['alt-KeyB']
784
+ keysMapping: 'alt-KeyH',
785
+ onclick: () => PopupDialog.toggle({
786
+ key: 'git-branch-dialog',
787
+ title: 'Ветки для Git',
788
+ Element: GitBranchCardList
789
+ })
801
790
  })
802
791
 
803
792
  toolbar.addButton({
804
793
  position: 'top',
805
794
  filter: { names: ['Ошибка', 'Задача', 'ЗадачаДок'] },
806
- title: 'Скопировать имя ветки для Git',
795
+ title: 'Скопировать имя ветки для Git (Alt+B)',
807
796
  iconSVG: octicons['git-branch'].toSVG({ width: 18 }),
797
+ keysMapping: 'alt-KeyB',
808
798
  onclick: card => {
809
799
  const gitCard = new GitBranchCardData(card.data)
810
800
 
@@ -816,8 +806,9 @@ toolbar.addButton({
816
806
  toolbar.addButton({
817
807
  position: 'top',
818
808
  filter: { names: ['Ошибка', 'Задача', 'ЗадачаДок'] },
819
- title: 'Скопировать описание для Git коммита',
809
+ title: 'Скопировать описание для Git коммита (Alt+O)',
820
810
  iconSVG: octicons['git-commit'].toSVG({ width: 18 }),
811
+ keysMapping: 'alt-KeyO',
821
812
  onclick: card => {
822
813
  const gitCard = new GitBranchCardData(card.data)
823
814
 
@@ -829,8 +820,9 @@ toolbar.addButton({
829
820
  toolbar.addButton({
830
821
  position: 'top',
831
822
  filter: { names: ['Merge request'] },
832
- title: 'Открыть ветки для Review кода',
823
+ title: 'Открыть ветки для Review кода (Alt+R)',
833
824
  iconSVG: octicons.codescan.toSVG({ width: 18 }),
825
+ keysMapping: 'alt-KeyR',
834
826
  onclick: card => {
835
827
  const links = []
836
828
  const view = card.element.querySelector('.fed2-DocumentPrint__content-view')?.shadowRoot
@@ -1,5 +1,6 @@
1
1
  import { oom } from '@notml/core'
2
2
  import { getListOfOpenCards } from './edo.js'
3
+ import { keysMapping } from 'saby-customizer/lib.js'
3
4
 
4
5
  const { MutationObserver } = window
5
6
  /**
@@ -68,6 +69,7 @@ class ToolbarContainer extends oom.extends(HTMLElement, optionsDefaults) {
68
69
  * @property {ButtonOptionsFilter} [filter] Фильтры отображения кнопок
69
70
  * @property {string} title Всплывающая подсказка на кнопке
70
71
  * @property {string} iconSVG Верстка иконки в формате SVG
72
+ * @property {string} [keysMapping] Горячие клавиши для вызова обработчика на onclick
71
73
  * @property {Function} onclick Обработчик клика на иконку
72
74
  */
73
75
  /** @type {ButtonOptions[]} */
@@ -84,13 +86,23 @@ class ToolbarContainer extends oom.extends(HTMLElement, optionsDefaults) {
84
86
 
85
87
  /**
86
88
  * Регистрирует новую общую кнопку в панели сайта
87
- *
88
89
  * @param {ButtonOptions} options Опции кнопки
89
90
  */
90
91
  static addButton(options) {
91
92
  options = Object.assign({ position: 'right' }, options)
92
93
  this.buttons.push(options)
93
94
 
95
+ if (options.keysMapping) {
96
+ keysMapping[options.keysMapping] = () => {
97
+ const container = Array.from(this.containers).pop()
98
+ const [card] = container.options.card
99
+ ? getListOfOpenCards({ id: container.options.card.data.id })
100
+ : [null]
101
+
102
+ if (card) options.onclick(card)
103
+ }
104
+ }
105
+
94
106
  this.containers.forEach(container => container.addButton(options))
95
107
 
96
108
  if (!ToolbarContainer.globalContainer) {
@@ -104,7 +116,6 @@ class ToolbarContainer extends oom.extends(HTMLElement, optionsDefaults) {
104
116
 
105
117
  /**
106
118
  * Добавляет в вертску сайта глобальный контейнер в панели для добавления кнопок
107
- *
108
119
  * @param {{searchCount:number}} options Опции регистарции обработчиков
109
120
  */
110
121
  static addGlobalContainer({ searchCount } = { searchCount: 0 }) {
@@ -130,7 +141,6 @@ class ToolbarContainer extends oom.extends(HTMLElement, optionsDefaults) {
130
141
 
131
142
  /**
132
143
  * Регистрирует обработчик для поиска открытых задач и добавления в них панели
133
- *
134
144
  * @param {{searchCount:number}} options Опции регистарции обработчиков
135
145
  */
136
146
  static registerTaskPanelWatcher({ searchCount } = { searchCount: 0 }) {
@@ -226,7 +236,6 @@ class ToolbarContainer extends oom.extends(HTMLElement, optionsDefaults) {
226
236
 
227
237
  /**
228
238
  * Добавляет новую общую кнопку в текущий контейнер панели
229
- *
230
239
  * @param {ButtonOptions} options Опции кнопки
231
240
  */
232
241
  addButton(options) {
@@ -241,16 +250,13 @@ class ToolbarContainer extends oom.extends(HTMLElement, optionsDefaults) {
241
250
  }
242
251
 
243
252
  if (match) {
253
+ const [card] = this.options.card
254
+ ? getListOfOpenCards({ id: this.options.card.data.id })
255
+ : [null]
244
256
  const button = oom.div({
245
257
  class: 'button',
246
258
  title: options.title,
247
- onclick: () => {
248
- const [card] = this.options.card
249
- ? getListOfOpenCards({ id: this.options.card.data.id })
250
- : [null]
251
-
252
- options.onclick(card)
253
- }
259
+ onclick: () => options.onclick(card)
254
260
  })
255
261
 
256
262
  if (options.iconSVG) {
@@ -268,5 +274,5 @@ oom.define(ToolbarContainer)
268
274
 
269
275
 
270
276
  export const toolbar = {
271
- addButton: (options) => ToolbarContainer.addButton(options)
277
+ addButton: (/** @type {ButtonOptions} */ options) => ToolbarContainer.addButton(options)
272
278
  }
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "repository": "github:saby-customizer/saby-customizer.github.io",
11
11
  "license": "Unlicense",
12
- "version": "0.0.2",
12
+ "version": "0.0.4",
13
13
  "type": "module",
14
14
  "main": "./userscript.js",
15
15
  "exports": {