public inbox for [email protected]  
help / color / mirror / Atom feed
From: Rahul Shirsat <[email protected]>
To: Akshay Joshi <[email protected]>
Cc: pgadmin-hackers <[email protected]>
Subject: Re: [patch][pgAdmin] RM6744 Unable to delete rows for Enum type in Create Type dialogue
Date: Tue, 5 Oct 2021 16:12:13 +0530
Message-ID: <CAKtn9dOM9q_py2GXhfnbBFRyDz+Uok+YckJoqqwZdq7p2T6=-Q@mail.gmail.com> (raw)
In-Reply-To: <CANxoLDf=5hZtt3WvhEnNNDmiq155s+0aAxzdj-De1DFDkK_aKg@mail.gmail.com>
References: <CAKtn9dNS_sLM2VUr3Ea5uPH2Pn9JjpCA1UWHRrAhtv6zLqFHYg@mail.gmail.com>
	<CANxoLDdc-kod3WuyL-_P_8=TGNv-cqB-c=vsxMNqu4xQUj3pZg@mail.gmail.com>
	<CAKtn9dMxhneUpidx2DeXG_76vf=oOWHNz5uekBDiqNaFECeHbQ@mail.gmail.com>
	<CANxoLDexum5jPaYi6P6y7efXy-BPi7f96Wza=qCwNRtwQp2EpA@mail.gmail.com>
	<CAKtn9dOZBftTQNZ-YQB2R8u2hxLC8oXvE2TZwGAHNeh3a9GMOA@mail.gmail.com>
	<CANxoLDcqQOtfEouOBUqkJ7fmTNwEa4_-ZPSyNrrypndveCRFYA@mail.gmail.com>
	<CAKtn9dNL0ji2Vi+fTqxnf82BCHCkGQg4rrMyr4kQLVw7mpeWzw@mail.gmail.com>
	<CANxoLDf=5hZtt3WvhEnNNDmiq155s+0aAxzdj-De1DFDkK_aKg@mail.gmail.com>

Hi Hackers,

Please find the attached patch which resolves the issues sec label & type
changing issue.

Additionally, while testing the workflow, fixed one issue related to
composite type added with minimum one type and then changing the Type.

On Mon, Oct 4, 2021 at 7:41 PM Akshay Joshi <[email protected]>
wrote:

> Thanks, the patch applied.
>
> On Mon, Oct 4, 2021 at 6:34 PM Rahul Shirsat <
> [email protected]> wrote:
>
>> Hi Hackers,
>>
>> Please find the attached patch which resolves one more additional issue
>> reported by Aditya.
>>
>> On Thu, Sep 30, 2021 at 3:32 PM Akshay Joshi <
>> [email protected]> wrote:
>>
>>> Thanks, the patch applied.
>>>
>>> On Thu, Sep 30, 2021 at 1:46 PM Rahul Shirsat <
>>> [email protected]> wrote:
>>>
>>>> Hi Hackers,
>>>>
>>>> Please find the attached patch for fixing some additional issues.
>>>>
>>>> On Mon, Sep 20, 2021 at 1:13 PM Akshay Joshi <
>>>> [email protected]> wrote:
>>>>
>>>>> Thanks, the patch applied.
>>>>>
>>>>> On Mon, Sep 20, 2021 at 1:06 PM Rahul Shirsat <
>>>>> [email protected]> wrote:
>>>>>
>>>>>> Hi Akshay,
>>>>>>
>>>>>> Please find the updated patch.
>>>>>>
>>>>>> On Fri, Sep 17, 2021 at 8:55 PM Akshay Joshi <
>>>>>> [email protected]> wrote:
>>>>>>
>>>>>>> Hi Rahul
>>>>>>>
>>>>>>> Patch not applied, rebase and send the patch again.
>>>>>>>
>>>>>>> On Thu, Sep 16, 2021 at 6:39 PM Rahul Shirsat <
>>>>>>> [email protected]> wrote:
>>>>>>>
>>>>>>>> Hi Hackers,
>>>>>>>>
>>>>>>>> Please find the attached patch which resolves the below issue:
>>>>>>>>
>>>>>>>> 1. Enum Type - Unable to delete rows for Enum type in Create Type
>>>>>>>> dialogue.
>>>>>>>> 2. Range Type - Loading icons are shown in different drop down tabs.
>>>>>>>>
>>>>>>>> --
>>>>>>>> *Rahul Shirsat*
>>>>>>>> Senior Software Engineer | EnterpriseDB Corporation.
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> *Thanks & Regards*
>>>>>>> *Akshay Joshi*
>>>>>>> *pgAdmin Hacker | Principal Software Architect*
>>>>>>> *EDB Postgres <http://edbpostgres.com>*
>>>>>>>
>>>>>>> *Mobile: +91 976-788-8246*
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> *Rahul Shirsat*
>>>>>> Senior Software Engineer | EnterpriseDB Corporation.
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> *Thanks & Regards*
>>>>> *Akshay Joshi*
>>>>> *pgAdmin Hacker | Principal Software Architect*
>>>>> *EDB Postgres <http://edbpostgres.com>*
>>>>>
>>>>> *Mobile: +91 976-788-8246*
>>>>>
>>>>
>>>>
>>>> --
>>>> *Rahul Shirsat*
>>>> Senior Software Engineer | EnterpriseDB Corporation.
>>>>
>>>
>>>
>>> --
>>> *Thanks & Regards*
>>> *Akshay Joshi*
>>> *pgAdmin Hacker | Principal Software Architect*
>>> *EDB Postgres <http://edbpostgres.com>*
>>>
>>> *Mobile: +91 976-788-8246*
>>>
>>
>>
>> --
>> *Rahul Shirsat*
>> Senior Software Engineer | EnterpriseDB Corporation.
>>
>
>
> --
> *Thanks & Regards*
> *Akshay Joshi*
> *pgAdmin Hacker | Principal Software Architect*
> *EDB Postgres <http://edbpostgres.com>*
>
> *Mobile: +91 976-788-8246*
>


-- 
*Rahul Shirsat*
Senior Software Engineer | EnterpriseDB Corporation.


Attachments:

  [application/octet-stream] RM6744_v5.patch (3.8K, 3-RM6744_v5.patch)
  download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/static/js/type.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/static/js/type.ui.js
index bb9f82a7f..1cc3cde88 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/static/js/type.ui.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/static/js/type.ui.js
@@ -1040,21 +1040,24 @@ class CompositeSchema extends BaseUISchema {
 
   validate(state, setError) {
 
-    let errmsg = null;
-
-    if (isEmptyString(state.member_name)) {
-      errmsg = gettext('Please specify the value for member name.');
-      setError('member_name', errmsg);
-      return true;
-    } else if(isEmptyString(state.type)) {
-      errmsg = gettext('Please specify the type.');
-      setError('type', errmsg);
-      return true;
-    }
-    if(_.isUndefined(errmsg) || errmsg == null) {
+    let self = this,
       errmsg = null;
-      setError('member_name', errmsg);
-      setError('type', errmsg);
+
+    if(self.top && self.top.sessData && self.top.sessData.typtype === 'c') {
+      if (isEmptyString(state.member_name)) {
+        errmsg = gettext('Please specify the value for member name.');
+        setError('member_name', errmsg);
+        return true;
+      } else if(isEmptyString(state.type)) {
+        errmsg = gettext('Please specify the type.');
+        setError('type', errmsg);
+        return true;
+      }
+      if(_.isUndefined(errmsg) || errmsg == null) {
+        errmsg = null;
+        setError('member_name', errmsg);
+        setError('type', errmsg);
+      }
     }
     return false;
   }
@@ -1286,7 +1289,7 @@ export default class TypeSchema extends BaseUISchema {
       ...fieldOptions
     };
     this.getPrivilegeRoleSchema = getPrivilegeRoleSchema;
-    this.getCompositeSchema = getCompositeSchema;
+    this.compositeSchema = getCompositeSchema(); // create only once the composite schema to avoid initializing the current (i.e. top)
     this.getRangeSchema = getRangeSchema;
     this.getExternalSchema = getExternalSchema;
     this.getDataTypeSchema = getDataTypeSchema;
@@ -1409,8 +1412,13 @@ export default class TypeSchema extends BaseUISchema {
       uniqueCol : ['member_name'],
       canAdd: true,  canEdit: false, canDelete: true,
       disabled: () => obj.inCatalog(),
-      schema: obj.getCompositeSchema(),
+      schema: obj.compositeSchema,
       deps: ['typtype'],
+      depChange: (state)=>{
+        if(_.isArray(state.composite) && state.composite.length > 0 && state.typtype !== 'c') {
+          state.composite.splice(0, state.composite.length);
+        }
+      },
       visible: (state) => {
         return state.typtype === 'c';
       },
@@ -1658,7 +1666,7 @@ export default class TypeSchema extends BaseUISchema {
         if (state.typtype === 'p') {
           var secLabs = state.seclabels;
           if(secLabs && secLabs.length > 0)
-            secLabs.reset();
+            secLabs.splice(0, secLabs.length);
         }
         return (state.typtype !== 'p');
       },
diff --git a/web/regression/javascript/schema_ui_files/type.ui.spec.js b/web/regression/javascript/schema_ui_files/type.ui.spec.js
index 70188aca8..bb648780b 100644
--- a/web/regression/javascript/schema_ui_files/type.ui.spec.js
+++ b/web/regression/javascript/schema_ui_files/type.ui.spec.js
@@ -96,6 +96,9 @@ describe('TypeSchema', ()=>{
     it('composite validate', () => {
       let state = { typtype: 'b' }; //validating for ExternalSchema which is distinguish as r
       let setError = jasmine.createSpy('setError');
+      compositeCollObj.top = {
+        'sessData': { 'typtype':'c' }
+      };
 
       compositeCollObj.validate(state, setError);
       expect(setError).toHaveBeenCalledWith('member_name', 'Please specify the value for member name.');


view thread (10+ 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], [email protected]
  Subject: Re: [patch][pgAdmin] RM6744 Unable to delete rows for Enum type in Create Type dialogue
  In-Reply-To: <CAKtn9dOM9q_py2GXhfnbBFRyDz+Uok+YckJoqqwZdq7p2T6=-Q@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