mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
fix(core-blocks): CB-399 PropertiesTable value's jumping
This commit is contained in:
@@ -12,6 +12,8 @@ export interface IProperty {
|
||||
displayName?: string;
|
||||
defaultValue?: string;
|
||||
description?: string;
|
||||
keyPlaceholder?: string;
|
||||
valuePlaceholder?: string;
|
||||
validValues?: string[];
|
||||
new?: boolean;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,9 @@ export const PropertiesTable = observer(function PropertiesTable({
|
||||
return;
|
||||
}
|
||||
|
||||
if (state[property.key] !== undefined) {
|
||||
const isUnique = properties.filter(({ key }) => key === property.key).length === 1;
|
||||
|
||||
if (state[property.key] !== undefined && isUnique) {
|
||||
state[key] = state[property.key];
|
||||
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
||||
delete state[property.key];
|
||||
|
||||
@@ -146,6 +146,7 @@ export const PropertyItem = observer(function PropertyItem({
|
||||
ref={keyInputRef}
|
||||
type='text'
|
||||
name={property.id}
|
||||
placeholder={property.keyPlaceholder}
|
||||
readOnly={!isKeyEditable}
|
||||
autoComplete='none'
|
||||
onChange={handleKeyChange}
|
||||
@@ -157,6 +158,7 @@ export const PropertyItem = observer(function PropertyItem({
|
||||
<ShadowInput
|
||||
type='text'
|
||||
name={`${property.id}_value`}
|
||||
placeholder={property.valuePlaceholder}
|
||||
autoComplete='none'
|
||||
onChange={handleValueChange}
|
||||
{...use({ focus, edited })}
|
||||
|
||||
+5
-2
@@ -47,8 +47,9 @@ export class DriverPropertiesController implements IInitializableController {
|
||||
addProperty = (key?: string, value?: string) => {
|
||||
this.driverProperties.unshift({
|
||||
id: uuid(),
|
||||
key: key ?? 'property',
|
||||
key: key ?? '',
|
||||
defaultValue: value ?? '',
|
||||
keyPlaceholder: 'property',
|
||||
new: !key,
|
||||
});
|
||||
};
|
||||
@@ -60,10 +61,12 @@ export class DriverPropertiesController implements IInitializableController {
|
||||
this.isLoading = true;
|
||||
try {
|
||||
const driverProperties = await this.driverPropertiesService.loadDriverProperties(this.driverId);
|
||||
this.driverProperties = observable(driverProperties.map(property => ({
|
||||
this.driverProperties = observable(driverProperties.map<IProperty>(property => ({
|
||||
id: property.id!,
|
||||
key: property.id!,
|
||||
keyPlaceholder: property.id,
|
||||
displayName: property.displayName,
|
||||
valuePlaceholder: property.defaultValue,
|
||||
defaultValue: property.defaultValue,
|
||||
description: property.description,
|
||||
validValues: property.validValues,
|
||||
|
||||
+4
-2
@@ -49,7 +49,8 @@ export class DriverPropertiesController implements IInitializableController {
|
||||
addProperty = (key?: string, value?: string) => {
|
||||
this.driverProperties.unshift({
|
||||
id: uuid(),
|
||||
key: key ?? 'property',
|
||||
key: key ?? '',
|
||||
keyPlaceholder: 'property',
|
||||
defaultValue: value ?? '',
|
||||
new: !key,
|
||||
});
|
||||
@@ -62,11 +63,12 @@ export class DriverPropertiesController implements IInitializableController {
|
||||
this.isLoading = true;
|
||||
try {
|
||||
const driverProperties = await this.driverPropertiesService.loadDriverProperties(this.driver.id);
|
||||
this.driverProperties = observable(driverProperties.map(property => ({
|
||||
this.driverProperties = observable(driverProperties.map<IProperty>(property => ({
|
||||
id: property.id!,
|
||||
key: property.id!,
|
||||
displayName: property.displayName!,
|
||||
defaultValue: property.defaultValue,
|
||||
valuePlaceholder: property.defaultValue,
|
||||
description: property.description,
|
||||
validValues: property.validValues,
|
||||
})));
|
||||
|
||||
@@ -101,13 +101,14 @@ export class DataExportController implements IInitializableController, IDestruct
|
||||
.data
|
||||
.get(processorId)!;
|
||||
|
||||
this.properties = this.processor.properties?.map(property => ({
|
||||
this.properties = this.processor.properties?.map<IProperty>(property => ({
|
||||
id: property.id!,
|
||||
key: property.id!,
|
||||
displayName: property.displayName!,
|
||||
displayName: property.displayName,
|
||||
description: property.description,
|
||||
validValues: property.validValues,
|
||||
defaultValue: property.defaultValue,
|
||||
valuePlaceholder: property.defaultValue,
|
||||
})) || [];
|
||||
|
||||
this.processorProperties = {};
|
||||
|
||||
Reference in New Issue
Block a user