saby-customizer 0.0.0-pre.22 → 0.0.0-pre.26

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
 
@@ -492,7 +492,7 @@ keysMapping['alt-KeyB'] = () => PopupDialog.toggle({
492
492
  Element: GitBranchCardList
493
493
  })
494
494
 
495
- rightSidebar.addButton({
495
+ toolbar.addButton({
496
496
  title: 'Ветки для Git',
497
497
  iconSVG: octicons['git-branch'].toSVG({ width: 24 }),
498
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'