saby-customizer 0.0.0-pre.21 → 0.0.0-pre.25

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.
@@ -1,5 +1,5 @@
1
1
  import { oom } from '@notml/core'
2
- import { keysMapping, rightSidebar, PopupDialog, getListOfOpenCards, snackbar, context, db } from 'saby-customizer/lib.js'
2
+ import { keysMapping, toolbar, PopupDialog, getListOfOpenCards, snackbar, context, db } from 'saby-customizer/lib.js'
3
3
  import { octicons } from 'saby-customizer/octicons.js'
4
4
 
5
5
 
@@ -181,7 +181,8 @@ class GitBranchCard extends oom.extends(HTMLElement) {
181
181
  placeholder: this.data.branchSubName,
182
182
  pattern: '^\\w+[\\w()-]*$',
183
183
  validationmessage: 'Латинские буквы, цифры и _()-',
184
- onblur: event => this.saveBranchSubName(event)
184
+ oninput: () => this.oninputBranchSubName(),
185
+ onblur: () => this.onblurBranchSubName()
185
186
  }).dom,
186
187
  /** @type {import('@material/mwc-icon-button').IconButton} */// @ts-ignore
187
188
  copyBranchButton: oom.mwcIconButton({
@@ -244,9 +245,10 @@ class GitBranchCard extends oom.extends(HTMLElement) {
244
245
  */
245
246
  set branchSubName(value) {
246
247
  this.data.branchSubName = value || this.data.number
247
- this.elements.branchSubName.textContent = this.data.branchSubName
248
- this.elements.branchSubName.title = this.data.branchSubName
249
- this.elements.branchSubNameTextfield.value = this.data.branchSubName
248
+ oom(this.elements.branchSubName, { innerHTML: '', title: this.data.branchSubName }, this.data.branchSubName)
249
+ if (this.elements.branchSubNameTextfield.value !== this.data.branchSubName) {
250
+ this.elements.branchSubNameTextfield.value = this.data.branchSubName
251
+ }
250
252
  }
251
253
 
252
254
  /** @returns {string} Краткое описание задачи */
@@ -327,14 +329,16 @@ class GitBranchCard extends oom.extends(HTMLElement) {
327
329
  this.elements.branchSubNameTextfield.select()
328
330
  }
329
331
 
330
- /**
331
- * Сохранение данных о доп. имени ветки при потере фокуса с поля ввода
332
- *
333
- * @param {{target:import('@material/mwc-textfield').TextField}} event Данные о событи onblur
334
- */
335
- saveBranchSubName({ target }) {
336
- if (target.checkValidity()) {
337
- this.branchSubName = target.value
332
+ /** Сохранение данных о доп. имени ветки при вводе */
333
+ oninputBranchSubName() {
334
+ if (this.elements.branchSubNameTextfield.checkValidity()) {
335
+ this.branchSubName = this.elements.branchSubNameTextfield.value
336
+ }
337
+ }
338
+
339
+ /** Скрывает поле ввода доп. имени ветки при потере фокуса */
340
+ onblurBranchSubName() {
341
+ if (this.elements.branchSubNameTextfield.checkValidity()) {
338
342
  this.elements.branchSubName.classList.toggle('hide')
339
343
  this.elements.branchSubNameTextfield.classList.toggle('hide')
340
344
  }
@@ -488,7 +492,7 @@ keysMapping['alt-KeyB'] = () => PopupDialog.toggle({
488
492
  Element: GitBranchCardList
489
493
  })
490
494
 
491
- rightSidebar.addButton({
495
+ toolbar.addButton({
492
496
  title: 'Ветки для Git',
493
497
  iconSVG: octicons['git-branch'].toSVG({ width: 24 }),
494
498
  onclick: keysMapping['alt-KeyB']
@@ -83,6 +83,7 @@ function parseRichEditorJSON(json) {
83
83
  * @typedef OpenCardsFilter Фильтры для выборки документов
84
84
  * @property {Array<string>} [names] Фильтр по названию документа
85
85
  * @property {boolean} [hasVersion] Документ включен хотя бы в 1 веху
86
+ * @property {boolean} [duplicates] Показать/скрыть из ответа документы которые открыты дважды
86
87
  */
87
88
  /**
88
89
  * Собирает из верстки страницы список открытых в данный момент карточек документов ЭДО
@@ -93,6 +94,7 @@ function parseRichEditorJSON(json) {
93
94
  export function getListOfOpenCards(filter = {}) {
94
95
  const cardNodes = document.querySelectorAll('.edo3-Dialog')
95
96
  const cards = []
97
+ const exists = []
96
98
 
97
99
  for (const cardNode of Array.from(cardNodes)) {
98
100
  // @ts-ignore
@@ -116,8 +118,12 @@ export function getListOfOpenCards(filter = {}) {
116
118
  description: ''
117
119
  }
118
120
 
119
- if (data) {
120
- const milestonesRS = record.get('РП.ВехаДокумента')
121
+ if (data && (filter.duplicates || !exists.includes(data.id))) {
122
+ const milestonesRS = record.get('РП.ВехаДокумента') || []
123
+
124
+ if (!filter.duplicates) {
125
+ exists.push(data.id)
126
+ }
121
127
 
122
128
  data.name = replaceDocTypeName[data.name] || data.name
123
129
  if (filter.names) {
@@ -1,14 +1,15 @@
1
1
  import { oom } from '@notml/core'
2
+ import { getListOfOpenCards } from './edo.js'
2
3
 
3
4
  const { MutationObserver } = window
4
5
 
5
6
 
6
7
  /** Класс контейнера для расширения правой панели сайта дополнительными кнопками */
7
- class RightSidebarButtonsContainer extends oom.extends(HTMLElement, { global: false }) {
8
+ class ToolbarContainer extends oom.extends(HTMLElement, { global: false }) {
8
9
 
9
- static tagName = 'saby-customizer-right-sidebar'
10
+ static tagName = 'saby-customizer-toolbar'
10
11
  static style = oom.style({
11
- 'saby-customizer-right-sidebar': {
12
+ 'saby-customizer-toolbar': {
12
13
  marginBottom: '12px'
13
14
  },
14
15
  '.button': {
@@ -40,10 +41,10 @@ class RightSidebarButtonsContainer extends oom.extends(HTMLElement, { global: fa
40
41
  /** @type {ButtonOptions[]} */
41
42
  static buttons = []
42
43
 
43
- /** @type {Set<RightSidebarButtonsContainer>} */
44
+ /** @type {Set<ToolbarContainer>} */
44
45
  static containers = new Set()
45
46
 
46
- /** @type {RightSidebarButtonsContainer} */
47
+ /** @type {ToolbarContainer} */
47
48
  static globalContainer = null
48
49
 
49
50
  /** @type {MutationObserver} */
@@ -59,10 +60,11 @@ class RightSidebarButtonsContainer extends oom.extends(HTMLElement, { global: fa
59
60
 
60
61
  this.containers.forEach(container => container.addButton(options))
61
62
 
62
- if (!RightSidebarButtonsContainer.globalContainer) {
63
+ if (!ToolbarContainer.globalContainer) {
63
64
  this.addGlobalContainer()
64
65
  }
65
66
  if (!this.observer) {
67
+ this.addTaskPanelContainer()
66
68
  this.registerTaskPanelWatcher()
67
69
  }
68
70
  }
@@ -74,16 +76,8 @@ class RightSidebarButtonsContainer extends oom.extends(HTMLElement, { global: fa
74
76
  const sabyPageRightPanel = document.querySelector('.sabyPage-MainLayout__rightPanel .sabyPage-MainLayout__wrapper')
75
77
 
76
78
  if (sabyPageRightPanel) {
77
- RightSidebarButtonsContainer.globalContainer = new RightSidebarButtonsContainer({ global: true })
78
- sabyPageRightPanel.prepend(RightSidebarButtonsContainer.globalContainer)
79
- } else {
80
- // Глобальные кнопки в карточке открытой в отдельной вкладке
81
- const cardRightPanel = document.querySelector('.controls-StackTemplate__rightPanel .sabyPage-widgets__wrapper')
82
-
83
- if (cardRightPanel) {
84
- RightSidebarButtonsContainer.globalContainer = new RightSidebarButtonsContainer({ global: true })
85
- cardRightPanel.prepend(RightSidebarButtonsContainer.globalContainer)
86
- }
79
+ ToolbarContainer.globalContainer = new ToolbarContainer({ global: true })
80
+ sabyPageRightPanel.prepend(ToolbarContainer.globalContainer)
87
81
  }
88
82
  }
89
83
 
@@ -92,24 +86,28 @@ class RightSidebarButtonsContainer extends oom.extends(HTMLElement, { global: fa
92
86
  const popupContainer = document.getElementById('popup')
93
87
 
94
88
  if (popupContainer) {
95
- this.observer = new MutationObserver(() => {
96
- let rightPanels = popupContainer.querySelectorAll('.controls-StackTemplate__rightPanel .sabyPage-MainLayout__wrapper')
89
+ this.observer = new MutationObserver(() => this.addTaskPanelContainer())
90
+ this.observer.observe(popupContainer, { childList: true })
91
+ }
92
+ }
97
93
 
98
- if (rightPanels.length === 0) {
99
- // Кнопки для всплывающий панелей в карточке открытой в отдельной вкладке
100
- rightPanels = popupContainer.querySelectorAll('.controls-StackTemplate__rightPanel .sabyPage-widgets__wrapper')
101
- }
94
+ /** Добавления во все найденные открытые задачи правую панель */
95
+ static addTaskPanelContainer() {
96
+ const openTaskList = getListOfOpenCards({ duplicates: true })
102
97
 
103
- rightPanels.forEach(panel => {
104
- const rightSidebar = panel.querySelector('saby-customizer-right-sidebar')
98
+ openTaskList.forEach(({ element }) => {
99
+ const rightPanel = element.querySelector('.controls-StackTemplate__rightPanel .sabyPage-MainLayout__wrapper') ||
100
+ // Кнопки для всплывающий панелей в карточке открытой в отдельной вкладке
101
+ element.querySelector('.controls-StackTemplate__rightPanel .sabyPage-widgets__wrapper')
105
102
 
106
- if (!rightSidebar) {
107
- panel.prepend(new RightSidebarButtonsContainer())
108
- }
109
- })
110
- })
111
- this.observer.observe(popupContainer, { childList: true })
112
- }
103
+ if (rightPanel) {
104
+ const rightSidebar = rightPanel.querySelector('saby-customizer-toolbar')
105
+
106
+ if (!rightSidebar) {
107
+ rightPanel.prepend(new ToolbarContainer())
108
+ }
109
+ }
110
+ })
113
111
  }
114
112
 
115
113
  template = () => {
@@ -120,17 +118,17 @@ class RightSidebarButtonsContainer extends oom.extends(HTMLElement, { global: fa
120
118
 
121
119
  /** Будем запоминать все контейнеры для синхронизации кнопок */
122
120
  connectedCallback() {
123
- RightSidebarButtonsContainer.containers.add(this)
124
- RightSidebarButtonsContainer.buttons.forEach(options => this.addButton(options))
121
+ ToolbarContainer.containers.add(this)
122
+ ToolbarContainer.buttons.forEach(options => this.addButton(options))
125
123
  }
126
124
 
127
125
  /** Очищаем удаленные из DOM контейнеры */
128
126
  disconnectedCallback() {
129
127
  if (this.options.global) {
130
- RightSidebarButtonsContainer.globalContainer = null
131
- RightSidebarButtonsContainer.addGlobalContainer()
128
+ ToolbarContainer.globalContainer = null
129
+ ToolbarContainer.addGlobalContainer()
132
130
  }
133
- RightSidebarButtonsContainer.containers.delete(this)
131
+ ToolbarContainer.containers.delete(this)
134
132
  this.innerHTML = ''
135
133
  }
136
134
 
@@ -156,9 +154,9 @@ class RightSidebarButtonsContainer extends oom.extends(HTMLElement, { global: fa
156
154
  }
157
155
 
158
156
 
159
- oom.define(RightSidebarButtonsContainer)
157
+ oom.define(ToolbarContainer)
160
158
 
161
159
 
162
- export const rightSidebar = {
163
- addButton: (options) => RightSidebarButtonsContainer.addButton(options)
160
+ export const toolbar = {
161
+ addButton: (options) => ToolbarContainer.addButton(options)
164
162
  }
package/lib.js CHANGED
@@ -4,5 +4,5 @@ export * from './lib/hotkeys.js'
4
4
  export * from './lib/layout.js'
5
5
  export * from './lib/popup-dialog.js'
6
6
  export * from './lib/saby-lib/edo.js'
7
- export * from './lib/saby-lib/right-sidebar.js'
8
7
  export * from './lib/saby-lib/rpc.js'
8
+ export * from './lib/saby-lib/toolbar.js'