public inbox for [email protected]  
help / color / mirror / Atom feed
[pgAdmin][RM-6906]: Referenced Table drop down should be disabled in foreign Key > Columns after one row added.
2+ messages / 2 participants
[nested] [flat]

* [pgAdmin][RM-6906]: Referenced Table drop down should be disabled in foreign Key > Columns after one row added.
@ 2021-11-16 04:15 Nikhil Mohite <[email protected]>
  2021-11-18 07:07 ` Re: [pgAdmin][RM-6906]: Referenced Table drop down should be disabled in foreign Key > Columns after one row added. Akshay Joshi <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Nikhil Mohite @ 2021-11-16 04:15 UTC (permalink / raw)
  To: pgadmin-hackers

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};
       },
     },{


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: [pgAdmin][RM-6906]: Referenced Table drop down should be disabled in foreign Key > Columns after one row added.
  2021-11-16 04:15 [pgAdmin][RM-6906]: Referenced Table drop down should be disabled in foreign Key > Columns after one row added. Nikhil Mohite <[email protected]>
@ 2021-11-18 07:07 ` Akshay Joshi <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Akshay Joshi @ 2021-11-18 07:07 UTC (permalink / raw)
  To: Nikhil Mohite <[email protected]>; +Cc: pgadmin-hackers

Thanks, the patch applied.

On Tue, Nov 16, 2021 at 9:45 AM Nikhil Mohite <
[email protected]> wrote:

> 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.*
>


-- 
*Thanks & Regards*
*Akshay Joshi*
*pgAdmin Hacker | Principal Software Architect*
*EDB Postgres <http://edbpostgres.com>*

*Mobile: +91 976-788-8246*


^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2021-11-18 07:07 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-11-16 04:15 [pgAdmin][RM-6906]: Referenced Table drop down should be disabled in foreign Key > Columns after one row added. Nikhil Mohite <[email protected]>
2021-11-18 07:07 ` Akshay Joshi <[email protected]>

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