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

View File

@ -23,8 +23,6 @@ export type GridContext = {
export type GridEvent =
GridCellValueChangeEvent |
GridKeyDownEvent |
GridMouseDownEvent |
GridCellValidationEvent
;
@ -41,14 +39,3 @@ export type GridCellValidationEvent = {
violation?: 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 MkGrid from '@/components/grid/MkGrid.vue';
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 XRegisterLogs from '@/pages/admin/custom-emojis-manager.logs.vue';
import * as os from '@/os.js';
@ -251,14 +251,11 @@ async function onImportClicked() {
await importEmojis(targets);
}
function onGridEvent(event: GridEvent, currentState: GridContext) {
function onGridEvent(event: GridEvent) {
switch (event.type) {
case 'cell-value-change':
onGridCellValueChange(event);
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[]) {
const action = () => {
return targets.map(item =>