Skip to content

Commit

Permalink
Enhance code
Browse files Browse the repository at this point in the history
  • Loading branch information
nestorip committed Mar 9, 2021
1 parent f3030bd commit 85060aa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 5 additions & 6 deletions actions/api_cf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3109,6 +3109,10 @@ def get_catalog(self, form_name, table_name, feature_type, feature_id, field_id,
def set_catalog(self, dialog, form_name, table_name, feature_id, id_name):
""" Insert table 'cat_work'. Add cat_work """

# Form handling so that the user cannot change values until the process is finished
self.dlg_cf.setEnabled(False)
self.controller.notify.task_finished.connect(self._enable_dialog)

# Manage mandatory fields
missing_mandatory = False
widgets = dialog.findChildren(QWidget)
Expand All @@ -3121,11 +3125,9 @@ def set_catalog(self, dialog, form_name, table_name, feature_id, id_name):
if missing_mandatory:
message = "Mandatory field is missing. Please, set a value"
self.controller.show_warning(message)
self._enable_dialog()
return

# Form handling so that the user cannot change values until the process is finished
self.controller.notify.task_start.connect(lambda: self.dlg_cf.setEnabled(False))
self.controller.notify.task_finished.connect(self._enable_dialog)

# Get widgets values
values = {}
Expand All @@ -3134,8 +3136,6 @@ def set_catalog(self, dialog, form_name, table_name, feature_id, id_name):
values = self.get_values(dialog, widget, values)
fields = json.dumps(values)



# Call gw_fct_setcatalog
fields = f'"fields":{fields}'
form = f'"formName":"{form_name}"'
Expand Down Expand Up @@ -3163,7 +3163,6 @@ def set_catalog(self, dialog, form_name, table_name, feature_id, id_name):

def _enable_dialog(self):
self.dlg_cf.setEnabled(True)
self.controller.notify.task_start.disconnect()
self.controller.notify.task_finished.disconnect()


Expand Down
2 changes: 2 additions & 0 deletions actions/notify_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class NotifyFunctions(ParentAction, QObject):
list_channels = None
task_start = pyqtSignal()
task_finished = pyqtSignal()


def __init__(self, iface, settings, controller, plugin_dir):
""" Class to control notify from PostgresSql """

Expand Down

0 comments on commit 85060aa

Please sign in to comment.