mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-16 10:15:24 -06:00
1) Fixed an issue where the Save button is disabled due to the existing table check in ERD.
2) Fix warnings given by webpack.
This commit is contained in:
parent
88c0968cab
commit
3f563d8cbf
@ -324,7 +324,7 @@ $schemadiff-target-row-color: #fbe3bf !default;
|
|||||||
$schema-diff-color-fg: $input-color !default;
|
$schema-diff-color-fg: $input-color !default;
|
||||||
|
|
||||||
/* Custom controls bootstrap changes */
|
/* Custom controls bootstrap changes */
|
||||||
$custom-forms-transition: none !default;
|
$custom-forms-transition: none, none, none;
|
||||||
$custom-control-indicator-focus-border-color: $input-focus-border-color !default;
|
$custom-control-indicator-focus-border-color: $input-focus-border-color !default;
|
||||||
$custom-control-indicator-border-color: $input-border-color !default;
|
$custom-control-indicator-border-color: $input-border-color !default;
|
||||||
|
|
||||||
|
@ -176,8 +176,6 @@ $card-header-border-color: $card-header-bg;
|
|||||||
$card-border-color: transparent;
|
$card-border-color: transparent;
|
||||||
$card-bg: $color-gray;
|
$card-bg: $color-gray;
|
||||||
|
|
||||||
|
|
||||||
$custom-forms-transition: none;
|
|
||||||
$custom-control-indicator-focus-border-color: #FFFFFF !important;
|
$custom-control-indicator-focus-border-color: #FFFFFF !important;
|
||||||
$custom-control-indicator-border-color: $color-gray-lighter;
|
$custom-control-indicator-border-color: $color-gray-lighter;
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ export default class TableDialog {
|
|||||||
return 'entity_dialog';
|
return 'entity_dialog';
|
||||||
}
|
}
|
||||||
|
|
||||||
getDataModel(attributes, existingTables, colTypes, schemas, sVersion) {
|
getDataModel(attributes, isNew, allTables, colTypes, schemas, sVersion) {
|
||||||
let dialogObj = this;
|
let dialogObj = this;
|
||||||
let columnsModel = this.pgBrowser.DataModel.extend({
|
let columnsModel = this.pgBrowser.DataModel.extend({
|
||||||
idAttribute: 'attnum',
|
idAttribute: 'attnum',
|
||||||
@ -694,7 +694,11 @@ export default class TableDialog {
|
|||||||
msg = gettext('Table name cannot be empty.');
|
msg = gettext('Table name cannot be empty.');
|
||||||
this.errorModel.set('name', msg);
|
this.errorModel.set('name', msg);
|
||||||
return msg;
|
return msg;
|
||||||
} else if(_.findIndex(existingTables, (table)=>table[0]==schema&&table[1]==name) >= 0) {
|
}
|
||||||
|
|
||||||
|
/* Check existing table names */
|
||||||
|
let sameNameCount = _.filter(allTables, (table)=>table[0]==schema&&table[1]==name).length;
|
||||||
|
if(isNew && this.sessAttrs['name'] && sameNameCount > 0 || isNew && sameNameCount > 0) {
|
||||||
msg = gettext('Table name already exists.');
|
msg = gettext('Table name already exists.');
|
||||||
this.errorModel.set('name', msg);
|
this.errorModel.set('name', msg);
|
||||||
return msg;
|
return msg;
|
||||||
@ -737,9 +741,9 @@ export default class TableDialog {
|
|||||||
return Alertify[dialogName];
|
return Alertify[dialogName];
|
||||||
}
|
}
|
||||||
|
|
||||||
show(title, attributes, existingTables, colTypes, schemas, sVersion, callback) {
|
show(title, attributes, isNew, allTables, colTypes, schemas, sVersion, callback) {
|
||||||
let dialogTitle = title || gettext('Unknown');
|
let dialogTitle = title || gettext('Unknown');
|
||||||
const dialog = this.createOrGetDialog('table_dialog');
|
const dialog = this.createOrGetDialog('table_dialog');
|
||||||
dialog(dialogTitle, this.getDataModel(attributes, existingTables, colTypes, schemas, sVersion), callback).resizeTo(this.pgBrowser.stdW.md, this.pgBrowser.stdH.md);
|
dialog(dialogTitle, this.getDataModel(attributes, isNew, allTables, colTypes, schemas, sVersion), callback).resizeTo(this.pgBrowser.stdW.md, this.pgBrowser.stdH.md);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -301,12 +301,12 @@ export default class BodyWidget extends React.Component {
|
|||||||
|
|
||||||
getDialog(dialogName) {
|
getDialog(dialogName) {
|
||||||
if(dialogName === 'entity_dialog') {
|
if(dialogName === 'entity_dialog') {
|
||||||
let existingTables = this.diagram.getModel().getNodes().map((node)=>{
|
let allTables = this.diagram.getModel().getNodes().map((node)=>{
|
||||||
return node.getSchemaTableName();
|
return node.getSchemaTableName();
|
||||||
});
|
});
|
||||||
return (title, attributes, callback)=>{
|
return (title, attributes, isNew, callback)=>{
|
||||||
this.props.getDialog(dialogName).show(
|
this.props.getDialog(dialogName).show(
|
||||||
title, attributes, existingTables, this.diagram.getCache('colTypes'), this.diagram.getCache('schemas'), this.state.server_version, callback
|
title, attributes, isNew, allTables, this.diagram.getCache('colTypes'), this.diagram.getCache('schemas'), this.state.server_version, callback
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
} else if(dialogName === 'onetomany_dialog' || dialogName === 'manytomany_dialog') {
|
} else if(dialogName === 'onetomany_dialog' || dialogName === 'manytomany_dialog') {
|
||||||
@ -335,12 +335,12 @@ export default class BodyWidget extends React.Component {
|
|||||||
let dialog = this.getDialog('entity_dialog');
|
let dialog = this.getDialog('entity_dialog');
|
||||||
if(node) {
|
if(node) {
|
||||||
let [schema, table] = node.getSchemaTableName();
|
let [schema, table] = node.getSchemaTableName();
|
||||||
dialog(_.escape(`Table: ${table} (${schema})`), node.getData(), (newData)=>{
|
dialog(_.escape(`Table: ${table} (${schema})`), node.getData(), false, (newData)=>{
|
||||||
node.setData(newData);
|
node.setData(newData);
|
||||||
this.diagram.repaint();
|
this.diagram.repaint();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
dialog('New table', {name: this.diagram.getNextTableName()}, (newData)=>{
|
dialog('New table', {name: this.diagram.getNextTableName()}, true, (newData)=>{
|
||||||
let newNode = this.diagram.addNode(newData);
|
let newNode = this.diagram.addNode(newData);
|
||||||
newNode.setSelected(true);
|
newNode.setSelected(true);
|
||||||
});
|
});
|
||||||
|
@ -252,7 +252,7 @@ describe('ERD BodyWidget', ()=>{
|
|||||||
bodyInstance.addEditNode();
|
bodyInstance.addEditNode();
|
||||||
expect(tableDialog.show).toHaveBeenCalled();
|
expect(tableDialog.show).toHaveBeenCalled();
|
||||||
|
|
||||||
let saveCallback = tableDialog.show.calls.mostRecent().args[6];
|
let saveCallback = tableDialog.show.calls.mostRecent().args[7];
|
||||||
let newData = {key: 'value'};
|
let newData = {key: 'value'};
|
||||||
saveCallback(newData);
|
saveCallback(newData);
|
||||||
expect(bodyInstance.diagram.addNode).toHaveBeenCalledWith(newData);
|
expect(bodyInstance.diagram.addNode).toHaveBeenCalledWith(newData);
|
||||||
@ -267,7 +267,7 @@ describe('ERD BodyWidget', ()=>{
|
|||||||
bodyInstance.addEditNode(node);
|
bodyInstance.addEditNode(node);
|
||||||
expect(tableDialog.show).toHaveBeenCalled();
|
expect(tableDialog.show).toHaveBeenCalled();
|
||||||
|
|
||||||
saveCallback = tableDialog.show.calls.mostRecent().args[6];
|
saveCallback = tableDialog.show.calls.mostRecent().args[7];
|
||||||
newData = {key: 'value'};
|
newData = {key: 'value'};
|
||||||
saveCallback(newData);
|
saveCallback(newData);
|
||||||
expect(node.setData).toHaveBeenCalledWith(newData);
|
expect(node.setData).toHaveBeenCalledWith(newData);
|
||||||
|
Loading…
Reference in New Issue
Block a user