From 85060aa973403f9da65808cf7340e55d3ab87a9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9stor=20Ib=C3=A1=C3=B1ez?= Date: Tue, 9 Mar 2021 13:06:12 +0100 Subject: [PATCH] Enhance code --- actions/api_cf.py | 11 +++++------ actions/notify_functions.py | 2 ++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/actions/api_cf.py b/actions/api_cf.py index b1ce3afbe..e40793313 100644 --- a/actions/api_cf.py +++ b/actions/api_cf.py @@ -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) @@ -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 = {} @@ -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}"' @@ -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() diff --git a/actions/notify_functions.py b/actions/notify_functions.py index d2d29fea8..2fec1aaee 100644 --- a/actions/notify_functions.py +++ b/actions/notify_functions.py @@ -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 """