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: Thu, 30 Sep 2021 13:45:28 +0530
Message-ID: <CAKtn9dOZBftTQNZ-YQB2R8u2hxLC8oXvE2TZwGAHNeh3a9GMOA@mail.gmail.com> (raw)
In-Reply-To: <CANxoLDexum5jPaYi6P6y7efXy-BPi7f96Wza=qCwNRtwQp2EpA@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>

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.


Attachments:

  [application/octet-stream] RM6744_v3.patch (7.9K, 3-RM6744_v3.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 bf8ba3d54..14e385f76 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
@@ -14,7 +14,7 @@ import SecLabelSchema from '../../../../../static/js/sec_label.ui';
 import { getNodeAjaxOptions } from '../../../../../../../static/js/node_ajax';
 import _ from 'underscore';
 import getApiInstance from 'sources/api_instance';
-import { isEmptyString, integerValidator } from 'sources/validators';
+import { isEmptyString } from 'sources/validators';
 
 
 function getCompositeSchema(nodeObj, treeNodeInfo, itemNodeData) {
@@ -69,9 +69,9 @@ function getRangeSchema(nodeObj, treeNodeInfo, itemNodeData) {
               null, 'get_canonical', itemNodeData, false,
               treeNodeInfo,
             ]);
-          var data;
+          var data = [];
 
-          if(!_.isUndefined(name) && name != ''){
+          if(!_.isUndefined(name) && name != '' && name != null){
             api.get(_url, {
               params: {
                 'name' : name
@@ -1051,35 +1051,10 @@ class CompositeSchema extends BaseUISchema {
       setError('type', errmsg);
       return true;
     }
-    if(state.is_tlength) {
-
-      if (state.tlength < state.min_val) {
-        errmsg = gettext('Length/Precision should not be less than %s.', state.min_val);
-      }
-      else if (state.tlength > state.max_val) {
-        errmsg = gettext('Length/Precision should not be greater than %s.', state.max_val);
-      }
-      if(_.isUndefined(errmsg) || errmsg == null)
-        errmsg = integerValidator('Length/Precision', state.tlength);
-      // If we have any error set then throw it to user
-      if(!_.isUndefined(errmsg) && errmsg != null) {
-        setError('tlength', errmsg);
-        return true;
-      }
-    }
-    if(state.is_precision) {
-      errmsg = integerValidator('Scale', state.precision);
-      if(!_.isUndefined(errmsg) && errmsg != null) {
-        setError('precision', errmsg);
-        return true;
-      }
-    }
     if(_.isUndefined(errmsg) || errmsg == null) {
       errmsg = null;
       setError('member_name', errmsg);
       setError('type', errmsg);
-      setError('tlength', errmsg);
-      setError('precision', errmsg);
     }
     return false;
   }
@@ -1122,7 +1097,7 @@ class DataTypeSchema extends BaseUISchema {
       id: 'type',
       label: gettext('Data Type'),
       group: gettext('Definition'),
-      mode: ['edit', 'create','properties'],
+      mode: ['edit', 'create'],
       disabled: false,
       readonly: function (state) {
         return !dataTypeObj.isNew(state);
@@ -1158,7 +1133,7 @@ class DataTypeSchema extends BaseUISchema {
       type: 'int',
       deps: ['typtype'],
       cell: 'int',
-      mode: ['create', 'edit','properties'],
+      mode: ['create', 'edit'],
       readonly: function (state) {
         return !dataTypeObj.isNew(state);
       },
@@ -1172,7 +1147,7 @@ class DataTypeSchema extends BaseUISchema {
       id: 'tlength',
       group: gettext('Data Type'),
       label: gettext('Length/Precision'),
-      mode: ['edit', 'create','properties'],
+      mode: ['edit', 'create'],
       deps: ['type'],
       type: 'text',
       cell: 'int',
@@ -1234,7 +1209,7 @@ class DataTypeSchema extends BaseUISchema {
       id: 'precision',
       group: gettext('Data Type'),
       label: gettext('Scale'),
-      mode: ['edit', 'create','properties'],
+      mode: ['edit', 'create'],
       deps: ['type'],
       type: 'text',
       readonly: function (state) {
@@ -1465,7 +1440,7 @@ export default class TypeSchema extends BaseUISchema {
       group: gettext('Definition'),
       label: '',
       deps: ['typtype'],
-      mode: ['edit', 'create', 'properties'],
+      mode: ['edit', 'create'],
       visible: function(state) {
         return state.typtype === 'N' || state.typtype === 'V';
       },
@@ -1594,6 +1569,50 @@ export default class TypeSchema extends BaseUISchema {
         return false;
       },
     },
+    {
+      id: 'type', label: gettext('Data Type'), cell: 'string',
+      type: 'text', mode: ['properties'], group: gettext('Definition'),
+      disabled: () => obj.inCatalog(),
+      visible: function(state) {
+        if(state.typtype === 'N' || state.typtype === 'V') {
+          return true;
+        }
+        return false;
+      }
+    },
+    {
+      id: 'tlength', label: gettext('Length/Precision'), cell: 'string',
+      type: 'text', mode: ['properties'], group: gettext('Definition'),
+      disabled: () => obj.inCatalog(),
+      visible: function(state) {
+        if(state.typtype === 'N') {
+          return true;
+        }
+        return false;
+      }
+    },
+    {
+      id: 'precision', label: gettext('Scale'), cell: 'string',
+      type: 'text', mode: ['properties'], group: gettext('Definition'),
+      disabled: () => obj.inCatalog(),
+      visible: function(state) {
+        if(state.typtype === 'N') {
+          return true;
+        }
+        return false;
+      }
+    },
+    {
+      id: 'maxsize', label: gettext('Size'), cell: 'string',
+      type: 'text', mode: ['properties'], group: gettext('Definition'),
+      disabled: () => obj.inCatalog(),
+      visible: function(state) {
+        if(state.typtype === 'V') {
+          return true;
+        }
+        return false;
+      }
+    },
     {
       id: 'type_acl', label: gettext('Privileges'), cell: 'string',
       type: 'text', mode: ['properties'], group: gettext('Security'),
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 33998f09a..70188aca8 100644
--- a/web/regression/javascript/schema_ui_files/type.ui.spec.js
+++ b/web/regression/javascript/schema_ui_files/type.ui.spec.js
@@ -15,8 +15,6 @@ import {messages} from '../fake_messages';
 import { createMount } from '@material-ui/core/test-utils';
 import SchemaView from '../../../pgadmin/static/js/SchemaView';
 import * as nodeAjax from '../../../pgadmin/browser/static/js/node_ajax';
-import gettext from 'sources/gettext';
-import { integerValidator } from 'sources/validators';
 import { getNodePrivilegeRoleSchema } from '../../../pgadmin/browser/server_groups/servers/static/js/privilege.ui';
 
 import TypeSchema, { EnumerationSchema, getCompositeSchema, getExternalSchema, getRangeSchema, getDataTypeSchema } from '../../../pgadmin/browser/server_groups/servers/databases/schemas/types/static/js/type.ui';
@@ -105,32 +103,6 @@ describe('TypeSchema', ()=>{
       state.member_name = 'demo_member';
       compositeCollObj.validate(state, setError);
       expect(setError).toHaveBeenCalledWith('type', 'Please specify the type.');
-
-      state.type = 'char';
-      state.min_val = 10;
-      state.max_val = 100;
-      state.is_tlength = true;
-      state.tlength = 9;
-      compositeCollObj.validate(state, setError);
-      expect(setError).toHaveBeenCalledWith('tlength', gettext('Length/Precision should not be less than %s.', state.min_val));
-
-      state.tlength = 200;
-      compositeCollObj.validate(state, setError);
-      expect(setError).toHaveBeenCalledWith('tlength', gettext('Length/Precision should not be greater than %s.', state.max_val));
-
-      state.tlength = 'ert';
-      compositeCollObj.validate(state, setError);
-      expect(setError).toHaveBeenCalledWith('tlength', integerValidator('Length/Precision', state.tlength));
-
-      state.tlength = 90;
-      state.is_precision = true;
-      state.precision = 'ert';
-      compositeCollObj.validate(state, setError);
-      expect(setError).toHaveBeenCalledWith('precision', integerValidator('Scale', state.precision));
-
-      state.precision = 9;
-      compositeCollObj.validate(state, setError);
-      expect(setError).toHaveBeenCalled();
     });
 
     it('tlength editable', ()=>{


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: <CAKtn9dOZBftTQNZ-YQB2R8u2hxLC8oXvE2TZwGAHNeh3a9GMOA@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