mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-11-25 18:20:20 -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;
|
||||
|
||||
/* 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-border-color: $input-border-color !default;
|
||||
|
||||
|
@ -176,8 +176,6 @@ $card-header-border-color: $card-header-bg;
|
||||
$card-border-color: transparent;
|
||||
$card-bg: $color-gray;
|
||||
|
||||
|
||||
$custom-forms-transition: none;
|
||||
$custom-control-indicator-focus-border-color: #FFFFFF !important;
|
||||
$custom-control-indicator-border-color: $color-gray-lighter;
|
||||
|
||||
|
@ -50,7 +50,7 @@ export default class TableDialog {
|
||||
return 'entity_dialog';
|
||||
}
|
||||
|
||||
getDataModel(attributes, existingTables, colTypes, schemas, sVersion) {
|
||||
getDataModel(attributes, isNew, allTables, colTypes, schemas, sVersion) {
|
||||
let dialogObj = this;
|
||||
let columnsModel = this.pgBrowser.DataModel.extend({
|
||||
idAttribute: 'attnum',
|
||||
@ -694,7 +694,11 @@ export default class TableDialog {
|
||||
msg = gettext('Table name cannot be empty.');
|
||||
this.errorModel.set('name', 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.');
|
||||
this.errorModel.set('name', msg);
|
||||
return msg;
|
||||
@ -737,9 +741,9 @@ export default class TableDialog {
|
||||
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');
|
||||
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) {
|
||||
if(dialogName === 'entity_dialog') {
|
||||
let existingTables = this.diagram.getModel().getNodes().map((node)=>{
|
||||
let allTables = this.diagram.getModel().getNodes().map((node)=>{
|
||||
return node.getSchemaTableName();
|
||||
});
|
||||
return (title, attributes, callback)=>{
|
||||
return (title, attributes, isNew, callback)=>{
|
||||
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') {
|
||||
@ -335,12 +335,12 @@ export default class BodyWidget extends React.Component {
|
||||
let dialog = this.getDialog('entity_dialog');
|
||||
if(node) {
|
||||
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);
|
||||
this.diagram.repaint();
|
||||
});
|
||||
} else {
|
||||
dialog('New table', {name: this.diagram.getNextTableName()}, (newData)=>{
|
||||
dialog('New table', {name: this.diagram.getNextTableName()}, true, (newData)=>{
|
||||
let newNode = this.diagram.addNode(newData);
|
||||
newNode.setSelected(true);
|
||||
});
|
||||
|
@ -252,7 +252,7 @@ describe('ERD BodyWidget', ()=>{
|
||||
bodyInstance.addEditNode();
|
||||
expect(tableDialog.show).toHaveBeenCalled();
|
||||
|
||||
let saveCallback = tableDialog.show.calls.mostRecent().args[6];
|
||||
let saveCallback = tableDialog.show.calls.mostRecent().args[7];
|
||||
let newData = {key: 'value'};
|
||||
saveCallback(newData);
|
||||
expect(bodyInstance.diagram.addNode).toHaveBeenCalledWith(newData);
|
||||
@ -267,7 +267,7 @@ describe('ERD BodyWidget', ()=>{
|
||||
bodyInstance.addEditNode(node);
|
||||
expect(tableDialog.show).toHaveBeenCalled();
|
||||
|
||||
saveCallback = tableDialog.show.calls.mostRecent().args[6];
|
||||
saveCallback = tableDialog.show.calls.mostRecent().args[7];
|
||||
newData = {key: 'value'};
|
||||
saveCallback(newData);
|
||||
expect(node.setData).toHaveBeenCalledWith(newData);
|
||||
|
Loading…
Reference in New Issue
Block a user