fix comment

This commit is contained in:
samunohito 2024-02-20 21:29:56 +09:00
parent effe586092
commit 06c44a9a02
3 changed files with 29 additions and 26 deletions

View File

@ -605,6 +605,7 @@ function onMouseMove(ev: MouseEvent) {
const targetCellAddress = getCellAddress(ev.target as HTMLElement, rowSetting); const targetCellAddress = getCellAddress(ev.target as HTMLElement, rowSetting);
if (equalCellAddress(previousCellAddress.value, targetCellAddress)) { if (equalCellAddress(previousCellAddress.value, targetCellAddress)) {
//
return; return;
} }
@ -615,7 +616,8 @@ function onMouseMove(ev: MouseEvent) {
switch (state.value) { switch (state.value) {
case 'cellSelecting': { case 'cellSelecting': {
const selectedCellAddress = selectedCell.value?.address; const selectedCellAddress = selectedCell.value?.address;
if (equalCellAddress(previousCellAddress.value, targetCellAddress) || !availableCellAddress(targetCellAddress) || !selectedCellAddress) { if (!availableCellAddress(targetCellAddress) || !selectedCellAddress) {
//
return; return;
} }
@ -629,6 +631,7 @@ function onMouseMove(ev: MouseEvent) {
row: Math.max(targetCellAddress.row, selectedCellAddress.row), row: Math.max(targetCellAddress.row, selectedCellAddress.row),
}; };
//
unSelectionOutOfRange(leftTop, rightBottom); unSelectionOutOfRange(leftTop, rightBottom);
expandCellRange(leftTop, rightBottom); expandCellRange(leftTop, rightBottom);
previousCellAddress.value = targetCellAddress; previousCellAddress.value = targetCellAddress;
@ -637,6 +640,7 @@ function onMouseMove(ev: MouseEvent) {
} }
case 'colSelecting': { case 'colSelecting': {
if (!isColumnHeaderCellAddress(targetCellAddress) || previousCellAddress.value.col === targetCellAddress.col) { if (!isColumnHeaderCellAddress(targetCellAddress) || previousCellAddress.value.col === targetCellAddress.col) {
//
return; return;
} }
@ -650,6 +654,7 @@ function onMouseMove(ev: MouseEvent) {
row: cells.value.length - 1, row: cells.value.length - 1,
}; };
//
unSelectionOutOfRange(leftTop, rightBottom); unSelectionOutOfRange(leftTop, rightBottom);
expandCellRange(leftTop, rightBottom); expandCellRange(leftTop, rightBottom);
previousCellAddress.value = targetCellAddress; previousCellAddress.value = targetCellAddress;
@ -661,6 +666,7 @@ function onMouseMove(ev: MouseEvent) {
} }
case 'rowSelecting': { case 'rowSelecting': {
if (!isRowNumberCellAddress(targetCellAddress) || previousCellAddress.value.row === targetCellAddress.row) { if (!isRowNumberCellAddress(targetCellAddress) || previousCellAddress.value.row === targetCellAddress.row) {
//
return; return;
} }
@ -674,9 +680,11 @@ function onMouseMove(ev: MouseEvent) {
row: Math.max(targetCellAddress.row, firstSelectionRowIdx.value), row: Math.max(targetCellAddress.row, firstSelectionRowIdx.value),
}; };
//
unSelectionOutOfRange(leftTop, rightBottom); unSelectionOutOfRange(leftTop, rightBottom);
expandCellRange(leftTop, rightBottom); expandCellRange(leftTop, rightBottom);
//
const rangedRowIndexes = [rows.value[targetCellAddress.row].index, ...rangedRows.value.map(it => it.index)]; const rangedRowIndexes = [rows.value[targetCellAddress.row].index, ...rangedRows.value.map(it => it.index)];
expandRowRange(Math.min(...rangedRowIndexes), Math.max(...rangedRowIndexes)); expandRowRange(Math.min(...rangedRowIndexes), Math.max(...rangedRowIndexes));
@ -714,6 +722,7 @@ function onContextMenu(ev: MouseEvent) {
const context = createContext(); const context = createContext();
const menuItems = Array.of<MenuItem>(); const menuItems = Array.of<MenuItem>();
switch (true) { switch (true) {
//
case availableCellAddress(cellAddress): { case availableCellAddress(cellAddress): {
const cell = cells.value[cellAddress.row].cells[cellAddress.col]; const cell = cells.value[cellAddress.row].cells[cellAddress.col];
if (cell.setting.contextMenuFactory) { if (cell.setting.contextMenuFactory) {
@ -721,6 +730,7 @@ function onContextMenu(ev: MouseEvent) {
} }
break; break;
} }
//
case isColumnHeaderCellAddress(cellAddress): { case isColumnHeaderCellAddress(cellAddress): {
const col = columns.value[cellAddress.col]; const col = columns.value[cellAddress.col];
if (col.setting.contextMenuFactory) { if (col.setting.contextMenuFactory) {
@ -728,6 +738,7 @@ function onContextMenu(ev: MouseEvent) {
} }
break; break;
} }
//
case isRowNumberCellAddress(cellAddress): { case isRowNumberCellAddress(cellAddress): {
const row = rows.value[cellAddress.row]; const row = rows.value[cellAddress.row];
if (row.setting.contextMenuFactory) { if (row.setting.contextMenuFactory) {
@ -768,7 +779,9 @@ function onChangeCellContentSize(sender: GridCell, contentSize: Size) {
if (_cells.length > sender.address.row && _cells[sender.address.row].cells.length > sender.address.col) { if (_cells.length > sender.address.row && _cells[sender.address.row].cells.length > sender.address.col) {
const currentSize = _cells[sender.address.row].cells[sender.address.col].contentSize; const currentSize = _cells[sender.address.row].cells[sender.address.col].contentSize;
if (currentSize.width !== contentSize.width || currentSize.height !== contentSize.height) { if (currentSize.width !== contentSize.width || currentSize.height !== contentSize.height) {
// CSS使
_cells[sender.address.row].cells[sender.address.col].contentSize = contentSize; _cells[sender.address.row].cells[sender.address.col].contentSize = contentSize;
if (sender.column.setting.width === 'auto') { if (sender.column.setting.width === 'auto') {
calcLargestCellWidth(sender.column); calcLargestCellWidth(sender.column);
} }
@ -809,7 +822,9 @@ function onHeaderCellChangeContentSize(sender: GridColumn, newSize: Size) {
case 'normal': { case 'normal': {
const currentSize = columns.value[sender.index].contentSize; const currentSize = columns.value[sender.index].contentSize;
if (currentSize.width !== newSize.width || currentSize.height !== newSize.height) { if (currentSize.width !== newSize.width || currentSize.height !== newSize.height) {
// CSS使
columns.value[sender.index].contentSize = newSize; columns.value[sender.index].contentSize = newSize;
if (sender.setting.width === 'auto') { if (sender.setting.width === 'auto') {
calcLargestCellWidth(sender); calcLargestCellWidth(sender);
} }
@ -880,7 +895,8 @@ function emitGridEvent(ev: GridEvent) {
} }
/** /**
* 親コンポーネントに新しい値を通知するセル値のバリデーション結果は問わない親コンポーネント側で制御する * 親コンポーネントに新しい値を通知する
* 新しい値はイベント通知元データへの反映再計算バリデーション含む再描画の流れで反映される
*/ */
function emitCellValue(sender: GridCell | CellAddress, newValue: CellValue) { function emitCellValue(sender: GridCell | CellAddress, newValue: CellValue) {
const cellAddress = 'address' in sender ? sender.address : sender; const cellAddress = 'address' in sender ? sender.address : sender;
@ -938,7 +954,7 @@ function unSelectionRangeAll() {
cell.ranged = false; cell.ranged = false;
} }
const _rows = rows.value; const _rows = rows.value.filter(it => it.using);
for (const row of _rows) { for (const row of _rows) {
row.ranged = false; row.ranged = false;
} }
@ -992,6 +1008,9 @@ function expandRowRange(top: number, bottom: number) {
} }
} }
/**
* 特定の条件下でのみ適用されるCSSを反映する
*/
function applyRowRules(targetCells: GridCell[]) { function applyRowRules(targetCells: GridCell[]) {
const _rows = rows.value; const _rows = rows.value;
const targetRowIdxes = [...new Set(targetCells.map(it => it.address.row))]; const targetRowIdxes = [...new Set(targetCells.map(it => it.address.row))];
@ -1086,6 +1105,9 @@ function refreshData() {
console.log('[grid][refresh-data][begin]'); console.log('[grid][refresh-data][begin]');
} }
//
//
//
const _data: DataSource[] = data.value; const _data: DataSource[] = data.value;
const _rows: GridRow[] = (_data.length > rowSetting.minimumDefinitionCount) const _rows: GridRow[] = (_data.length > rowSetting.minimumDefinitionCount)
? _data.map((_, index) => createRow(index, true, rowSetting)) ? _data.map((_, index) => createRow(index, true, rowSetting))
@ -1137,7 +1159,7 @@ function patchData(newItems: DataSource[]) {
const newRows = Array.of<GridRow>(); const newRows = Array.of<GridRow>();
const newCells = Array.of<RowHolder>(); const newCells = Array.of<RowHolder>();
// // 使
for (let rowIdx = rows.value.length; rowIdx < newItems.length; rowIdx++) { for (let rowIdx = rows.value.length; rowIdx < newItems.length; rowIdx++) {
const newRow = createRow(rowIdx, true, rowSetting); const newRow = createRow(rowIdx, true, rowSetting);
newRows.push(newRow); newRows.push(newRow);
@ -1169,6 +1191,7 @@ function patchData(newItems: DataSource[]) {
} }
} }
//
const changedCells = Array.of<GridCell>(); const changedCells = Array.of<GridCell>();
for (let rowIdx = 0; rowIdx < newItems.length; rowIdx++) { for (let rowIdx = 0; rowIdx < newItems.length; rowIdx++) {
const holder = cells.value[rowIdx]; const holder = cells.value[rowIdx];

View File

@ -23,8 +23,6 @@ export type GridContext = {
export type GridEvent = export type GridEvent =
GridCellValueChangeEvent | GridCellValueChangeEvent |
GridKeyDownEvent |
GridMouseDownEvent |
GridCellValidationEvent GridCellValidationEvent
; ;
@ -41,14 +39,3 @@ export type GridCellValidationEvent = {
violation?: ValidateViolation; violation?: ValidateViolation;
all: ValidateViolation[]; all: ValidateViolation[];
}; };
export type GridKeyDownEvent = {
type: 'keydown';
event: KeyboardEvent;
};
export type GridMouseDownEvent = {
type: 'mousedown';
event: MouseEvent;
clickedCellAddress: CellAddress;
};

View File

@ -116,7 +116,7 @@ import MkButton from '@/components/MkButton.vue';
import MkInput from '@/components/MkInput.vue'; import MkInput from '@/components/MkInput.vue';
import MkGrid from '@/components/grid/MkGrid.vue'; import MkGrid from '@/components/grid/MkGrid.vue';
import { emptyStrToUndefined, RequestLogItem } from '@/pages/admin/custom-emojis-manager.impl.js'; import { emptyStrToUndefined, RequestLogItem } from '@/pages/admin/custom-emojis-manager.impl.js';
import { GridCellValueChangeEvent, GridContext, GridEvent, GridKeyDownEvent } from '@/components/grid/grid-event.js'; import { GridCellValueChangeEvent, GridEvent } from '@/components/grid/grid-event.js';
import MkFolder from '@/components/MkFolder.vue'; import MkFolder from '@/components/MkFolder.vue';
import XRegisterLogs from '@/pages/admin/custom-emojis-manager.logs.vue'; import XRegisterLogs from '@/pages/admin/custom-emojis-manager.logs.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
@ -251,14 +251,11 @@ async function onImportClicked() {
await importEmojis(targets); await importEmojis(targets);
} }
function onGridEvent(event: GridEvent, currentState: GridContext) { function onGridEvent(event: GridEvent) {
switch (event.type) { switch (event.type) {
case 'cell-value-change': case 'cell-value-change':
onGridCellValueChange(event); onGridCellValueChange(event);
break; break;
case 'keydown':
onGridKeyDown(event, currentState);
break;
} }
} }
@ -269,10 +266,6 @@ function onGridCellValueChange(event: GridCellValueChangeEvent) {
} }
} }
function onGridKeyDown(event: GridKeyDownEvent, currentState: GridContext) {
optInGridUtils.defaultKeyDownHandler(gridItems, event, currentState);
}
async function importEmojis(targets: GridItem[]) { async function importEmojis(targets: GridItem[]) {
const action = () => { const action = () => {
return targets.map(item => return targets.map(item =>