react-graph-grid 0.0.4 → 0.0.6
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/README.md +10 -3
- package/package.json +1 -1
- package/src/GridFE.jsx +155 -13
- package/src/Modal.jsx +1 -1
- package/src/Tests/TestData.jsx +5 -5
- package/src/Themes/Translate.jsx +3 -0
- package/src/css/default.css +23 -0
package/README.md
CHANGED
|
@@ -117,8 +117,7 @@ Example
|
|
|
117
117
|
allowEditGrid={true}
|
|
118
118
|
/>
|
|
119
119
|
|
|
120
|
-
|
|
121
|
-
Some grid properties
|
|
120
|
+
Some grid properties
|
|
122
121
|
|
|
123
122
|
uid - grid uid
|
|
124
123
|
parentGrids - parent grids uids
|
|
@@ -129,4 +128,12 @@ Example
|
|
|
129
128
|
pageSize - grid page size
|
|
130
129
|
|
|
131
130
|
|
|
132
|
-
|
|
131
|
+
For more examples see DebugApp.jsx
|
|
132
|
+
|
|
133
|
+
0.0.5 version
|
|
134
|
+
|
|
135
|
+
"Adjust column visibility" option added to GridFE.jsx module
|
|
136
|
+
|
|
137
|
+
0.0.6 version
|
|
138
|
+
|
|
139
|
+
Fixed GridFE.showColumnsSettings() function
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"author": "Mikhail Razumtsev",
|
|
4
4
|
"description": "A React package containing a grid that can communicate with other grids through a connection graph",
|
|
5
5
|
"private": false,
|
|
6
|
-
"version": "0.0.
|
|
6
|
+
"version": "0.0.6",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"dev": "vite --port 4000",
|
package/src/GridFE.jsx
CHANGED
|
@@ -111,6 +111,7 @@ export class GridFEClass extends GridFLClass {
|
|
|
111
111
|
grid.onClosePopup(e);
|
|
112
112
|
grid.refreshState();
|
|
113
113
|
}}
|
|
114
|
+
footerButtons={grid._popupButtons ? grid._popupButtons : null}
|
|
114
115
|
>
|
|
115
116
|
</Modal>
|
|
116
117
|
:
|
|
@@ -123,10 +124,12 @@ export class GridFEClass extends GridFLClass {
|
|
|
123
124
|
grid.popupIsShowing = false;
|
|
124
125
|
grid.popupCloseWhenEscape = false;
|
|
125
126
|
grid.popupTitle = '';
|
|
127
|
+
delete grid._popupButtons;
|
|
126
128
|
}
|
|
127
129
|
// -------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
128
130
|
renderPopupContent() {
|
|
129
|
-
|
|
131
|
+
const grid = this;
|
|
132
|
+
return grid.columnsSettingsIsShowing ? grid.renderColumnsSettings() : <></>;
|
|
130
133
|
}
|
|
131
134
|
// -------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
132
135
|
renderCell(grid, col, row, selected) {
|
|
@@ -510,8 +513,11 @@ export class GridFEClass extends GridFLClass {
|
|
|
510
513
|
const res = super.getGridSettingsList();
|
|
511
514
|
|
|
512
515
|
const grid = this;
|
|
516
|
+
|
|
517
|
+
res.push({ id: 4, text: grid.translate('Adjust column visibility', 'grid-menu') });
|
|
518
|
+
|
|
513
519
|
if (!grid.exportDisabled) {
|
|
514
|
-
res.push({ id:
|
|
520
|
+
res.push({ id: 5, text: grid.translate('Export to CSV', 'grid-menu') });
|
|
515
521
|
}
|
|
516
522
|
|
|
517
523
|
return res;
|
|
@@ -523,14 +529,150 @@ export class GridFEClass extends GridFLClass {
|
|
|
523
529
|
|
|
524
530
|
switch (String(itemId)) {
|
|
525
531
|
case '4':
|
|
532
|
+
grid.showColumnsSettings();
|
|
533
|
+
grid.refreshState();
|
|
534
|
+
break;
|
|
535
|
+
case '5':
|
|
526
536
|
grid.exportToCSV();
|
|
527
|
-
|
|
528
537
|
grid.refreshState();
|
|
529
538
|
break;
|
|
530
539
|
default:
|
|
531
540
|
}
|
|
532
541
|
}
|
|
533
542
|
// -------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
543
|
+
applyColumnsVisibility() {
|
|
544
|
+
const grid = this;
|
|
545
|
+
for (let col of grid.columns) {
|
|
546
|
+
col.visible = col._newVisible;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
// -------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
550
|
+
showColumnsSettings() {
|
|
551
|
+
const grid = this;
|
|
552
|
+
grid.popupIsShowing = true;
|
|
553
|
+
grid.columnsSettingsIsShowing = true;
|
|
554
|
+
grid.popupTitle = grid.translate('Adjust column visibility');
|
|
555
|
+
|
|
556
|
+
grid._visibleColumnsCount = 0;
|
|
557
|
+
for (let col of grid.columns) {
|
|
558
|
+
col._newVisible = col.visible;
|
|
559
|
+
if (col._newVisible != false) grid._visibleColumnsCount++;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
grid._popupButtons = [
|
|
563
|
+
{
|
|
564
|
+
title: grid.translate('OK'),
|
|
565
|
+
onClick: (e) => {
|
|
566
|
+
grid.applyColumnsVisibility();
|
|
567
|
+
grid.columnsSettingsIsShowing = false;
|
|
568
|
+
grid.onClosePopup(e);
|
|
569
|
+
grid.refreshState();
|
|
570
|
+
}
|
|
571
|
+
},
|
|
572
|
+
{
|
|
573
|
+
title: grid.translate('Cancel'),
|
|
574
|
+
onClick: (e) => {
|
|
575
|
+
grid.columnsSettingsIsShowing = false;
|
|
576
|
+
grid.onClosePopup(e);
|
|
577
|
+
grid.refreshState();
|
|
578
|
+
}
|
|
579
|
+
},
|
|
580
|
+
];
|
|
581
|
+
}
|
|
582
|
+
// -------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
583
|
+
hideAllColumns(preview) {
|
|
584
|
+
const grid = this;
|
|
585
|
+
let first = true;
|
|
586
|
+
for (let col of grid.columns) {
|
|
587
|
+
if (col._newVisible == false || !preview && col.visible == false) continue;
|
|
588
|
+
|
|
589
|
+
if (first) {
|
|
590
|
+
first = false;
|
|
591
|
+
continue;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
if (preview) {
|
|
595
|
+
col._newVisible = false;
|
|
596
|
+
grid._visibleColumnsCount--;
|
|
597
|
+
}
|
|
598
|
+
else {
|
|
599
|
+
col.visible = false;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
// -------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
604
|
+
showAllColumns(preview) {
|
|
605
|
+
const grid = this;
|
|
606
|
+
for (let col of grid.columns) {
|
|
607
|
+
if (col._newVisible != false || !preview && col.visible != false) continue;
|
|
608
|
+
|
|
609
|
+
if (preview) {
|
|
610
|
+
col._newVisible = true;
|
|
611
|
+
grid._visibleColumnsCount++;
|
|
612
|
+
}
|
|
613
|
+
else {
|
|
614
|
+
col.visible = true;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
// -------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
619
|
+
renderColumnsSettings() {
|
|
620
|
+
const grid = this;
|
|
621
|
+
return (
|
|
622
|
+
<div className='grid-columns-settings-div'>
|
|
623
|
+
<div>
|
|
624
|
+
<ul className='dropdown-ul grid-columns-settings-div-ul'>
|
|
625
|
+
<li className="dropdown-item" onClick={(e) => { grid.hideAllColumns(true); grid.refreshState(); }}>
|
|
626
|
+
<div className="dropdown-item-div">
|
|
627
|
+
<span className='grid-columns-settings-label'>{grid.translate('Visible columns')}</span>
|
|
628
|
+
{Images.images.last()}
|
|
629
|
+
</div>
|
|
630
|
+
</li>
|
|
631
|
+
{
|
|
632
|
+
grid.columns.map((column) => {
|
|
633
|
+
if (column._newVisible == false) return <></>;
|
|
634
|
+
|
|
635
|
+
return (
|
|
636
|
+
<li className="dropdown-item" onClick={(e) => { if (grid._visibleColumnsCount > 1) { column._newVisible = false; grid._visibleColumnsCount--; grid.refreshState(); } }}>
|
|
637
|
+
<div className="dropdown-item-div">
|
|
638
|
+
<span>{column.title}</span>
|
|
639
|
+
{Images.images.next()}
|
|
640
|
+
</div>
|
|
641
|
+
</li>
|
|
642
|
+
);
|
|
643
|
+
})
|
|
644
|
+
}
|
|
645
|
+
</ul>
|
|
646
|
+
</div>
|
|
647
|
+
<div></div>
|
|
648
|
+
<div>
|
|
649
|
+
<ul className='dropdown-ul grid-columns-settings-div-ul'>
|
|
650
|
+
<li className="dropdown-item" onClick={(e) => { grid.showAllColumns(true); grid.refreshState(); }}>
|
|
651
|
+
<div className="dropdown-item-div">
|
|
652
|
+
{Images.images.first()}
|
|
653
|
+
<span className='grid-columns-settings-label'>{grid.translate('Invisible columns')}</span>
|
|
654
|
+
</div>
|
|
655
|
+
</li>
|
|
656
|
+
{
|
|
657
|
+
grid.columns.map((column) => {
|
|
658
|
+
if (column._newVisible != false) return <></>;
|
|
659
|
+
|
|
660
|
+
return (
|
|
661
|
+
<li className="dropdown-item" onClick={(e) => { column._newVisible = true; grid._visibleColumnsCount++; grid.refreshState(); }}>
|
|
662
|
+
<div className="dropdown-item-div">
|
|
663
|
+
{Images.images.prev()}
|
|
664
|
+
<span>{column.title}</span>
|
|
665
|
+
</div>
|
|
666
|
+
</li>
|
|
667
|
+
);
|
|
668
|
+
})
|
|
669
|
+
}
|
|
670
|
+
</ul>
|
|
671
|
+
</div>
|
|
672
|
+
</div>
|
|
673
|
+
);
|
|
674
|
+
}
|
|
675
|
+
// -------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
534
676
|
exportToCSV(filename, delimeter) {
|
|
535
677
|
const grid = this;
|
|
536
678
|
|
|
@@ -550,18 +692,18 @@ export class GridFEClass extends GridFLClass {
|
|
|
550
692
|
// 1. Преобразование данных в CSV строку
|
|
551
693
|
const csvContent = "\uFEFF" + // Добавляем BOM для корректного отображения кириллицы в Excel
|
|
552
694
|
[
|
|
553
|
-
|
|
554
|
-
|
|
695
|
+
titles.join(delimeter), // Заголовки
|
|
696
|
+
...grid.rows.map(item => {
|
|
555
697
|
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
698
|
+
let values = [];
|
|
699
|
+
for (let col of grid.columns) {
|
|
700
|
+
if (col.visible == false) continue;
|
|
701
|
+
values.push(item[col.name]);
|
|
702
|
+
}
|
|
703
|
+
return values.join(delimeter);
|
|
562
704
|
|
|
563
|
-
|
|
564
|
-
|
|
705
|
+
//return Object.values(item).join(delimeter);
|
|
706
|
+
}) // Строки данных
|
|
565
707
|
].join("\n");
|
|
566
708
|
|
|
567
709
|
// 2. Создание Blob
|
package/src/Modal.jsx
CHANGED
|
@@ -236,7 +236,7 @@ export class ModalClass extends BaseComponent {
|
|
|
236
236
|
wnd-btn={`button_${wnd.id}_${btn._ind}_`}
|
|
237
237
|
className={wnd.opt.footerButtonClass}
|
|
238
238
|
title={btn.title}
|
|
239
|
-
onClick={btn.
|
|
239
|
+
onClick={btn.onClick ? (e) => btn.onClick(e) : null}
|
|
240
240
|
disabled={btn.getDisabled ? btn.getDisabled() : false}
|
|
241
241
|
>
|
|
242
242
|
<i className={btn.imageClass}></i>
|
package/src/Tests/TestData.jsx
CHANGED
|
@@ -25,10 +25,10 @@ export default class TestData {
|
|
|
25
25
|
{ Id: 14, ParentId: [6, 31], Name: 'Tuyanka', SecondName: 'Batyreva', Date: '15/11/2010', Comment: 'Plemyannica 3', Hometown: 'Elista', HometownId: 5 },
|
|
26
26
|
{ Id: 15, ParentId: [0], Name: 'Shura', SecondName: 'Pelushskaya', Date: '22/04/1919', Comment: 'Dv. Babushka', Hometown: 'Ustyuzhna', HometownId: 9 },
|
|
27
27
|
{ Id: 16, ParentId: [15], Name: 'Ira', SecondName: 'Pelushskaya', Date: '11/06/1947', Comment: 'Dv. Tetya', Hometown: 'Pskov', HometownId: 4 },
|
|
28
|
-
{ Id: 17, ParentId: [11, 23], Name: 'Sveta', SecondName: 'Dolginova', Date: '10/11/
|
|
29
|
-
{ Id: 18, ParentId: [11, 23], Name: 'Rita', SecondName: 'Dolginova', Date: '23/10/
|
|
30
|
-
{ Id: 19, ParentId: [11, 23], Name: 'Nadya', SecondName: 'Shaula', Date: '11/11/
|
|
31
|
-
{ Id: 20, ParentId: [11, 23], Name: 'Vitia', SecondName: 'Dolginov', Date: '11/11/
|
|
28
|
+
{ Id: 17, ParentId: [11, 23], Name: 'Sveta', SecondName: 'Dolginova', Date: '10/11/1954', Comment: 'Tetya', Hometown: 'Novosibirsk', HometownId: 8 },
|
|
29
|
+
{ Id: 18, ParentId: [11, 23], Name: 'Rita', SecondName: 'Dolginova', Date: '23/10/1956', Comment: 'Tetya', Hometown: 'Novosibirsk', HometownId: 8 },
|
|
30
|
+
{ Id: 19, ParentId: [11, 23], Name: 'Nadya', SecondName: 'Shaula', Date: '11/11/1958', Comment: 'Tetya', Hometown: 'Novosibirsk', HometownId: 8 },
|
|
31
|
+
{ Id: 20, ParentId: [11, 23], Name: 'Vitia', SecondName: 'Dolginov', Date: '11/11/1958', Comment: 'Dadya', Hometown: 'Novosibirsk', HometownId: 8 },
|
|
32
32
|
{ Id: 21, ParentId: [11, 23], Name: 'Tanya', SecondName: 'Dolginova', Date: '07/01/1963', Comment: 'Tetya', Hometown: 'Elista', HometownId: 5 },
|
|
33
33
|
{ Id: 22, ParentId: [0], Name: 'Misha', SecondName: 'Razumtsev', Date: '05/11/1918', Comment: 'Ded', Hometown: 'Grafskaya', HometownId: 2 },
|
|
34
34
|
{ Id: 23, ParentId: [0], Name: 'Zambo', SecondName: 'Dolginov', Date: '24/04/1926', Comment: 'Ded 2', Hometown: 'Elista', HometownId: 5 },
|
|
@@ -38,7 +38,7 @@ export default class TestData {
|
|
|
38
38
|
{ Id: 26, ParentId: [19, 33], Name: 'Dima', SecondName: 'Shaula', Date: '??/??/????', Comment: 'Dv. Brother', Hometown: 'Energodar', HometownId: 14 },
|
|
39
39
|
{ Id: 27, ParentId: [20, 35], Name: 'Olga', SecondName: 'Dolginova', Date: '??/??/????', Comment: 'Dv. Sister', Hometown: 'Elista', HometownId: 5 },
|
|
40
40
|
{ Id: 28, ParentId: [20, 35], Name: 'Venia', SecondName: 'Dolginov', Date: '??/??/????', Comment: 'Dv. Brother', Hometown: 'Elista', HometownId: 5 },
|
|
41
|
-
{ Id: 29, ParentId: [20, 36], Name: 'Oleg', SecondName: 'Dolginov', Date: '
|
|
41
|
+
{ Id: 29, ParentId: [20, 36], Name: 'Oleg', SecondName: 'Dolginov', Date: '10/11/????', Comment: 'Dv. Brother', Hometown: 'Elista', HometownId: 5 },
|
|
42
42
|
|
|
43
43
|
{ Id: 30, ParentId: [0], Name: 'Yura', SecondName: 'Pelushskiy', Date: '??/??/1921', Comment: 'Dv. Ded', Hometown: 'Ustyuzhna', HometownId: 9 },
|
|
44
44
|
{ Id: 31, ParentId: [0], Name: 'Sanal', SecondName: 'Batyrev', Date: '11/06/????', Comment: 'Muzh Sestry 3', Hometown: 'Elista', HometownId: 5 },
|
package/src/Themes/Translate.jsx
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
const dict = {
|
|
12
12
|
'ADD': 'Добавить',
|
|
13
13
|
'ADD NEW RECORD': 'Добавить новую строку',
|
|
14
|
+
'ADJUST COLUMN VISIBILITY': 'Настроить видимость колонок',
|
|
14
15
|
'BUTTONS SIZE': 'Размер кнопок',
|
|
15
16
|
'CANCEL': 'Отмена',
|
|
16
17
|
'COLLAPSE': 'Свернуть',
|
|
@@ -29,6 +30,7 @@
|
|
|
29
30
|
'EXPAND': 'Развернуть',
|
|
30
31
|
'EXIT': 'Выход',
|
|
31
32
|
'FIRST': 'К началу',
|
|
33
|
+
'INVISIBLE COLUMNS': 'Невидимые колонки',
|
|
32
34
|
'LARGE BUTTONS': 'Большие',
|
|
33
35
|
'LAST': 'В конец',
|
|
34
36
|
'LOAD MORE RECORDS': 'Загрузить еще строк',
|
|
@@ -62,6 +64,7 @@
|
|
|
62
64
|
'VALUE': 'Значение',
|
|
63
65
|
'VIEW': 'Просмотр',
|
|
64
66
|
'VIEW RECORD': 'Карточка',
|
|
67
|
+
'VISIBLE COLUMNS': 'Видимые колонки',
|
|
65
68
|
'USER': 'Пользователь',
|
|
66
69
|
};
|
|
67
70
|
return dict[text.toUpperCase()] || text;
|
package/src/css/default.css
CHANGED
|
@@ -423,6 +423,14 @@
|
|
|
423
423
|
background-color: lightgray;
|
|
424
424
|
}
|
|
425
425
|
|
|
426
|
+
.dropdown-item-div {
|
|
427
|
+
display: flex;
|
|
428
|
+
justify-content: space-between;
|
|
429
|
+
flex-wrap: nowrap;
|
|
430
|
+
align-items: center;
|
|
431
|
+
width: 100%;
|
|
432
|
+
}
|
|
433
|
+
|
|
426
434
|
.grid-header-content-grid {
|
|
427
435
|
display: grid;
|
|
428
436
|
grid-template-columns: auto 16px;
|
|
@@ -496,6 +504,21 @@
|
|
|
496
504
|
background-color: lightgray;
|
|
497
505
|
}
|
|
498
506
|
|
|
507
|
+
.grid-columns-settings-div {
|
|
508
|
+
display: grid;
|
|
509
|
+
grid-template-columns: calc(50% - 4px) 8px calc(50% - 4px);
|
|
510
|
+
margin: 10px;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
.grid-columns-settings-div-ul {
|
|
514
|
+
margin: 5px;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
.grid-columns-settings-label {
|
|
518
|
+
font-weight: 600;
|
|
519
|
+
/*margin: 5px;*/
|
|
520
|
+
}
|
|
521
|
+
|
|
499
522
|
.graph-tabcontrol-buttons {
|
|
500
523
|
margin: 0 1em;
|
|
501
524
|
display: flex
|