saby-customizer 0.0.0-pre.30 → 0.0.0-pre.31
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 +137 -8
- package/lib/popup-dialog.js +35 -6
- package/package.json +1 -1
package/features/git-branch.js
CHANGED
|
@@ -182,6 +182,17 @@ export class GitBranchCardData {
|
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
+
/**
|
|
186
|
+
* Удаление карточки задачи из истории
|
|
187
|
+
*
|
|
188
|
+
* @param {number} primaryKey Ид записи в истории
|
|
189
|
+
*/
|
|
190
|
+
async removeFromHistory(primaryKey) {
|
|
191
|
+
const gitBranchHistory = db.table('gitBranchHistory')
|
|
192
|
+
|
|
193
|
+
await gitBranchHistory.delete(primaryKey)
|
|
194
|
+
}
|
|
195
|
+
|
|
185
196
|
}
|
|
186
197
|
|
|
187
198
|
/** Карточка со сведениями о задаче для копирования ветки */
|
|
@@ -208,6 +219,10 @@ class GitBranchCard extends oom.extends(HTMLElement) {
|
|
|
208
219
|
whiteSpace: 'nowrap',
|
|
209
220
|
textOverflow: 'ellipsis'
|
|
210
221
|
},
|
|
222
|
+
'.history-info': {
|
|
223
|
+
fontSize: '13px',
|
|
224
|
+
fontStyle: 'italic'
|
|
225
|
+
},
|
|
211
226
|
'.link': {
|
|
212
227
|
fontSize: '14px',
|
|
213
228
|
color: 'var(--mdc-theme-primary, #6200ee)'
|
|
@@ -265,6 +280,10 @@ class GitBranchCard extends oom.extends(HTMLElement) {
|
|
|
265
280
|
'.description-textarea': {
|
|
266
281
|
width: '100%'
|
|
267
282
|
},
|
|
283
|
+
'.icon_16': {
|
|
284
|
+
'--mdc-icon-size': '16px',
|
|
285
|
+
'--mdc-icon-button-size': '24px'
|
|
286
|
+
},
|
|
268
287
|
'.icon_18': {
|
|
269
288
|
'--mdc-icon-size': '18px',
|
|
270
289
|
'--mdc-icon-button-size': '24px'
|
|
@@ -427,8 +446,32 @@ class GitBranchCard extends oom.extends(HTMLElement) {
|
|
|
427
446
|
|
|
428
447
|
this.updateBranchNamePart().catch(console.error)
|
|
429
448
|
|
|
430
|
-
|
|
431
|
-
.div({ class: 'title' }, this.elements.cardTitle)
|
|
449
|
+
const cardElement = oom.div({ class: 'mdc-card' }, oom
|
|
450
|
+
.div({ class: 'title' }, this.elements.cardTitle))
|
|
451
|
+
|
|
452
|
+
if (this.options.pk) {
|
|
453
|
+
// Добавим элементы для карточки задачи из истории
|
|
454
|
+
const useDate = this.options.useDate.toLocaleString()
|
|
455
|
+
|
|
456
|
+
cardElement(oom.div(oom
|
|
457
|
+
.span({ class: 'history-info' }, `Скопировано: ${useDate}`)
|
|
458
|
+
.mwcIconButton({
|
|
459
|
+
title: 'Удалить из истории',
|
|
460
|
+
class: 'icon_16',
|
|
461
|
+
innerHTML: octicons.x.toSVG({ width: 16 }),
|
|
462
|
+
onclick: () => {
|
|
463
|
+
/** @type {GitBranchCardList} */// @ts-ignore
|
|
464
|
+
const cardList = this.parentElement.parentElement
|
|
465
|
+
|
|
466
|
+
this.remove()
|
|
467
|
+
this.data.removeFromHistory(this.options.pk)
|
|
468
|
+
.then(() => cardList.buildHistoryList())
|
|
469
|
+
.catch(console.error)
|
|
470
|
+
}
|
|
471
|
+
})))
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
return cardElement(oom
|
|
432
475
|
.div(oom
|
|
433
476
|
.a({ class: 'link' }, this.data.url, {
|
|
434
477
|
target: '_blank',
|
|
@@ -531,8 +574,26 @@ class GitBranchCardList extends oom.extends(HTMLElement) {
|
|
|
531
574
|
textAlign: 'center'
|
|
532
575
|
},
|
|
533
576
|
'.content': {
|
|
534
|
-
|
|
535
|
-
|
|
577
|
+
flexGrow: '1',
|
|
578
|
+
overflowY: 'auto',
|
|
579
|
+
overflowX: 'hidden',
|
|
580
|
+
maxHeight: 'calc(var(--mdc-dialog-max-height) - 100px)',
|
|
581
|
+
background: 'var(--mdc-theme-background)'
|
|
582
|
+
},
|
|
583
|
+
'.hide': {
|
|
584
|
+
display: 'none'
|
|
585
|
+
},
|
|
586
|
+
'.nav-buttons': {
|
|
587
|
+
display: 'flex',
|
|
588
|
+
justifyContent: 'space-between',
|
|
589
|
+
alignItems: 'center',
|
|
590
|
+
padding: '4px 4px 0px'
|
|
591
|
+
},
|
|
592
|
+
'.nav-buttons-space': {
|
|
593
|
+
width: '64px'
|
|
594
|
+
},
|
|
595
|
+
'.nav-buttons-page-label': {
|
|
596
|
+
userSelect: 'none'
|
|
536
597
|
}
|
|
537
598
|
})
|
|
538
599
|
|
|
@@ -542,16 +603,38 @@ class GitBranchCardList extends oom.extends(HTMLElement) {
|
|
|
542
603
|
// .mwcTab({ label: 'Список задач' })
|
|
543
604
|
.mwcTab({ label: 'История задач' }))
|
|
544
605
|
|
|
545
|
-
|
|
606
|
+
openTaskList = oom.div({ class: 'content' }, oom.div({ class: 'empty' }, 'Загрузка ...'))
|
|
607
|
+
historyTaskList = oom.div({ class: 'content hide' })
|
|
608
|
+
|
|
609
|
+
// Параметры навигации по истории
|
|
610
|
+
historyListPage = 0
|
|
611
|
+
historyListLimit = 3
|
|
546
612
|
|
|
547
613
|
template = async () => {
|
|
548
614
|
// if (this.openTaskList.length === 0) {
|
|
549
615
|
// this.tabs({ activeindex: '1' })
|
|
550
616
|
// }
|
|
551
|
-
oom(this, this.tabs, this.
|
|
552
|
-
|
|
617
|
+
oom(this, this.tabs, this.openTaskList, this.historyTaskList)
|
|
618
|
+
|
|
619
|
+
this.tabs.dom.addEventListener('MDCTabBar:activated', (/** @type {CustomEvent<import('@material/mwc-list/mwc-list-foundation').ActionDetail>} */event) => {
|
|
620
|
+
switch (event.detail.index) {
|
|
621
|
+
case 0:
|
|
622
|
+
this.historyTaskList({ innerHTML: '' })
|
|
623
|
+
this.historyTaskList.dom.classList.add('hide')
|
|
624
|
+
this.openTaskList.dom.classList.remove('hide')
|
|
625
|
+
break
|
|
626
|
+
case 1:
|
|
627
|
+
this.historyTaskList({ innerHTML: '' }, oom.div({ class: 'empty' }, 'Загрузка ...'))
|
|
628
|
+
this.openTaskList.dom.classList.add('hide')
|
|
629
|
+
this.historyTaskList.dom.classList.remove('hide')
|
|
630
|
+
this.historyListPage = 0
|
|
631
|
+
this.historyListLimit = 3
|
|
632
|
+
this.buildHistoryList().catch(console.error)
|
|
633
|
+
break
|
|
634
|
+
}
|
|
635
|
+
})
|
|
553
636
|
|
|
554
|
-
this.
|
|
637
|
+
this.openTaskList({ innerHTML: '' }, await this.buildTaskList())
|
|
555
638
|
}
|
|
556
639
|
|
|
557
640
|
/** @returns {Promise<HTMLElement|DocumentFragment>} Вернет готовый список задач с учетом аинхронной загрузки данных */
|
|
@@ -573,6 +656,52 @@ class GitBranchCardList extends oom.extends(HTMLElement) {
|
|
|
573
656
|
return taskTist.dom
|
|
574
657
|
}
|
|
575
658
|
|
|
659
|
+
/** Строит компонент списка истории задач */
|
|
660
|
+
async buildHistoryList() {
|
|
661
|
+
const offset = this.historyListPage * this.historyListLimit
|
|
662
|
+
const navButtons = oom.div({ class: 'nav-buttons' })
|
|
663
|
+
const gitBranchHistory = db.table('gitBranchHistory')
|
|
664
|
+
const historyData = await gitBranchHistory
|
|
665
|
+
.orderBy('useDate')
|
|
666
|
+
.reverse()
|
|
667
|
+
.offset(offset)
|
|
668
|
+
.limit(this.historyListLimit + 1)
|
|
669
|
+
.toArray()
|
|
670
|
+
|
|
671
|
+
if (historyData.length > 0) {
|
|
672
|
+
if (this.historyListPage > 0) {
|
|
673
|
+
navButtons(oom.mwcButton({
|
|
674
|
+
innerHTML: octicons['arrow-left'].toSVG({ width: 24 }),
|
|
675
|
+
onclick: () => {
|
|
676
|
+
--this.historyListPage
|
|
677
|
+
this.buildHistoryList().catch(console.error)
|
|
678
|
+
}
|
|
679
|
+
}))
|
|
680
|
+
} else {
|
|
681
|
+
navButtons(oom.span({ class: 'nav-buttons-space' }))
|
|
682
|
+
}
|
|
683
|
+
navButtons(oom.span(`${offset + 1} - ${offset + this.historyListLimit}`, {
|
|
684
|
+
class: 'nav-buttons-page-label'
|
|
685
|
+
}))
|
|
686
|
+
if (historyData.length > this.historyListLimit) {
|
|
687
|
+
historyData.pop()
|
|
688
|
+
navButtons(oom.mwcButton({
|
|
689
|
+
innerHTML: octicons['arrow-right'].toSVG({ width: 24 }),
|
|
690
|
+
onclick: () => {
|
|
691
|
+
++this.historyListPage
|
|
692
|
+
this.buildHistoryList().catch(console.error)
|
|
693
|
+
}
|
|
694
|
+
}))
|
|
695
|
+
} else {
|
|
696
|
+
navButtons(oom.span({ class: 'nav-buttons-space' }))
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
this.historyTaskList({ innerHTML: '' }, navButtons, ...historyData.map(card => new GitBranchCard(card)))
|
|
700
|
+
} else {
|
|
701
|
+
this.historyTaskList({ innerHTML: '' }, oom.div({ class: 'empty' }, 'Задач в истории не найдено'))
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
|
|
576
705
|
}
|
|
577
706
|
|
|
578
707
|
|
package/lib/popup-dialog.js
CHANGED
|
@@ -47,7 +47,8 @@ export class PopupDialog extends oom.extends(HTMLElement, PopupDialogDefaults) {
|
|
|
47
47
|
'mwc-dialog': {
|
|
48
48
|
'--mdc-dialog-z-index': '10000',
|
|
49
49
|
'--mdc-dialog-max-width': '700px',
|
|
50
|
-
'--mdc-dialog-
|
|
50
|
+
'--mdc-dialog-min-width': '500px',
|
|
51
|
+
'--mdc-dialog-max-height': '700px'
|
|
51
52
|
},
|
|
52
53
|
'header': {
|
|
53
54
|
margin: '-20px -24px 0px -24px',
|
|
@@ -61,25 +62,31 @@ export class PopupDialog extends oom.extends(HTMLElement, PopupDialogDefaults) {
|
|
|
61
62
|
overflow: 'hidden'
|
|
62
63
|
},
|
|
63
64
|
'main': {
|
|
65
|
+
display: 'flex',
|
|
66
|
+
flexDirection: 'column',
|
|
64
67
|
margin: '0px -24px -20px -24px',
|
|
65
68
|
overflow: 'auto',
|
|
66
69
|
maxHeight: 'calc(var(--mdc-dialog-max-height) - 52px)'
|
|
67
70
|
}
|
|
68
71
|
})
|
|
69
72
|
|
|
73
|
+
// Фиксированный минимальный размер диалога по содержимому
|
|
74
|
+
contentMinWidth = 0
|
|
75
|
+
contentMinHeight = 0
|
|
76
|
+
|
|
70
77
|
key = this.options.key
|
|
71
78
|
content = typeof this.options.Element === 'string' ? this.options.Element : new this.options.Element()
|
|
79
|
+
main = oom.main(this.content)
|
|
80
|
+
header = oom.header(oom
|
|
81
|
+
.span(this.options.title)
|
|
82
|
+
.mwcIconButton({ icon: 'close', onclick: () => this.close() }))
|
|
72
83
|
|
|
73
84
|
template = async () => {
|
|
74
85
|
// Открытый диалог может быть только один
|
|
75
86
|
this.id = 'sc-popup-dialog'
|
|
76
87
|
/** @type {import('@material/mwc-dialog').Dialog} */// @ts-ignore
|
|
77
88
|
this.dialog = oom
|
|
78
|
-
.mwcDialog({ hideActions: true },
|
|
79
|
-
.header(oom
|
|
80
|
-
.span(this.options.title)
|
|
81
|
-
.mwcIconButton({ icon: 'close', onclick: () => this.close() }))
|
|
82
|
-
.main(this.content))
|
|
89
|
+
.mwcDialog({ hideActions: true }, this.header, this.main)
|
|
83
90
|
.dom
|
|
84
91
|
|
|
85
92
|
oom(this, this.dialog)
|
|
@@ -87,6 +94,10 @@ export class PopupDialog extends oom.extends(HTMLElement, PopupDialogDefaults) {
|
|
|
87
94
|
this.dialog.addEventListener('closed', event => this.closed(event))
|
|
88
95
|
|
|
89
96
|
await this.open()
|
|
97
|
+
|
|
98
|
+
this.fixMinimumSize()
|
|
99
|
+
this.observer = new MutationObserver(() => this.fixMinimumSize())
|
|
100
|
+
this.observer.observe(this, { childList: true, subtree: true })
|
|
90
101
|
}
|
|
91
102
|
|
|
92
103
|
/** Функция открытия диалога с асинхронной задержкой, что бы успело построиться дерево компонента */
|
|
@@ -115,6 +126,24 @@ export class PopupDialog extends oom.extends(HTMLElement, PopupDialogDefaults) {
|
|
|
115
126
|
}
|
|
116
127
|
}
|
|
117
128
|
|
|
129
|
+
/** Фиксирует минимальный размер диалога по содержимому, чтобы избежать дальнейших скачков размера окна */
|
|
130
|
+
fixMinimumSize() {
|
|
131
|
+
const width = Math.max(this.contentMinWidth, this.main.dom.clientWidth)
|
|
132
|
+
const height = Math.max(this.contentMinHeight, this.main.dom.clientHeight)
|
|
133
|
+
|
|
134
|
+
if (this.contentMinWidth !== width || this.contentMinHeight !== height) {
|
|
135
|
+
this.contentMinWidth = width
|
|
136
|
+
this.contentMinHeight = height
|
|
137
|
+
|
|
138
|
+
this.main({
|
|
139
|
+
style: {
|
|
140
|
+
minWidth: `${this.contentMinWidth}px`,
|
|
141
|
+
minHeight: `${this.contentMinHeight}px`
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
118
147
|
}
|
|
119
148
|
|
|
120
149
|
oom.define(PopupDialog)
|