Feat(SQL, UI): 1. Perfected architecture for modular Search functionality across heirarchical Get Many and Calc Stored Procedures that allows text search filtering on different fields as well as by record Id with control over how the filters are applied. \n 2. Updated User Calc and Get Many Stored Procedures with new Search functionality. \n 3. Improved styles on Dog Command Link page.

This commit is contained in:
2025-07-05 23:17:07 +01:00
parent 0d1e644e6c
commit 8cb8508dcd
51 changed files with 4161 additions and 1292 deletions

View File

@@ -41,13 +41,15 @@ class Command(SQLAlchemy_ABC, Base):
def __init__(self):
self.id_command = 0
self.command_category = None
self.is_new = False
self.has_button = False
super().__init__()
def from_db_command(query_row):
_m = 'Command.from_db_command'
command = Command()
@classmethod
def from_db_command(cls, query_row):
_m = f'{cls.__qualname__}.from_db_command'
command = cls()
command.id_command = query_row[0]
command.id_command_category = query_row[1]
command.name = query_row[2]
@@ -59,25 +61,27 @@ class Command(SQLAlchemy_ABC, Base):
# command.created_on = query_row[7]
return command
def from_db_dog_command_link(query_row):
_m = 'Command.from_db_dog_command_link'
command = Command()
@classmethod
def from_db_dog_command_link(cls, query_row):
_m = f'{cls.__qualname__}.from_db_dog_command_link'
command = cls()
command.id_command = query_row[5]
command.id_command_category = query_row[3]
command.name = query_row[6]
# command.hand_signal_default_description = query_row[2]
# command.can_have_button = av.input_bool(query_row[5], 'can_have_button', _m)
command.has_button = av.input_bool(query_row[7], 'has_button', _m)
command.can_have_button = av.input_bool(query_row[8], 'can_have_button', _m)
# command.has_button = av.input_bool(query_row[7], 'has_button', _m)
# command.notes = query_row[4]
command.active = av.input_bool(True, 'active', _m)
command.active = True # av.input_bool(True, 'active', _m)
# command.created_on = query_row[7]
command.command_category = Command_Category.from_db_dog_command_link(query_row)
return command
@classmethod
def from_json(cls, json):
_m = 'Command.from_json'
_m = f'{cls.__qualname__}.from_json'
command = cls()
if json is None: return Command
if json is None: return command
# Helper_App.console_log(f'{_m}\njson: {json}')
command.id_command = -1
command.id_command_category = json[Command_Category.FLAG_COMMAND_CATEGORY]
@@ -94,7 +98,7 @@ class Command(SQLAlchemy_ABC, Base):
as_json = {
**self.get_shared_json_attributes(self)
, self.ATTR_ID_COMMAND: self.id_command
, Command_Category.FLAG_COMMAND_CATEGORY: self.id_command_category
, Command_Category.ATTR_ID_COMMAND_CATEGORY: self.id_command_category
, self.FLAG_NAME: self.name
, self.FLAG_HAND_SIGNAL_DEFAULT_DESCRIPTION: self.hand_signal_default_description
, self.FLAG_CAN_HAVE_BUTTON: self.can_have_button
@@ -152,48 +156,102 @@ class Command_Temp(db.Model, Base):
class Parameters_Command(Get_Many_Parameters_Base):
get_all_command_category: bool
get_inactive_command_category: bool
ids_command_category: str
names_command_category: str
get_all_command: bool
get_inactive_command: bool
ids_command: str
names_command: str
hand_signal_default_descriptions_command: str
notes_command: str
require_all_id_search_filters_met: bool
require_any_id_search_filters_met: bool
require_all_non_id_search_filters_met: bool
require_any_non_id_search_filters_met: bool
output_command_categories: bool
output_commands: bool
@classmethod
def get_default(cls):
return cls(
get_all_command = True
get_all_command_category = True
, get_inactive_command_category = False
, ids_command_category = ''
, names_command_category = ''
, get_all_command = True
, get_inactive_command = False
, ids_command = ''
, names_command = ''
, hand_signal_default_descriptions_command = ''
, notes_command = ''
, require_all_id_search_filters_met = True
, require_any_id_search_filters_met = True
, require_all_non_id_search_filters_met = False
, require_any_non_id_search_filters_met = True
, output_command_categories = True
, output_commands = True
)
@classmethod
def from_json(cls, json):
return cls(
get_all_command = json.get('a_get_all_command', False)
get_all_command_category = json.get('a_get_all_command_category', False)
, get_inactive_command_category = json.get('a_get_inactive_command_category', False)
, ids_command_category = json.get('a_ids_command_category', '')
, names_command_category = json.get('a_names_command_category', '')
, get_all_command = json.get('a_get_all_command', False)
, get_inactive_command = json.get('a_get_inactive_command', False)
, ids_command = json.get('a_ids_command', '')
, names_command = json.get('a_names_command', '')
, hand_signal_default_descriptions_command = json.get('a_hand_signal_default_descriptions_command', '')
, notes_command = json.get('a_notes_command', '')
, require_all_id_search_filters_met = json.get('a_require_all_id_search_filters_met', True)
, require_any_id_search_filters_met = json.get('a_require_any_id_search_filters_met', True)
, require_all_non_id_search_filters_met = json.get('a_require_all_non_id_search_filters_met', False)
, require_any_non_id_search_filters_met = json.get('a_require_any_non_id_search_filters_met', True)
, output_command_categories = json.get('a_output_command_categories', False)
, output_commands = json.get('a_output_commands', False)
)
"""
@classmethod
def from_form_filters_command(cls, form):
av.val_instance(form, 'form', 'Parameters_Command.from_form_filters_command', Filters_Command)
has_filter_command = not (form.id_command.data == '0' or form.id_command.data == '' or form.id_command.data is None)
active_only = av.input_bool(form.active.data, "active", "Parameters_Command.from_form_filters_command")
def from_form_filters_dog_command_link(cls, form):
av.val_instance(form, 'form', 'Parameters_Command.from_form_filters_dog_command_link', Filters_Dog_Command_Link)
has_filter_search_text = not (form.search.data == '' or form.search.data is None)
has_filter_command_category = not (has_filter_search_text or form.id_command_category.data == '0' or form.id_command_category.data == '' or form.id_command_category.data is None)
has_filter_command = not (has_filter_search_text or form.id_command.data == '0' or form.id_command.data == '' or form.id_command.data is None)
active_only = av.input_bool(form.active_only.data, "active", "Parameters_Command.from_form_filters_dog_command_link")
return cls(
get_all_command = not has_filter_command
get_all_command_category = not has_filter_command_category
, get_inactive_command_category = not active_only
, ids_command_category = form.id_command_category.data if has_filter_command_category else ''
, names_command_category = form.search_text.data if has_filter_search_text else ''
, get_all_command = not has_filter_command
, get_inactive_command = not active_only
, ids_command = form.id_command.data if has_filter_id else ''
, names_command = form.name_command.data if has_filter_name else ''
, ids_command = form.id_command.data if has_filter_command else ''
, names_command = form.search_text.data if has_filter_search_text else ''
)
"""
def to_json(self):
return {
'a_get_all_command': self.get_all_command
'a_get_all_command_category': self.get_all_command_category
, 'a_get_inactive_command_category': self.get_inactive_command_category
, 'a_ids_command_category': self.ids_command_category
, 'a_names_command_category': self.names_command_category
, 'a_get_all_command': self.get_all_command
, 'a_get_inactive_command': self.get_inactive_command
, 'a_ids_command': self.ids_command
, 'a_names_command': self.names_command
, 'a_hand_signal_default_descriptions_command': self.hand_signal_default_descriptions_command
, 'a_notes_command': self.notes_command
, 'a_require_all_id_search_filters_met': self.require_all_id_search_filters_met
, 'a_require_any_id_search_filters_met': self.require_any_id_search_filters_met
, 'a_require_all_non_id_search_filters_met': self.require_all_non_id_search_filters_met
, 'a_require_any_non_id_search_filters_met': self.require_any_non_id_search_filters_met
, 'a_output_command_categories': self.output_command_categories
, 'a_output_commands': self.output_commands
}