mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 04:56:00 +00:00
form view cleanup
This commit is contained in:
@@ -1,96 +0,0 @@
|
||||
// import type { ChangeSet, ChangeSetRowDefinition } from 'dbgate-datalib';
|
||||
// import {
|
||||
// changeSetContainsChanges,
|
||||
// changeSetInsertNewRow,
|
||||
// createChangeSet,
|
||||
// deleteChangeSetRows,
|
||||
// findExistingChangeSetItem,
|
||||
// getChangeSetInsertedRows,
|
||||
// TableFormViewDisplay,
|
||||
// revertChangeSetRowChanges,
|
||||
// setChangeSetValue,
|
||||
// } from 'dbgate-datalib';
|
||||
// import Former from './Former';
|
||||
|
||||
// export default class ChangeSetFormer extends Former {
|
||||
// public changeSet: ChangeSet;
|
||||
// public setChangeSet: Function;
|
||||
// private batchChangeSet: ChangeSet;
|
||||
// public rowDefinition: ChangeSetRowDefinition;
|
||||
// public rowStatus;
|
||||
// public rowData: {};
|
||||
|
||||
// constructor(
|
||||
// public sourceRow: any,
|
||||
// public changeSetState,
|
||||
// public dispatchChangeSet,
|
||||
// public display: TableFormViewDisplay
|
||||
// ) {
|
||||
// super();
|
||||
// this.changeSet = changeSetState && changeSetState.value;
|
||||
// this.setChangeSet = value => dispatchChangeSet({ type: 'set', value });
|
||||
// this.batchChangeSet = null;
|
||||
// this.rowDefinition = display.getChangeSetRow(sourceRow);
|
||||
// const [matchedField, matchedChangeSetItem] = findExistingChangeSetItem(this.changeSet, this.rowDefinition);
|
||||
// this.rowData = matchedChangeSetItem ? { ...sourceRow, ...matchedChangeSetItem.fields } : sourceRow;
|
||||
// let status = 'regular';
|
||||
// if (matchedChangeSetItem && matchedField == 'updates') status = 'updated';
|
||||
// if (matchedField == 'deletes') status = 'deleted';
|
||||
// this.rowStatus = {
|
||||
// status,
|
||||
// modifiedFields:
|
||||
// matchedChangeSetItem && matchedChangeSetItem.fields ? new Set(Object.keys(matchedChangeSetItem.fields)) : null,
|
||||
// };
|
||||
// }
|
||||
|
||||
// applyModification(changeSetReducer) {
|
||||
// if (this.batchChangeSet) {
|
||||
// this.batchChangeSet = changeSetReducer(this.batchChangeSet);
|
||||
// } else {
|
||||
// this.setChangeSet(changeSetReducer(this.changeSet));
|
||||
// }
|
||||
// }
|
||||
|
||||
// setCellValue(uniqueName: string, value: any) {
|
||||
// const row = this.sourceRow;
|
||||
// const definition = this.display.getChangeSetField(row, uniqueName);
|
||||
// this.applyModification(chs => setChangeSetValue(chs, definition, value));
|
||||
// }
|
||||
|
||||
// deleteRow(index: number) {
|
||||
// this.applyModification(chs => deleteChangeSetRows(chs, this.rowDefinition));
|
||||
// }
|
||||
|
||||
// beginUpdate() {
|
||||
// this.batchChangeSet = this.changeSet;
|
||||
// }
|
||||
// endUpdate() {
|
||||
// this.setChangeSet(this.batchChangeSet);
|
||||
// this.batchChangeSet = null;
|
||||
// }
|
||||
|
||||
// revertRowChanges() {
|
||||
// this.applyModification(chs => revertChangeSetRowChanges(chs, this.rowDefinition));
|
||||
// }
|
||||
// revertAllChanges() {
|
||||
// this.applyModification(chs => createChangeSet());
|
||||
// }
|
||||
// undo() {
|
||||
// this.dispatchChangeSet({ type: 'undo' });
|
||||
// }
|
||||
// redo() {
|
||||
// this.dispatchChangeSet({ type: 'redo' });
|
||||
// }
|
||||
// get editable() {
|
||||
// return this.display.editable;
|
||||
// }
|
||||
// get canUndo() {
|
||||
// return this.changeSetState.canUndo;
|
||||
// }
|
||||
// get canRedo() {
|
||||
// return this.changeSetState.canRedo;
|
||||
// }
|
||||
// get containsChanges() {
|
||||
// return changeSetContainsChanges(this.changeSet);
|
||||
// }
|
||||
// }
|
||||
@@ -1,53 +0,0 @@
|
||||
// // export interface GriderRowStatus {
|
||||
// // status: 'regular' | 'updated' | 'deleted' | 'inserted';
|
||||
// // modifiedFields?: Set<string>;
|
||||
// // insertedFields?: Set<string>;
|
||||
// // deletedFields?: Set<string>;
|
||||
// // }
|
||||
|
||||
// export default abstract class Former {
|
||||
// public rowData: any;
|
||||
|
||||
// // getRowStatus(index): GriderRowStatus {
|
||||
// // const res: GriderRowStatus = {
|
||||
// // status: 'regular',
|
||||
// // };
|
||||
// // return res;
|
||||
// // }
|
||||
// beginUpdate() {}
|
||||
// endUpdate() {}
|
||||
// setCellValue(uniqueName: string, value: any) {}
|
||||
// revertRowChanges() {}
|
||||
// revertAllChanges() {}
|
||||
// undo() {}
|
||||
// redo() {}
|
||||
// get editable() {
|
||||
// return false;
|
||||
// }
|
||||
// get canInsert() {
|
||||
// return false;
|
||||
// }
|
||||
// get allowSave() {
|
||||
// return this.containsChanges;
|
||||
// }
|
||||
// get canUndo() {
|
||||
// return false;
|
||||
// }
|
||||
// get canRedo() {
|
||||
// return false;
|
||||
// }
|
||||
// get containsChanges() {
|
||||
// return false;
|
||||
// }
|
||||
// get disableLoadNextPage() {
|
||||
// return false;
|
||||
// }
|
||||
// get errors() {
|
||||
// return null;
|
||||
// }
|
||||
// updateRow(changeObject) {
|
||||
// for (const key of Object.keys(changeObject)) {
|
||||
// this.setCellValue(key, changeObject[key]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -1,51 +0,0 @@
|
||||
<!-- <script lang="ts">
|
||||
import ColumnLabel from '../elements/ColumnLabel.svelte';
|
||||
import InlineButton from '../buttons/InlineButton.svelte';
|
||||
|
||||
import FontIcon from '../icons/FontIcon.svelte';
|
||||
import keycodes from '../utility/keycodes';
|
||||
|
||||
export let column;
|
||||
export let baseTable;
|
||||
export let formDisplay;
|
||||
|
||||
let domEditor;
|
||||
$: value = formDisplay.getKeyValue(column.columnName);
|
||||
|
||||
const applyFilter = () => {
|
||||
formDisplay.requestKeyValue(column.columnName, domEditor.value);
|
||||
};
|
||||
|
||||
const cancelFilter = () => {
|
||||
formDisplay.cancelRequestKey();
|
||||
formDisplay.reload();
|
||||
};
|
||||
|
||||
const handleKeyDown = ev => {
|
||||
if (ev.keyCode == keycodes.enter) {
|
||||
applyFilter();
|
||||
}
|
||||
if (ev.keyCode == keycodes.escape) {
|
||||
cancelFilter();
|
||||
}
|
||||
};
|
||||
|
||||
$: if (domEditor) domEditor.value = value;
|
||||
</script>
|
||||
|
||||
<div class="m-1">
|
||||
<div class="space-between">
|
||||
<div>
|
||||
<FontIcon icon="img primary-key" />
|
||||
<ColumnLabel {...baseTable.columns.find(x => x.columnName == column.columnName)} />
|
||||
</div>
|
||||
{#if formDisplay.config.formViewKeyRequested}
|
||||
<InlineButton square on:click={cancelFilter}>
|
||||
<FontIcon icon="icon delete" />
|
||||
</InlineButton>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="flex">
|
||||
<input bind:this={domEditor} type="text" on:blur={applyFilter} on:keydown={handleKeyDown} />
|
||||
</div>
|
||||
</div> -->
|
||||
@@ -36,13 +36,11 @@
|
||||
let isLoadedCount = false;
|
||||
let loadedTime = new Date().getTime();
|
||||
let allRowCount = null;
|
||||
let rowCountBefore = null;
|
||||
let errorMessage = null;
|
||||
|
||||
const handleLoadCurrentRow = async () => {
|
||||
if (isLoadingData) return;
|
||||
let newLoadedRow = false;
|
||||
// if (_.isNumber(display.config.formViewRecordNumber)) {
|
||||
isLoadingData = true;
|
||||
const row = await loadRow($$props, display.getPageQuery(display.config.formViewRecordNumber || 0, 1));
|
||||
isLoadingData = false;
|
||||
@@ -50,13 +48,6 @@
|
||||
rowData = row;
|
||||
loadedTime = new Date().getTime();
|
||||
newLoadedRow = row;
|
||||
// }
|
||||
// if (formDisplay.config.formViewKeyRequested && newLoadedRow) {
|
||||
// formDisplay.cancelRequestKey(newLoadedRow);
|
||||
// }
|
||||
// if (!newLoadedRow && !formDisplay.config.formViewKeyRequested) {
|
||||
// await handleNavigate('first');
|
||||
// }
|
||||
};
|
||||
|
||||
const handleLoadRowCount = async () => {
|
||||
@@ -67,24 +58,10 @@
|
||||
isLoadedCount = true;
|
||||
isLoadingCount = false;
|
||||
allRowCount = countRow ? parseInt(countRow.count) : null;
|
||||
// rowCountBefore = countBeforeRow ? parseInt(countBeforeRow.count) : null;
|
||||
};
|
||||
|
||||
const handleNavigate = async command => {
|
||||
display.formViewNavigate(command, allRowCount);
|
||||
|
||||
// isLoadingData = true;
|
||||
// const row = await loadRow($$props, formDisplay.navigateRowQuery(command));
|
||||
// if (row) {
|
||||
// formDisplay.navigate(row);
|
||||
// }
|
||||
// isLoadingData = false;
|
||||
// isLoadedData = true;
|
||||
// isLoadedCount = false;
|
||||
// allRowCount = null;
|
||||
// rowCountBefore = null;
|
||||
// rowData = row;
|
||||
// loadedTime = new Date().getTime();
|
||||
};
|
||||
|
||||
export function reload() {
|
||||
@@ -95,7 +72,6 @@
|
||||
rowData = null;
|
||||
loadedTime = new Date().getTime();
|
||||
allRowCount = null;
|
||||
rowCountBefore = null;
|
||||
errorMessage = null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user