mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
fix: CB-154 show confirmation for unsaved changes in grid
This commit is contained in:
+16
-16
@@ -60,10 +60,10 @@ export class DataGridContextMenuFilterService {
|
||||
const data = model.source.getAction(resultIndex, ResultSetDataAction);
|
||||
const columnLabel = data.getColumn(column)?.label || '';
|
||||
|
||||
await model.requestDataAction(() =>
|
||||
constraints.setFilter(columnLabel, operator, filterValue)
|
||||
);
|
||||
await model.refresh();
|
||||
await model.requestDataAction(async () => {
|
||||
constraints.setFilter(columnLabel, operator, filterValue);
|
||||
await model.refresh(true);
|
||||
});
|
||||
}
|
||||
|
||||
private async getClipboardValue() {
|
||||
@@ -158,10 +158,10 @@ export class DataGridContextMenuFilterService {
|
||||
const { model, resultIndex } = context.data;
|
||||
const constraints = model.source.getAction(resultIndex, ResultSetConstraintAction);
|
||||
|
||||
await model.requestDataAction(() =>
|
||||
constraints.deleteData()
|
||||
);
|
||||
await model.refresh();
|
||||
await model.requestDataAction(async () => {
|
||||
constraints.deleteData();
|
||||
await model.refresh(true);
|
||||
});
|
||||
},
|
||||
}
|
||||
);
|
||||
@@ -401,10 +401,10 @@ export class DataGridContextMenuFilterService {
|
||||
const data = model.source.getAction(resultIndex, ResultSetDataAction);
|
||||
const columnLabel = data.getColumn(key.column)?.label || '';
|
||||
|
||||
await model.requestDataAction(() =>
|
||||
constraints.deleteFilter(columnLabel)
|
||||
);
|
||||
await model.refresh();
|
||||
await model.requestDataAction(async () => {
|
||||
constraints.deleteFilter(columnLabel);
|
||||
await model.refresh(true);
|
||||
});
|
||||
},
|
||||
}
|
||||
);
|
||||
@@ -428,10 +428,10 @@ export class DataGridContextMenuFilterService {
|
||||
const { model, resultIndex } = context.data;
|
||||
const constraints = model.source.getAction(resultIndex, ResultSetConstraintAction);
|
||||
|
||||
await model.requestDataAction(() =>
|
||||
constraints.deleteDataFilters()
|
||||
);
|
||||
await model.refresh();
|
||||
await model.requestDataAction(async () => {
|
||||
constraints.deleteDataFilters();
|
||||
await model.refresh(true);
|
||||
});
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
+8
-8
@@ -33,10 +33,10 @@ export class DataGridContextMenuOrderService {
|
||||
const constraints = model.source.getAction(resultIndex, ResultSetConstraintAction);
|
||||
const columnLabel = data.getColumn(column)?.label || '';
|
||||
|
||||
await model.requestDataAction(() =>
|
||||
constraints.setOrder(columnLabel, order, true)
|
||||
);
|
||||
await model.refresh();
|
||||
await model.requestDataAction(async () => {
|
||||
constraints.setOrder(columnLabel, order, true);
|
||||
await model.refresh(true);
|
||||
});
|
||||
}
|
||||
|
||||
register(): void {
|
||||
@@ -141,10 +141,10 @@ export class DataGridContextMenuOrderService {
|
||||
isDisabled: context => context.data.model.isLoading(),
|
||||
onClick: async context => {
|
||||
const constraints = context.data.model.source.getAction(context.data.resultIndex, ResultSetConstraintAction);
|
||||
await context.data.model.requestDataAction(() =>
|
||||
constraints.deleteOrders()
|
||||
);
|
||||
await context.data.model.refresh();
|
||||
await context.data.model.requestDataAction(async () => {
|
||||
constraints.deleteOrders();
|
||||
await context.data.model.refresh(true);
|
||||
});
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
+1
-1
@@ -70,8 +70,8 @@ export const OrderButton = observer<Props>(function OrderButton({
|
||||
const nextOrder = getNextOrder(currentOrder);
|
||||
await model.requestDataAction(async () => {
|
||||
constraints.setOrder(attribute, nextOrder, e.ctrlKey || e.metaKey);
|
||||
await model.refresh(true);
|
||||
});
|
||||
await model.refresh();
|
||||
};
|
||||
|
||||
return styled(styles)(
|
||||
|
||||
@@ -125,7 +125,7 @@ export class DataViewerTabService {
|
||||
// TODO: used for initial data fetch, but can repeat request each time data tab is selected,
|
||||
// so probably should be refactored and managed by presentation
|
||||
if (model.source.error === null && model.source.results.length === 0) {
|
||||
model.requestData();
|
||||
model.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -117,12 +117,16 @@ implements IDatabaseDataModel<TOptions, TResult> {
|
||||
await this.requestDataAction(() => this.source.retry());
|
||||
}
|
||||
|
||||
async refresh(): Promise<void> {
|
||||
await this.requestData();
|
||||
async refresh(concurrent?: boolean): Promise<void> {
|
||||
if (concurrent) {
|
||||
await this.source.requestData();
|
||||
return;
|
||||
}
|
||||
await this.requestDataAction(() => this.source.requestData());
|
||||
}
|
||||
|
||||
async reload(): Promise<void> {
|
||||
await this.requestDataAction(() => this
|
||||
await this.requestDataAction(() => this.source
|
||||
.setSlice(0, this.countGain)
|
||||
.requestData()
|
||||
);
|
||||
@@ -137,10 +141,6 @@ implements IDatabaseDataModel<TOptions, TResult> {
|
||||
}
|
||||
}
|
||||
|
||||
async requestData(): Promise<void> {
|
||||
await this.requestDataAction(() => this.source.requestData());
|
||||
}
|
||||
|
||||
cancel(): Promise<void> | void {
|
||||
return this.source.cancel();
|
||||
}
|
||||
@@ -157,8 +157,8 @@ implements IDatabaseDataModel<TOptions, TResult> {
|
||||
return action();
|
||||
}
|
||||
|
||||
async requestDataAction(action: () => Promise<void> | void, concurrent?: boolean): Promise<void> {
|
||||
if (this.currentTask && !concurrent) {
|
||||
async requestDataAction(action: () => Promise<void> | void): Promise<void> {
|
||||
if (this.currentTask) {
|
||||
return this.currentTask;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,11 +43,10 @@ export interface IDatabaseDataModel<TOptions = any, TResult extends IDatabaseDat
|
||||
requestOptionsChange: () => Promise<boolean>;
|
||||
requestDataAction: (action: () => Promise<void> | void) => Promise<void>;
|
||||
retry: () => Promise<void>;
|
||||
save: (concurrent?: boolean) => Promise<void>;
|
||||
refresh: () => Promise<void>;
|
||||
save: () => Promise<void>;
|
||||
refresh: (concurrent?: boolean) => Promise<void>;
|
||||
reload: () => Promise<void>;
|
||||
requestDataPortion: (offset: number, count: number) => Promise<void>;
|
||||
requestData: () => Promise<void>;
|
||||
cancel: () => Promise<void> | void;
|
||||
resetData: () => void;
|
||||
dispose: () => Promise<void>;
|
||||
|
||||
@@ -73,14 +73,14 @@ export const TableWhereFilter: PlaceholderComponent<ITableHeaderPlaceholderProps
|
||||
return;
|
||||
}
|
||||
|
||||
await model.requestDataAction(() =>
|
||||
constraints.deleteDataFilters()
|
||||
);
|
||||
await model.requestDataAction(async () => {
|
||||
constraints.deleteDataFilters();
|
||||
|
||||
const applyNeeded = !!model.requestInfo.requestFilter;
|
||||
if (applyNeeded) {
|
||||
await model.refresh();
|
||||
}
|
||||
const applyNeeded = !!model.requestInfo.requestFilter;
|
||||
if (applyNeeded) {
|
||||
await model.refresh(true);
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
|
||||
return styled(useStyles(styles))(
|
||||
|
||||
@@ -105,7 +105,7 @@ export class SqlQueryService {
|
||||
await model
|
||||
.setCountGain(getDefaultRowsCount())
|
||||
.setSlice(0)
|
||||
.requestData();
|
||||
.refresh();
|
||||
|
||||
this.sqlQueryResultService.updateGroupTabs(editorState, model, tabGroup.groupId);
|
||||
} catch (exception) {
|
||||
@@ -179,7 +179,7 @@ export class SqlQueryService {
|
||||
await model
|
||||
.setCountGain(getDefaultRowsCount())
|
||||
.setSlice(0)
|
||||
.requestData();
|
||||
.refresh();
|
||||
|
||||
statistics.executedQueries++;
|
||||
statistics.executeTime += source.requestInfo.requestDuration;
|
||||
|
||||
Reference in New Issue
Block a user