Skip to content

Commit

Permalink
fix hiding/unhiding fields based on DSN and database type
Browse files Browse the repository at this point in the history
  • Loading branch information
thorstenkampe committed Oct 14, 2021
1 parent d4c5398 commit 69cbf66
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Binary file modified sql shell.exe
Binary file not shown.
19 changes: 12 additions & 7 deletions sql shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,18 @@ def create(self):
self.passwd = self.add(TitlePassword, name='- Password:', value=None, **widget_defaults)

def adjust_widgets(self):
# hide host, port, database, user, and password field if DSN selected
for field in self.host, self.port, self.db, self.user, self.passwd:
field.hidden = self.dsn.value
field.hidden = False

# hide host, port, database, user, and password field if DSN selected
if self.dsn.value:
for field in self.host, self.port, self.db, self.user, self.passwd:
field.hidden = True

# disable editing host, port, user, and password field if SQLite selected
elif self.dbtype.value == 5:
for field in self.host, self.port, self.user, self.passwd:
field.hidden = True

try: # try to set database type field to database type from DSN label
# ['...', '1. MSSQL: name = arguments', '2. <...>'] -> '1. MSSQL: name' ->
Expand All @@ -93,10 +102,6 @@ def adjust_widgets(self):
# field
self.dbtype.editable = False

# disable editing host, port, user, and password field if SQLite selected
for field in self.host, self.port, self.user, self.passwd:
field.editable = self.dbtype.value != 5 # `5` is SQLite

self.display()

def on_cancel(self):
Expand All @@ -108,7 +113,7 @@ def on_ok(self): # NOSONAR
notify_confirm('Database type is mandatory!', title='ERROR', editw=True)
return

if not (self.user.value or self.dbtype.value == 5): # `5` is SQLite
if not (self.user.value or self.dsn.value or self.dbtype.value == 5): # `5` is SQLite
notify_confirm('User is mandatory!', title='ERROR', editw=True)
return

Expand Down

0 comments on commit 69cbf66

Please sign in to comment.