[Patch]: RM-4644 - Length and Precision control for domain node

Neel Patel <[email protected]> Wed, 21 Aug 2019 12:48:46 +0530
Newsgroups gmane.comp.db.postgresql.pgadmin.devel
Message-ID <CACCA4P1kBP7iY4kWc=-UcsAZR03qvhpinsWhC7j8NijCs0nbWg@mail.gmail.com>
Hi,

Please find attached patch to fix RM-4644 - Length and Precision control
should enable/disable based on change in data type.

Do review it and let me know for comment.

Thanks,
Neel Patel
RM-4644.patch (application/octet-stream, 1.8 KB)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/static/js/domain.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/static/js/domain.js
index 8fa1c36b5..dbb9591d3 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/static/js/domain.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/static/js/domain.js
@@ -204,6 +204,7 @@ define('pgadmin.node.domain', [
               return true;
             }
             var of_type = m.get('basetype');
+
             if(m.type_options) {
               // iterating over all the types
               _.each(m.type_options, function(o) {
@@ -217,8 +218,16 @@ define('pgadmin.node.domain', [
                     m.set('min_val', o.min_val, {silent: true});
                     m.set('max_val', o.max_val, {silent: true});
                   }
+                  else
+                    m.set('is_tlength', false, {silent: true});
                 }
               });
+
+              !m.get('is_tlength') && setTimeout(function() {
+                if(m.get('typlen')) {
+                  m.set('typlen', null);
+                }
+              },10);
             }
             return !m.get('is_tlength');
           },
@@ -244,8 +253,16 @@ define('pgadmin.node.domain', [
                     m.set('min_val', o.min_val, {silent: true});
                     m.set('max_val', o.max_val, {silent: true});
                   }
+                  else
+                    m.set('is_precision', false, {silent: true});
                 }
               });
+
+              !m.get('is_precision') && setTimeout(function() {
+                if(m.get('precision')) {
+                  m.set('precision', null);
+                }
+              },10);
             }
             return !m.get('is_precision');
           },