public inbox for [email protected]  
help / color / mirror / Atom feed
From: Nikhil Mohite <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: [pgAdmin][RM-6906]: Referenced Table drop down should be disabled in foreign Key > Columns after one row added.
Date: Tue, 16 Nov 2021 09:45:12 +0530
Message-ID: <CAOBg0AMODmy4AHMjDwO8OsXQ1j6iaF8xgYijGhWYaAQDbRG7HQ@mail.gmail.com> (raw)

Hi Hackers,

Please find the attached patch for RM-6906:
<https://redmine.postgresql.org/issues/6906; Referenced Table drop-down
should be disabled in foreign Key > Columns after one row is added.


-- 
*Thanks & Regards,*
*Nikhil Mohite*
*Senior Software Engineer.*
*EDB Postgres* <https://www.enterprisedb.com/;
*Mob.No: +91-7798364578.*


Attachments:

  [application/x-patch] RM-6906.patch (2.7K, 3-RM-6906.patch)
  download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/static/js/foreign_key.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/static/js/foreign_key.ui.js
index 4aae23bd..7cfd3b5d 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/static/js/foreign_key.ui.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/static/js/foreign_key.ui.js
@@ -37,6 +37,7 @@ class ForeignKeyHeaderSchema extends BaseUISchema {
       local_column: undefined,
       references: undefined,
       referenced: undefined,
+      _disable_references: false,
     });
 
     this.fieldOptions = fieldOptions;
@@ -48,12 +49,12 @@ class ForeignKeyHeaderSchema extends BaseUISchema {
   }
 
   addDisabled(state) {
-    return !(state.local_column && state.references && state.referenced);
+    return !(state.local_column && (state.references || this.origData.references) && state.referenced);
   }
 
   /* Data to ForeignKeyColumnSchema will added using the header form */
   getNewData(data) {
-    let references_table_name = _.find(this.refTables, (t)=>t.value==data.references)?.label;
+    let references_table_name = _.find(this.refTables, (t)=>t.value==data.references || t.value == this.origData.references)?.label;
     return {
       local_column: data.local_column,
       referenced: data.referenced,
@@ -73,6 +74,9 @@ class ForeignKeyHeaderSchema extends BaseUISchema {
       options: this.fieldOptions.references,
       optionsReloadBasis: this.fieldOptions.references?.map ? _.join(this.fieldOptions.references.map((c)=>c.label), ',') : null,
       optionsLoaded: (rows)=>obj.refTables=rows,
+      disabled: (state) => {
+        return state._disable_references ? true : false;
+      }
     },{
       id: 'referenced', label: gettext('Referencing'), editable: false, deps: ['references'],
       type: (state)=>{
@@ -82,6 +86,9 @@ class ForeignKeyHeaderSchema extends BaseUISchema {
           optionsReloadBasis: state.references,
         };
       },
+    },
+    {
+      id: '_disable_references', label: '', type: 'switch', visible: false
     }];
   }
 }
@@ -358,6 +365,12 @@ export default class ForeignKeySchema extends BaseUISchema {
             }
           }
         }
+        if(actionObj.type == SCHEMA_STATE_ACTIONS.ADD_ROW) {
+          obj.fkHeaderSchema.origData.references = null;
+          // Set references value.
+          obj.fkHeaderSchema.origData.references = obj.fkHeaderSchema.sessData.references;
+          obj.fkHeaderSchema.origData._disable_references = true;
+        }
         return {columns: currColumns};
       },
     },{


view thread (2+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: [pgAdmin][RM-6906]: Referenced Table drop down should be disabled in foreign Key > Columns after one row added.
  In-Reply-To: <CAOBg0AMODmy4AHMjDwO8OsXQ1j6iaF8xgYijGhWYaAQDbRG7HQ@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox