feat(JavaScript): Updated architecture for TableBasePage object with static row ID attribute attached for adding ID against each row added to DOM

This commit is contained in:
2024-10-18 22:25:07 +01:00
parent 697963e28a
commit 7b6266e2f6
116 changed files with 7534 additions and 3840 deletions

View File

@@ -11,28 +11,52 @@ Data model for supplier view page
"""
# internal
from models.model_view_base import Model_View_Base
from models.model_view_store import Model_View_Store
# from routes import bp_home
from lib import argument_validation as av
from forms.forms import Form_Supplier
from datastores.datastore_store_supplier import DataStore_Store_Supplier
from business_objects.store.supplier import Supplier, Parameters_Supplier
from forms.store.supplier import Filters_Supplier
import lib.argument_validation as av
# external
from typing import ClassVar
class Model_View_Store_Supplier(Model_View_Store):
# Attributes
form: Form_Supplier
FLAG_DEPARTMENT_CONTACT: ClassVar[str] = Supplier.FLAG_DEPARTMENT_CONTACT
FLAG_NAME_COMPANY: ClassVar[str] = Supplier.FLAG_NAME_COMPANY
FLAG_NAME_CONTACT: ClassVar[str] = Supplier.FLAG_NAME_CONTACT
supplier_addresses: list = None
currencies: list = None
currency_options: list = None
form_filters: Filters_Supplier = None
form_filters_old: Filters_Supplier
regions: list = None
suppliers: list = None
units_measurement: list = None
units_measurement_time: list = None
@property
def title(self):
return 'Supplier'
return 'Store Supplier'
"""
def __new__(cls, db, info_user, app, form):
# Initialiser - validation
_m = 'Model_View_Supplier.__new__'
av.val_instance(form, 'form', _m, FlaskForm)
return super(Model_View_Supplier, cls).__new__(cls, db, info_user, app)
"""
def __init__(self,form, hash_page_current=Model_View_Base.HASH_PAGE_STORE_SUPPLIERS):
super().__init__(hash_page_current=hash_page_current, form=form)
def __init__(self, form_filters_old, hash_page_current=Model_View_Store.HASH_PAGE_STORE_SUPPLIERS):
_m = 'Model_View_Store_Supplier.__init__'
print(f'{_m}\nstarting...')
super().__init__(hash_page_current = hash_page_current, form_filters_old = form_filters_old)
self.form_filters = form_filters_old # Filters_Supplier.from_json(form_filters_old.to_json())
parameters_supplier = Parameters_Supplier.from_filters_supplier(self.form_filters)
datastore_supplier = DataStore_Store_Supplier()
self.suppliers, errors = datastore_supplier.get_many_supplier(parameters_supplier)
"""
self.units_measurement = self.get_many_unit_measurement()
self.units_measurement_time = [unit_measurement for unit_measurement in self.units_measurement if unit_measurement.is_unit_of_time]
"""
self.currencies = self.get_many_currency()
self.currency_options = [currency.to_json_option() for currency in self.currencies]
self.supplier_addresses = {}
for supplier in self.suppliers:
self.supplier_addresses[supplier.id_supplier] = [address.to_json() for address in supplier.addresses] if supplier.addresses else []
self.regions = self.get_many_region()
@classmethod
def save_suppliers(cls, comment, list_suppliers):
_m = f'{cls.__name__}.save_suppliers'
return DataStore_Store_Supplier().save_suppliers(comment, list_suppliers)