Skip to content

Commit 11b11ab

Browse files
authored
Merge pull request #31 from eviltester/28-add-playwright-coverage-to-apphtml-but-more-control-over-ai
28 add playwright coverage to apphtml but more control over ai
2 parents 7e4956a + 4d6ee3f commit 11b11ab

83 files changed

Lines changed: 3632 additions & 56 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/core-ui/js/gui_components/data-grid-editor/ag-grid/gridExtension-ag-grid.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@ class GridExtensionAgGrid {
3434
this.gridApi.setFilterModel(null);
3535
}
3636

37+
clearSort() {
38+
if (typeof this.gridApi.applyColumnState === 'function') {
39+
this.gridApi.applyColumnState({
40+
defaultState: { sort: null },
41+
});
42+
return;
43+
}
44+
45+
if (typeof this.gridApi.setSortModel === 'function') {
46+
this.gridApi.setSortModel(null);
47+
}
48+
}
49+
3750
filterText(text) {
3851
this.gridApi.setGridOption('quickFilterText', text);
3952
}

packages/core-ui/js/gui_components/data-grid-editor/gridControl.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ class GridControlsPageMap {
55
this.addRowsBelowButtonQuery = '#addRowsBelowButton';
66
this.deleteSelectedRowsButtonQuery = '#deleteSelectedRowsButton';
77
this.clearFiltersButtonQuery = '#clearFiltersButton';
8+
this.clearSortButtonQuery = '#clearSortButton';
89
this.filtersTextBoxQuery = '#filter-text-box';
910
this.clearTableButtonQuery = '#clearTableButton';
1011
}
@@ -27,6 +28,7 @@ class GridControl {
2728
<button id="deleteSelectedRowsButton">Delete Selected Rows</button>
2829
<label>Filter: <input type="text" id="filter-text-box" placeholder="Filter..."></label>
2930
<button id="clearFiltersButton" title="Clear Filters">Clear Filters</button>
31+
<button id="clearSortButton" title="Clear Sort">Clear Sort</button>
3032
<button id="clearTableButton" title="Clear All Data">Reset Table</button>
3133
</div>
3234
<!-- ag-theme-alpine -->
@@ -71,6 +73,12 @@ class GridControl {
7173
let clearFiltersListener = this.clearFilters.bind(this);
7274
element.addEventListener('click', clearFiltersListener, false);
7375

76+
element = container.querySelector(this.pageMap.clearSortButtonQuery);
77+
if (element) {
78+
const clearSortListener = this.clearSort.bind(this);
79+
element.addEventListener('click', clearSortListener, false);
80+
}
81+
7482
element = container.querySelector(this.pageMap.filtersTextBoxQuery);
7583
let filterTextListener = this.filterTextBoxChanged.bind(this);
7684
element.addEventListener('input', filterTextListener, false);
@@ -104,6 +112,12 @@ class GridControl {
104112
this.gridExtras.clearFilters();
105113
}
106114

115+
clearSort() {
116+
if (typeof this.gridExtras.clearSort === 'function') {
117+
this.gridExtras.clearSort();
118+
}
119+
}
120+
107121
filterTextBoxChanged() {
108122
this.gridExtras.filterText(document.getElementById('filter-text-box').value);
109123
}

packages/core-ui/js/gui_components/data-grid-editor/tabulator/gridExtension-tabulator.js

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ class GridExtensionTabulator {
4141
this.tabulator.clearFilter(true);
4242
}
4343

44+
clearSort() {
45+
if (typeof this.tabulator.clearSort === 'function') {
46+
this.tabulator.clearSort();
47+
}
48+
}
49+
4450
// [x] convert to tabulature
4551
filterText(text) {
4652
this.tabUtils.filterAcrossAllColumns(text);
@@ -106,7 +112,7 @@ class GridExtensionTabulator {
106112
}
107113

108114
// [x] convert to tabulature
109-
duplicateColumn(position, columnOrId, colTitle) {
115+
async duplicateColumn(position, columnOrId, colTitle) {
110116
const column = this._resolveColumn(columnOrId);
111117
if (!column) {
112118
return;
@@ -117,7 +123,7 @@ class GridExtensionTabulator {
117123
return;
118124
}
119125

120-
this._copyColumnData(column.getDefinition().field, destinationCol.field);
126+
await this._copyColumnData(column.getDefinition().field, destinationCol.field);
121127
}
122128

123129
appendColumnToGrid(colTitle) {
@@ -572,28 +578,28 @@ class GridExtensionTabulator {
572578
}
573579
}
574580

575-
_copyColumnData(sourceFieldName, destinationFieldName) {
576-
const allData = typeof this.tabulator.getData === 'function' ? this.tabulator.getData() : null;
577-
const canUseBulkDataPath = Array.isArray(allData) && typeof this.tabulator.redraw === 'function';
578-
579-
if (canUseBulkDataPath) {
581+
async _copyColumnData(sourceFieldName, destinationFieldName) {
582+
const rowComponents = typeof this.tabulator.getRows === 'function' ? this.tabulator.getRows() : null;
583+
if (Array.isArray(rowComponents) && rowComponents.length > 0) {
584+
const updates = [];
580585
this._runWithoutRedraw(() => {
581-
for (let rowIndex = 0; rowIndex < allData.length; rowIndex++) {
582-
const rowData = allData[rowIndex];
583-
rowData[destinationFieldName] = rowData[sourceFieldName];
584-
}
586+
rowComponents.forEach((row) => {
587+
const sourceValue = row.getData?.()[sourceFieldName];
588+
updates.push(Promise.resolve(row.update({ [destinationFieldName]: sourceValue })));
589+
});
585590
});
586-
this.tabulator.redraw(true);
591+
await Promise.all(updates);
587592
return;
588593
}
589594

590-
this._runWithoutRedraw(() => {
591-
this.tabulator.getRows().forEach((row) => {
592-
let obj = {};
593-
obj[destinationFieldName] = row.getData()[sourceFieldName];
594-
row.update(obj);
595-
});
596-
});
595+
const allData = typeof this.tabulator.getData === 'function' ? this.tabulator.getData() : null;
596+
if (Array.isArray(allData) && allData.length > 0) {
597+
const updatedRows = allData.map((rowData) => ({
598+
...rowData,
599+
[destinationFieldName]: rowData[sourceFieldName],
600+
}));
601+
await Promise.resolve(this._setBulkData(updatedRows));
602+
}
597603
}
598604

599605
_enqueueGridMutation(mutationFn) {

packages/core-ui/js/gui_components/data-grid-editor/tabulator/main-display-grid.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ class ExtendedDataGrid {
4343
<div class="customHeaderLabel">${escapeHtml(columnName)}</div>
4444
<div class="customSort">
4545
<span class="customSortDownLabel" data-action="sort-desc" title="Sort Desc">
46-
<i class="ag-icon ag-icon-desc"></i>
46+
4747
</span>
4848
<span class="customSortUpLabel" data-action="sort-asc" title="Sort Asc">
49-
<i class="ag-icon ag-icon-asc"></i>
49+
5050
</span>
5151
<span class="customSortRemoveLabel" data-action="sort-none" title="Clear Sort">
52-
<i class="ag-icon ag-icon-cancel"></i>
52+
×
5353
</span>
5454
</div>
5555
</div>
@@ -65,7 +65,9 @@ class ExtendedDataGrid {
6565
};
6666

6767
const onCustomHeaderClick = function (e, column) {
68-
const action = e?.target?.dataset?.action;
68+
const targetElement = e?.target && typeof e.target.closest === 'function' ? e.target : null;
69+
const actionElement = targetElement?.closest?.('[data-action]');
70+
const action = actionElement?.dataset?.action;
6971
if (!action) {
7072
return;
7173
}
@@ -146,6 +148,8 @@ class ExtendedDataGrid {
146148
// not from inferred object keys during setData/import.
147149
autoColumns: false,
148150
headerSort: true,
151+
// Prevent accidental table re-order when clicking non-sort controls in custom headers.
152+
headerSortClickElement: 'icon',
149153

150154
movableColumns: true,
151155

0 commit comments

Comments
 (0)