saby-customizer 0.0.0-pre.31 → 0.0.0-pre.34
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.
- package/features/git-branch.js +89 -14
- package/lib/saby-lib/edo.js +17 -3
- package/lib/saby-lib/toolbar.js +3 -2
- package/material.js +269 -48
- package/octicons.js +329 -5
- package/package.json +12 -12
- package/userscript.js +1 -1
package/features/git-branch.js
CHANGED
|
@@ -55,9 +55,7 @@ export class GitBranchCardData {
|
|
|
55
55
|
* @param {string} value Версия
|
|
56
56
|
*/
|
|
57
57
|
set version(value) {
|
|
58
|
-
|
|
59
|
-
this.raw.version = value
|
|
60
|
-
}
|
|
58
|
+
this.raw.version = value || this.raw.version
|
|
61
59
|
}
|
|
62
60
|
|
|
63
61
|
/** @returns {string} Часть имени ветки, зависящая от регламента задачи */
|
|
@@ -249,6 +247,7 @@ class GitBranchCard extends oom.extends(HTMLElement) {
|
|
|
249
247
|
marginBottom: '-1px',
|
|
250
248
|
cursor: 'pointer',
|
|
251
249
|
color: 'var(--mdc-theme-primary, #6200ee)',
|
|
250
|
+
whiteSpace: 'nowrap',
|
|
252
251
|
overflow: 'hidden',
|
|
253
252
|
textOverflow: 'ellipsis'
|
|
254
253
|
},
|
|
@@ -260,6 +259,9 @@ class GitBranchCard extends oom.extends(HTMLElement) {
|
|
|
260
259
|
height: '48px',
|
|
261
260
|
marginTop: '-1px'
|
|
262
261
|
},
|
|
262
|
+
'.branch-sub-name-version': {
|
|
263
|
+
width: '132px'
|
|
264
|
+
},
|
|
263
265
|
'.actions': {
|
|
264
266
|
display: 'flex',
|
|
265
267
|
marginLeft: '12px'
|
|
@@ -306,6 +308,7 @@ class GitBranchCard extends oom.extends(HTMLElement) {
|
|
|
306
308
|
}
|
|
307
309
|
|
|
308
310
|
data = new GitBranchCardData(this.options.data)
|
|
311
|
+
versionsList = this.data.milestones.concat(['Произвольная'])
|
|
309
312
|
|
|
310
313
|
elements = {
|
|
311
314
|
/** @type {HTMLSpanElement} */
|
|
@@ -339,13 +342,23 @@ class GitBranchCard extends oom.extends(HTMLElement) {
|
|
|
339
342
|
oninput: () => this.oninputDescription()
|
|
340
343
|
}).dom,
|
|
341
344
|
/** @type {import('@material/mwc-menu').Menu} */// @ts-ignore
|
|
342
|
-
versions: this.
|
|
345
|
+
versions: this.versionsList.reduce((mwcMenu, item) => {
|
|
343
346
|
return mwcMenu(oom.mwcListItem(item))
|
|
344
347
|
}, oom.mwcMenu({ fixed: true, activatable: true })).dom,
|
|
348
|
+
/** @type {import('@material/mwc-textfield').TextField} */// @ts-ignore
|
|
349
|
+
branchVersionTextfield: oom.mwcTextfield({
|
|
350
|
+
class: 'branch-sub-name branch-sub-name-version hide',
|
|
351
|
+
value: this.data.version,
|
|
352
|
+
placeholder: 'YY.XXXX',
|
|
353
|
+
pattern: '^\\d\\d.\\d\\d\\d\\d$',
|
|
354
|
+
validationmessage: 'Пример: 99.9999',
|
|
355
|
+
oninput: () => this.oninputBranchVersion(),
|
|
356
|
+
onblur: () => this.onblurBranchVersion()
|
|
357
|
+
}).dom,
|
|
345
358
|
/** @type {HTMLDivElement} */// @ts-ignore
|
|
346
359
|
branchButton: oom.div({
|
|
347
360
|
class: 'version-button',
|
|
348
|
-
onclick: () =>
|
|
361
|
+
onclick: () => this.editBranchVersion()
|
|
349
362
|
}, this.data.version).dom,
|
|
350
363
|
/** @type {HTMLSpanElement} */
|
|
351
364
|
branchNamePart: oom.span({
|
|
@@ -396,6 +409,7 @@ class GitBranchCard extends oom.extends(HTMLElement) {
|
|
|
396
409
|
this.data.version = value
|
|
397
410
|
if (this.data.version === value) {
|
|
398
411
|
this.elements.branchButton.textContent = this.data.version
|
|
412
|
+
this.elements.branchVersionTextfield.value = this.data.version
|
|
399
413
|
this.elements.cardTitle.textContent = this.data.branchTitle
|
|
400
414
|
}
|
|
401
415
|
}
|
|
@@ -441,7 +455,7 @@ class GitBranchCard extends oom.extends(HTMLElement) {
|
|
|
441
455
|
template = () => {
|
|
442
456
|
this.elements.versions.anchor = this.elements.branchButton
|
|
443
457
|
this.elements.versions.addEventListener('selected', (/** @type {CustomEvent<import('@material/mwc-list/mwc-list-foundation').ActionDetail>} */event) => {
|
|
444
|
-
this.
|
|
458
|
+
this.selectedVersion(event.detail.index)
|
|
445
459
|
})
|
|
446
460
|
|
|
447
461
|
this.updateBranchNamePart().catch(console.error)
|
|
@@ -484,6 +498,7 @@ class GitBranchCard extends oom.extends(HTMLElement) {
|
|
|
484
498
|
.div({ class: 'branch' },
|
|
485
499
|
this.elements.branchButton,
|
|
486
500
|
this.elements.versions,
|
|
501
|
+
this.elements.branchVersionTextfield,
|
|
487
502
|
this.elements.branchNamePart,
|
|
488
503
|
this.elements.branchSubName,
|
|
489
504
|
this.elements.branchSubNameTextfield)
|
|
@@ -512,6 +527,52 @@ class GitBranchCard extends oom.extends(HTMLElement) {
|
|
|
512
527
|
this.description = this.elements.descriptionTextarea.value
|
|
513
528
|
}
|
|
514
529
|
|
|
530
|
+
/**
|
|
531
|
+
* Обработчик выбора версии из меню
|
|
532
|
+
*
|
|
533
|
+
* @param {number} index Выбранная в меню позиция
|
|
534
|
+
*/
|
|
535
|
+
selectedVersion(index) {
|
|
536
|
+
const version = this.versionsList[index]
|
|
537
|
+
|
|
538
|
+
if (version === 'Произвольная') {
|
|
539
|
+
this.elements.branchVersionTextfield.classList.toggle('hide')
|
|
540
|
+
this.elements.branchButton.classList.toggle('hide')
|
|
541
|
+
this.elements.branchVersionTextfield.focus()
|
|
542
|
+
this.elements.branchVersionTextfield.select()
|
|
543
|
+
} else {
|
|
544
|
+
this.version = version
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/** Открывает форму редактирования версии ветки */
|
|
549
|
+
editBranchVersion() {
|
|
550
|
+
if (this.data.milestones.length === 0) {
|
|
551
|
+
this.elements.branchVersionTextfield.classList.toggle('hide')
|
|
552
|
+
this.elements.branchButton.classList.toggle('hide')
|
|
553
|
+
this.elements.branchVersionTextfield.focus()
|
|
554
|
+
this.elements.branchVersionTextfield.select()
|
|
555
|
+
} else {
|
|
556
|
+
this.elements.versions.open = true
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/** Сохранение данных о версии ветки при вводе */
|
|
561
|
+
oninputBranchVersion() {
|
|
562
|
+
if (this.elements.branchVersionTextfield.checkValidity()) {
|
|
563
|
+
this.version = this.elements.branchVersionTextfield.value
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
/** Скрывает поле ввода версии ветки при потере фокуса */
|
|
568
|
+
onblurBranchVersion() {
|
|
569
|
+
if (this.elements.branchVersionTextfield.checkValidity()) {
|
|
570
|
+
this.elements.branchVersionTextfield.classList.toggle('hide')
|
|
571
|
+
this.elements.branchButton.classList.toggle('hide')
|
|
572
|
+
this.version = this.elements.branchVersionTextfield.value
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
|
|
515
576
|
/** Открывает форму редактирования доп. имени ветки */
|
|
516
577
|
editBranchSubName() {
|
|
517
578
|
this.elements.branchSubName.classList.toggle('hide')
|
|
@@ -542,14 +603,22 @@ class GitBranchCard extends oom.extends(HTMLElement) {
|
|
|
542
603
|
|
|
543
604
|
/** Копирование имени ветки */
|
|
544
605
|
async copyBranchName() {
|
|
545
|
-
|
|
606
|
+
const valid = this.elements.branchSubNameTextfield.checkValidity() &&
|
|
607
|
+
this.elements.branchVersionTextfield.checkValidity()
|
|
608
|
+
|
|
609
|
+
if (valid) {
|
|
546
610
|
await this.data.copyBranchName()
|
|
547
611
|
}
|
|
548
612
|
}
|
|
549
613
|
|
|
550
614
|
/** Копирование описания для git commit */
|
|
551
615
|
async copyDescription() {
|
|
552
|
-
|
|
616
|
+
const valid = this.elements.branchSubNameTextfield.checkValidity() &&
|
|
617
|
+
this.elements.branchVersionTextfield.checkValidity()
|
|
618
|
+
|
|
619
|
+
if (valid) {
|
|
620
|
+
await this.data.copyDescription()
|
|
621
|
+
}
|
|
553
622
|
}
|
|
554
623
|
|
|
555
624
|
/** Восстановление из истории последнего сохраненного состояния карточки */
|
|
@@ -570,7 +639,7 @@ class GitBranchCardList extends oom.extends(HTMLElement) {
|
|
|
570
639
|
static style = oom.style({
|
|
571
640
|
'display': 'contents',
|
|
572
641
|
'.empty': {
|
|
573
|
-
padding: '
|
|
642
|
+
padding: '50px',
|
|
574
643
|
textAlign: 'center'
|
|
575
644
|
},
|
|
576
645
|
'.content': {
|
|
@@ -587,7 +656,8 @@ class GitBranchCardList extends oom.extends(HTMLElement) {
|
|
|
587
656
|
display: 'flex',
|
|
588
657
|
justifyContent: 'space-between',
|
|
589
658
|
alignItems: 'center',
|
|
590
|
-
padding: '4px 4px 0px'
|
|
659
|
+
padding: '4px 4px 0px',
|
|
660
|
+
height: '36px'
|
|
591
661
|
},
|
|
592
662
|
'.nav-buttons-space': {
|
|
593
663
|
width: '64px'
|
|
@@ -641,8 +711,7 @@ class GitBranchCardList extends oom.extends(HTMLElement) {
|
|
|
641
711
|
async buildTaskList() {
|
|
642
712
|
let taskTist = null
|
|
643
713
|
const openTaskList = (await getListOfOpenCards({
|
|
644
|
-
names: ['Ошибка', 'Задача']
|
|
645
|
-
hasVersion: true
|
|
714
|
+
names: ['Ошибка', 'Задача']
|
|
646
715
|
})).map(card => new GitBranchCard(card))
|
|
647
716
|
|
|
648
717
|
await Promise.all(openTaskList.map(card => card.restoreFromHistory()))
|
|
@@ -650,7 +719,7 @@ class GitBranchCardList extends oom.extends(HTMLElement) {
|
|
|
650
719
|
if (openTaskList.length > 0) {
|
|
651
720
|
taskTist = oom()(...openTaskList)
|
|
652
721
|
} else {
|
|
653
|
-
taskTist = oom.div({ class: 'empty' }, 'Открытых задач
|
|
722
|
+
taskTist = oom.div({ class: 'empty' }, 'Открытых задач не найдено')
|
|
654
723
|
}
|
|
655
724
|
|
|
656
725
|
return taskTist.dom
|
|
@@ -669,6 +738,9 @@ class GitBranchCardList extends oom.extends(HTMLElement) {
|
|
|
669
738
|
.toArray()
|
|
670
739
|
|
|
671
740
|
if (historyData.length > 0) {
|
|
741
|
+
const totalCount = await gitBranchHistory.count()
|
|
742
|
+
const currentSize = offset + Math.min(this.historyListLimit, historyData.length)
|
|
743
|
+
|
|
672
744
|
if (this.historyListPage > 0) {
|
|
673
745
|
navButtons(oom.mwcButton({
|
|
674
746
|
innerHTML: octicons['arrow-left'].toSVG({ width: 24 }),
|
|
@@ -680,7 +752,7 @@ class GitBranchCardList extends oom.extends(HTMLElement) {
|
|
|
680
752
|
} else {
|
|
681
753
|
navButtons(oom.span({ class: 'nav-buttons-space' }))
|
|
682
754
|
}
|
|
683
|
-
navButtons(oom.span(`${offset + 1} - ${
|
|
755
|
+
navButtons(oom.span(`${offset + 1} - ${currentSize} / ${totalCount}`, {
|
|
684
756
|
class: 'nav-buttons-page-label'
|
|
685
757
|
}))
|
|
686
758
|
if (historyData.length > this.historyListLimit) {
|
|
@@ -697,6 +769,9 @@ class GitBranchCardList extends oom.extends(HTMLElement) {
|
|
|
697
769
|
}
|
|
698
770
|
|
|
699
771
|
this.historyTaskList({ innerHTML: '' }, navButtons, ...historyData.map(card => new GitBranchCard(card)))
|
|
772
|
+
} else if (this.historyListPage > 0) {
|
|
773
|
+
--this.historyListPage
|
|
774
|
+
this.buildHistoryList().catch(console.error)
|
|
700
775
|
} else {
|
|
701
776
|
this.historyTaskList({ innerHTML: '' }, oom.div({ class: 'empty' }, 'Задач в истории не найдено'))
|
|
702
777
|
}
|
package/lib/saby-lib/edo.js
CHANGED
|
@@ -91,6 +91,16 @@ function parseRichEditorJSON(json) {
|
|
|
91
91
|
* @property {boolean} [hasVersion] Документ включен хотя бы в 1 веху
|
|
92
92
|
* @property {boolean} [duplicates] Показать/скрыть из ответа документы которые открыты дважды
|
|
93
93
|
*/
|
|
94
|
+
/**
|
|
95
|
+
* @typedef ReactWasabyControl filter
|
|
96
|
+
* @property {{record:{get:(name:string)=>any}}} props Опции компонента
|
|
97
|
+
*/
|
|
98
|
+
/**
|
|
99
|
+
* @typedef WasabyControl Реализация компонентов платформы Wasaby в в составе DOM элемента
|
|
100
|
+
* @property {HTMLElement} element Ссылка на DOM элемент
|
|
101
|
+
* @property {{record:{get:(name:string)=>any}}} options Опции компонента
|
|
102
|
+
* @property {ReactWasabyControl} control Доп. вложенность контрола, для реализации на React
|
|
103
|
+
*/
|
|
94
104
|
/**
|
|
95
105
|
* Собирает из верстки страницы список открытых в данный момент карточек документов ЭДО
|
|
96
106
|
*
|
|
@@ -107,10 +117,10 @@ export function getListOfOpenCards(filter = {}) {
|
|
|
107
117
|
const { controlNodes } = cardNode
|
|
108
118
|
|
|
109
119
|
if (controlNodes) {
|
|
110
|
-
/** @type {
|
|
120
|
+
/** @type {WasabyControl} */
|
|
111
121
|
const control = controlNodes.at()
|
|
112
122
|
const { element } = control
|
|
113
|
-
const record = control
|
|
123
|
+
const record = control.options?.record || control.control?.props?.record
|
|
114
124
|
const data = record && {
|
|
115
125
|
id: record.get('@Документ'),
|
|
116
126
|
number: record.get('Номер'),
|
|
@@ -120,10 +130,14 @@ export function getListOfOpenCards(filter = {}) {
|
|
|
120
130
|
url: '',
|
|
121
131
|
author: record.get('ЛицоСоздал.Название') || record.get('Сотрудник.Название'),
|
|
122
132
|
milestones: [],
|
|
123
|
-
version: '
|
|
133
|
+
version: `${(new Date().getFullYear() + '').slice(-2)}.0000`,
|
|
124
134
|
description: ''
|
|
125
135
|
}
|
|
126
136
|
|
|
137
|
+
if (!data) {
|
|
138
|
+
continue
|
|
139
|
+
}
|
|
140
|
+
|
|
127
141
|
if (filter.id && filter.id !== data.id) {
|
|
128
142
|
continue
|
|
129
143
|
}
|
package/lib/saby-lib/toolbar.js
CHANGED
|
@@ -106,7 +106,8 @@ class ToolbarContainer extends oom.extends(HTMLElement, optionsDefaults) {
|
|
|
106
106
|
* Добавляет в вертску сайта глобальный контейнер в панели для добавления кнопок
|
|
107
107
|
*/
|
|
108
108
|
static addGlobalContainer() {
|
|
109
|
-
const sabyPageRightPanel = document.querySelector('.sabyPage-MainLayout__rightPanel .sabyPage-MainLayout__wrapper')
|
|
109
|
+
const sabyPageRightPanel = document.querySelector('.sabyPage-MainLayout__rightPanel .sabyPage-MainLayout__wrapper') ||
|
|
110
|
+
document.querySelector('.sabyPage-MainLayout__mainContent .sabyPage-widgets__rightPanel__bottomButtons .sabyPage-widgets__wrapper')
|
|
110
111
|
|
|
111
112
|
if (sabyPageRightPanel) {
|
|
112
113
|
ToolbarContainer.globalContainer = new ToolbarContainer({ global: true })
|
|
@@ -145,7 +146,7 @@ class ToolbarContainer extends oom.extends(HTMLElement, optionsDefaults) {
|
|
|
145
146
|
/** @type {ToolbarContainer} */
|
|
146
147
|
let topSidebar = topPanel.querySelector('saby-customizer-toolbar')
|
|
147
148
|
|
|
148
|
-
if (topSidebar && topSidebar.options?.card.data.
|
|
149
|
+
if (topSidebar && topSidebar.options?.card.data.id !== card.data.id) {
|
|
149
150
|
topSidebar.remove()
|
|
150
151
|
topSidebar = null
|
|
151
152
|
}
|