diff --git a/business_objects/address.py b/business_objects/address.py index feda3839..6805fb66 100644 --- a/business_objects/address.py +++ b/business_objects/address.py @@ -54,6 +54,7 @@ class Address(db.Model, Base): address = cls() address.id_address = query_row[1] address.id_region = query_row[2] + return address @classmethod def from_DB_stock_item(cls, query_row): address = cls() @@ -81,7 +82,7 @@ class Address(db.Model, Base): return { **self.get_shared_json_attributes(self), self.ATTR_ID_ADDRESS: self.id_address, - self.FLAG_REGION: self.region.to_json(), + self.FLAG_REGION: None if self.region is None else self.region.to_json(), self.FLAG_POSTCODE: self.postcode, self.FLAG_ADDRESS_LINE_1: self.address_line_1, self.FLAG_ADDRESS_LINE_2: self.address_line_2, diff --git a/business_objects/store/plant.py b/business_objects/store/plant.py index d48cd297..17d506f9 100644 --- a/business_objects/store/plant.py +++ b/business_objects/store/plant.py @@ -76,7 +76,7 @@ class Plant(db.Model, Store_Base): self.ATTR_ID_PLANT: self.id_plant, self.FLAG_CODE: self.code, self.FLAG_NAME: self.name, - self.FLAG_ADDRESS: self.address.to_json(), + self.FLAG_ADDRESS: None if self.address is None else self.address.to_json(), self.ATTR_ID_USER_MANAGER: self.id_user_manager, self.FLAG_ACTIVE: 1 if av.input_bool(self.active, self.FLAG_ACTIVE, f'{self.__class__.__name__}.to_json') else 0 } diff --git a/business_objects/store/storage_location.py b/business_objects/store/storage_location.py index d1831f4e..61a3fb8f 100644 --- a/business_objects/store/storage_location.py +++ b/business_objects/store/storage_location.py @@ -43,9 +43,9 @@ class Storage_Location(db.Model, Store_Base): location.id_location = query_row[0] location.id_plant = query_row[1] location.plant = Plant.from_DB_storage_location(query_row) - location.code = query_row[2] - location.name = query_row[3] - location.active = query_row[4] + location.code = query_row[4] + location.name = query_row[5] + location.active = query_row[6] return location @classmethod def from_DB_stock_item(cls, query_row): diff --git a/datastores/__pycache__/datastore_store_base.cpython-312.pyc b/datastores/__pycache__/datastore_store_base.cpython-312.pyc index dad97b7c..1c69cf60 100644 Binary files a/datastores/__pycache__/datastore_store_base.cpython-312.pyc and b/datastores/__pycache__/datastore_store_base.cpython-312.pyc differ diff --git a/datastores/datastore_store_base.py b/datastores/datastore_store_base.py index 30a1da23..d9a8e5b9 100644 --- a/datastores/datastore_store_base.py +++ b/datastores/datastore_store_base.py @@ -20,9 +20,11 @@ from business_objects.store.delivery_option import Delivery_Option from business_objects.region import Region from business_objects.store.discount import Discount from business_objects.store.order import Order +from business_objects.store.plant import Plant from business_objects.store.product import Product, Product_Permutation, Parameters_Product from business_objects.sql_error import SQL_Error from business_objects.store.stock_item import Stock_Item +from business_objects.store.storage_location import Storage_Location from business_objects.user import User, User_Filters, User_Permission_Evaluation from business_objects.store.product_variation import Product_Variation, Parameters_Product_Variation from business_objects.store.product_variation_type import Product_Variation_Type @@ -194,13 +196,66 @@ class DataStore_Store_Base(DataStore_Base): index_comma = msg_error_availability.find(',') ids_permutation.append(msg_error_availability[:index_comma]) return ids_permutation + @classmethod - def get_many_currency(cls): + def get_many_plant(cls, get_inactive = False): + _m = 'DataStore_Store_Base.get_many_plant' + _m_db_plant = 'p_shop_get_many_plant' + + argument_dict_list_plant = { + 'a_get_inactive_plant': 1 if get_inactive else 0 + } + + Helper_App.console_log(f'executing {_m_db_plant}') + result = cls.db_procedure_execute(_m_db_plant, argument_dict_list_plant) + cursor = result.cursor + Helper_App.console_log('data received') + + # cursor.nextset() + result_set_1 = cursor.fetchall() + plants = [] + for row in result_set_1: + plant = Plant.from_DB_plant(row) + plants.append(plant) + Helper_App.console_log(f'plants: {plants}') + DataStore_Store_Base.db_cursor_clear(cursor) + cursor.close() + + return plants + + @classmethod + def get_many_storage_location(self, get_inactive = False): + _m = 'DataStore_Store_Base.get_many_storage_location' + _m_db_storage_location = 'p_shop_get_many_storage_location' + + argument_dict_list_storage_location = { + 'a_get_inactive_storage_location': 1 if get_inactive else 0 + } + + Helper_App.console_log(f'executing {_m_db_storage_location}') + result = self.db_procedure_execute(_m_db_storage_location, argument_dict_list_storage_location) + cursor = result.cursor + Helper_App.console_log('data received') + + # cursor.nextset() + result_set_1 = cursor.fetchall() + storage_locations = [] + for row in result_set_1: + storage_location = Storage_Location.from_DB_storage_location(row) + storage_locations.append(storage_location) + Helper_App.console_log(f'storage_locations: {storage_locations}') + DataStore_Store_Base.db_cursor_clear(cursor) + cursor.close() + + return storage_locations + + @classmethod + def get_many_currency(cls, get_inactive = False): _m = 'DataStore_Store_Base.get_many_currency' _m_db_currency = 'p_shop_get_many_currency' argument_dict_list_currency = { - 'a_get_inactive_currency': 0 + 'a_get_inactive_currency': 1 if get_inactive else 0 } Helper_App.console_log(f'executing {_m_db_currency}') @@ -220,12 +275,12 @@ class DataStore_Store_Base(DataStore_Base): return currencies @classmethod - def get_many_region(cls): + def get_many_region(cls, get_inactive = False): _m = 'DataStore_Store_Base.get_many_region' _m_db_region = 'p_shop_get_many_region' argument_dict_list_region = { - 'a_get_inactive_currency': 0 + 'a_get_inactive_region': 1 if get_inactive else 0 } Helper_App.console_log(f'executing {_m_db_region}') @@ -246,10 +301,10 @@ class DataStore_Store_Base(DataStore_Base): return regions @classmethod - def get_many_region_and_currency(cls): + def get_many_region_and_currency(cls, get_inactive_currency = False, get_inactive_region = False): _m = 'DataStore_Store_Base.get_many_region_and_currency' - currencies = cls.get_many_currency() - regions = cls.get_many_region() + currencies = cls.get_many_currency(get_inactive_currency) + regions = cls.get_many_region(get_inactive_region) return regions, currencies @classmethod diff --git a/models/__pycache__/model_view_store.cpython-312.pyc b/models/__pycache__/model_view_store.cpython-312.pyc index 6ae5e9ec..3497bac4 100644 Binary files a/models/__pycache__/model_view_store.cpython-312.pyc and b/models/__pycache__/model_view_store.cpython-312.pyc differ diff --git a/models/__pycache__/model_view_store_stock_item.cpython-312.pyc b/models/__pycache__/model_view_store_stock_item.cpython-312.pyc index 4d82ac2c..4e4b47d6 100644 Binary files a/models/__pycache__/model_view_store_stock_item.cpython-312.pyc and b/models/__pycache__/model_view_store_stock_item.cpython-312.pyc differ diff --git a/models/model_view_store.py b/models/model_view_store.py index 73229dab..81ddc2e9 100644 --- a/models/model_view_store.py +++ b/models/model_view_store.py @@ -492,6 +492,12 @@ class Model_View_Store(Model_View_Base): # validation conducted by server return DataStore_User().get_many_user_order(self.info_user['sub'], ids_order, n_order_max, id_checkout_session) + def get_many_plant(self, get_inactive = False): + plants = DataStore_Store_Base().get_many_plant(get_inactive) + return plants + def get_many_storage_location(self, get_inactive = False): + storage_locations = DataStore_Store_Base().get_many_storage_location(get_inactive) + return storage_locations def get_many_currency(self): currencies = DataStore_Store_Base().get_many_currency() return currencies diff --git a/models/model_view_store_stock_item.py b/models/model_view_store_stock_item.py index 74b7b237..e79f38ec 100644 --- a/models/model_view_store_stock_item.py +++ b/models/model_view_store_stock_item.py @@ -33,6 +33,8 @@ class Model_View_Store_Stock_Item(Model_View_Store): filters_stock_item: Filters_Stock_Item form_filters: Filters_Stock_Item = None list_options_product: list = None + plants: list = None + storage_locations: list = None units_measurement: list = None units_measurement_time: list = None variations: list = None @@ -87,6 +89,8 @@ class Model_View_Store_Stock_Item(Model_View_Store): 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.plants = self.get_many_plant(False) + self.storage_locations = self.get_many_storage_location(False) @classmethod def save_stock_items(cls, comment, list_stock_items): diff --git a/static/MySQL/0000_combine.sql b/static/MySQL/0000_combine.sql index 6f9ae521..9d4b5402 100644 --- a/static/MySQL/0000_combine.sql +++ b/static/MySQL/0000_combine.sql @@ -173,10 +173,14 @@ DROP TABLE IF EXISTS Shop_Variation_Audit; DROP TABLE IF EXISTS Shop_Variation; DROP TABLE IF EXISTS Shop_Product_Variation_Type_Link_Audit; DROP TABLE IF EXISTS Shop_Product_Variation_Type_Link; +DROP TABLE IF EXISTS Shop_Product_Variation_Temp; +DROP TABLE IF EXISTS Shop_Product_Variation; DROP TABLE IF EXISTS Shop_Variation_Type_Temp; DROP TABLE IF EXISTS Shop_Variation_Type_Audit; DROP TABLE IF EXISTS Shop_Variation_Type; +DROP TABLE IF EXISTS Shop_Product_Variation_Type_Temp; +DROP TABLE IF EXISTS Shop_Product_Variation_Type; DROP TABLE IF EXISTS Shop_Product_Permutation_Temp; DROP TABLE IF EXISTS Shop_Product_Permutation_Audit; @@ -1475,9 +1479,9 @@ CREATE TABLE IF NOT EXISTS Shop_Variation_Type_Audit ( SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Variation_Type_Temp'; CREATE TABLE IF NOT EXISTS Shop_Variation_Type_Temp ( - id_temp INT NOT NULL PRIMARY KEY + id_temp INT NOT NULL PRIMARY KEY AUTO_INCREMENT , id_type INT NOT NULL - , id_type_temp INT NOT NULL + -- , id_type_temp INT NOT NULL , code VARCHAR(50) , name VARCHAR(255) , name_plural VARCHAR(256) @@ -1536,10 +1540,12 @@ CREATE TABLE IF NOT EXISTS Shop_Variation_Audit ( # Variations Temp +-- DROP TABLE partsltd_prod.Shop_Variation_Temp; + SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Variation_Temp'; CREATE TABLE Shop_Variation_Temp ( - id_temp INT NOT NULL PRIMARY KEY + id_temp INT NOT NULL PRIMARY KEY AUTO_INCREMENT , id_variation INT NOT NULL , id_type INT NOT NULL , code VARCHAR(50) @@ -11219,10 +11225,10 @@ DELIMITER ;; CALL p_shop_get_many_product_variation ( 1 # 'auth0|6582b95c895d09a70ba10fef', # a_id_user , 1 # a_get_all_variation_type - , 0 # a_get_inactive_variation_type + , 1 # a_get_inactive_variation_type , '' # a_ids_variation_type , 1 # a_get_all_variation - , 0 # a_get_inactive_variation + , 1 # a_get_inactive_variation , '' # a_ids_variation , 0 # a_debug ); @@ -11613,6 +11619,8 @@ BEGIN ; END IF; + -- Duplicate Variation Type Ids + -- Duplicate Variation Ids -- Duplicate Variation Type Codes -- Duplicate Variation Codes @@ -11683,7 +11691,7 @@ BEGIN -- Transaction IF NOT EXISTS (SELECT * FROM tmp_Msg_Error) THEN START TRANSACTION; - INSERT INTO Shop_Sales_And_Purchasing_Change_Set ( + INSERT INTO Shop_Product_Change_Set ( comment , updated_last_by , updated_last_on @@ -11768,6 +11776,7 @@ BEGIN , VT.display_order = t_VT.display_order , VT.created_on = t_VT.created_on , VT.created_by = t_VT.created_by + , VT.id_change_set = v_id_change_set ; UPDATE partsltd_prod.Shop_Variation V @@ -11781,6 +11790,7 @@ BEGIN , V.display_order = t_V.display_order , V.created_on = t_V.created_on , V.created_by = t_V.created_by + , V.id_change_set = v_id_change_set ; DELETE VT_T @@ -11853,7 +11863,7 @@ BEGIN INSERT INTO partsltd_prod.Shop_Variation_Type_Temp ( id_type - , id_type_temp + -- , id_type_temp , code , name , name_plural @@ -11861,10 +11871,10 @@ BEGIN , active , GUID ) - /* Test 1 - Insert */ + /* Test 1 - Insert VALUES ( -1 - , -1 + -- , -1 , 'SIZE' , 'Size' , 'Sizes' @@ -11872,11 +11882,19 @@ BEGIN , 1 , v_guid ) - /* Test 2: Alter - SELECT - FROM partsltd_prod.Shop_Variation_Type - WHERE id_order = 6 */ + /* Test 2: Alter */ + SELECT + id_type + -- , id_type AS id_type_temp + , code + , name + , name_plural + , display_order + , active + , v_guid AS GUID + FROM partsltd_prod.Shop_Variation_Type + WHERE id_type = 1 ; INSERT INTO partsltd_prod.Shop_Variation_Temp ( @@ -11888,7 +11906,7 @@ BEGIN , active , GUID ) - /* Test 1 - Insert */ + /* Test 1 - Insert VALUES ( -1 -- id_variation , -1 -- id_type @@ -11898,11 +11916,38 @@ BEGIN , 1 -- active , v_guid -- ) - /* Test 2: Alter - SELECT - FROM partsltd_prod.Shop_Variation - WHERE id_order = 6 */ + /* Test 3 - Insert + VALUES ( + -1 -- id_variation + , 1 -- id_type + , 'SILVER' -- code + , 'Silver' -- name + , 10 -- display_order + , 1 -- active + , 'NIPS' -- v_guid -- + ); + */ + /* Test 2: Alter */ + SELECT + id_variation + , id_type + , code + , name + , display_order + , active + , v_guid AS GUID + FROM partsltd_prod.Shop_Variation + WHERE id_variation = 2 + UNION + SELECT + -1 -- id_variation + , 1 -- id_type + , 'GREEN' -- code + , 'Green' -- name + , 3 -- display_order + , 1 -- active + , v_guid -- ; COMMIT; @@ -11918,7 +11963,7 @@ BEGIN ; CALL partsltd_prod.p_shop_save_product_variation ( - 'Test save Variations' -- comment + 'Test save Variations - add + edit' -- comment , v_guid -- guid , 1 -- id_user , 1 -- debug @@ -11964,6 +12009,9 @@ delete from shop_variation_type where id_type = -1 ; + +Cannot add or update a child row: a foreign key constraint fails (`partsltd_prod`.`shop_variation_type`, CONSTRAINT `FK_Shop_Variation_Type_id_change_set` FOREIGN KEY (`id_change_set`) REFERENCES `shop_product_change_set` (`id_change_set`)) + */ -- Clear previous proc @@ -22403,6 +22451,78 @@ INSERT INTO Shop_Storage_Location ( ) VALUES (1, 'K-F-1', 'Kitchen Fridge 1') + , (1, 'K-AHL-M-B', 'Kitchen - Above Hob Left Medial - Bottom') + , (1, 'K-AHL-M-M', 'Kitchen - Above Hob Left Medial - Middle') + , (1, 'K-AHL-M-T', 'Kitchen - Above Hob Left Medial - Top') + , (1, 'K-AHL-L-B', 'Kitchen - Above Hob Left Lateral - Bottom') + , (1, 'K-AHL-L-M', 'Kitchen - Above Hob Left Lateral - Middle') + , (1, 'K-AHL-L-T', 'Kitchen - Above Hob Left Lateral - Top') + , (1, 'K-AHR-M-B', 'Kitchen - Above Hob Left Medial - Bottom') + , (1, 'K-AHR-M-M', 'Kitchen - Above Hob Left Medial - Middle') + , (1, 'K-AHR-M-T', 'Kitchen - Above Hob Left Medial - Top') + , (1, 'K-AHL-M-B', 'Kitchen - Above Hob Left Medial - Bottom') + , (1, 'K-AHL-M-M', 'Kitchen - Above Hob Left Medial - Middle') + , (1, 'K-AHL-M-T', 'Kitchen - Above Hob Left Medial - Top') + , (1, 'K-AHL-L-B', 'Kitchen - Above Hob Left Lateral - Bottom') + , (1, 'K-AHL-L-M', 'Kitchen - Above Hob Left Lateral - Middle') + , (1, 'K-AHL-L-T', 'Kitchen - Above Hob Left Lateral - Top') + , (1, 'K-AHL-XL-B', 'Kitchen - Above Hob Left Extra Lateral - Bottom') + , (1, 'K-AHL-XL-M', 'Kitchen - Above Hob Left Extra Lateral - Middle') + , (1, 'K-AHL-XL-T', 'Kitchen - Above Hob Left Extra Lateral - Top') + , (1, 'K-BS-B', 'Kitchen - Below Sink - Bottom') + , (1, 'K-BS-T', 'Kitchen - Below Sink - Top') + , (1, 'K-LO-B', 'Kitchen - Left of Oven - Bottom') + , (1, 'K-LO-T', 'Kitchen - Left of Oven - Top') + , (1, 'K-RO-M-B', 'Kitchen - Right of Oven - Medial - Bottom') + , (1, 'K-RO-M-M', 'Kitchen - Right of Oven - Medial - Middle') + , (1, 'K-RO-M-T', 'Kitchen - Right of Oven - Medial - Top') + , (1, 'K-RO-L-B', 'Kitchen - Right of Oven - Lateral - Bottom') + , (1, 'K-RO-L-T', 'Kitchen - Right of Oven - Lateral - Top') + , (1, 'K-BBB-B', 'Kitchen - Below Breakfast Bar - Bottom') + , (1, 'K-BBB-T', 'Kitchen - Below Breakfast Bar - Top') + , (1, 'K-BSL-M-B', 'Kitchen - Bekow Sink Left - Medial - Bottom') + , (1, 'K-BSL-M-T', 'Kitchen - Bekow Sink Left - Medial - Top') + , (1, 'K-BSL-L-B', 'Kitchen - Bekow Sink Left - Lateral - Bottom') + , (1, 'K-BSL-L-T', 'Kitchen - Bekow Sink Left - Lateral - Top') + , (1, 'K-ASL-M-B', 'Kitchen - Above Sink Left - Medial - Bottom') + , (1, 'K-ASL-M-M', 'Kitchen - Above Sink Left - Medial - Middle') + , (1, 'K-ASL-M-T', 'Kitchen - Above Sink Left - Medial - Top') + , (1, 'K-ASL-L-B', 'Kitchen - Above Sink Left - Lateral - Bottom') + , (1, 'K-ASL-L-M', 'Kitchen - Above Sink Left - Lateral - Middle') + , (1, 'K-ASL-L-T', 'Kitchen - Above Sink Left - Lateral - Top') + , (1, 'K-ASL-XL-B', 'Kitchen - Above Sink Left - Extra Lateral - Bottom') + , (1, 'K-ASL-XL-M', 'Kitchen - Above Sink Left - Extra Lateral - Middle') + , (1, 'K-ASL-XL-T', 'Kitchen - Above Sink Left - Extra Lateral - Top') + , (1, 'K-T-B', 'Kitchen - Tower - Bottom') + , (1, 'K-T-LM', 'Kitchen - Tower - Lower Middle') + , (1, 'K-T-UM', 'Kitchen - Tower - Upper Middle') + , (1, 'K-T-T', 'Kitchen - Tower - Top') + , (1, 'K-FJ-MEAT', 'Kitchen - Fridge - Meat Drawer') + , (1, 'K-FJ-VEG', 'Kitchen - Fridge - Vegetables Drawer') + , (1, 'K-FJ-CHEESE', 'Kitchen - Fridge - Cheese Drawer') + , (1, 'K-FJ-S-B', 'Kitchen - Fridge - Shelf - Bottom') + , (1, 'K-FJ-S-LM', 'Kitchen - Fridge - Shelf - Lower Middle') + , (1, 'K-FJ-S-UM', 'Kitchen - Fridge - Shelf - Upper Middle') + , (1, 'K-FJ-S-T', 'Kitchen - Fridge - Shelf - Top') + , (1, 'K-FJ-DG-B', 'Kitchen - Door Shelf (Guarded) - Bottom') + , (1, 'K-FJ-DG-LM', 'Kitchen - Door Shelf (Guarded) - Lower Middle') + , (1, 'K-FJ-DG-UM', 'Kitchen - Door Shelf (Guarded) - Upper Middle') + , (1, 'K-FJ-DG-T', 'Kitchen - Door Shelf (Guarded) - Top') + , (1, 'K-FJ-DU', 'Kitchen - Door Shelf (Unguarded)') + , (1, 'K-FZ-DRAWER-B', 'Kitchen - Freezer - Drawer - Bottom') + , (1, 'K-FZ-DRAWER-T', 'Kitchen - Freezer - Drawer - Top') + , (1, 'K-FZ-DRAWER-I', 'Kitchen - Freezer - Drawer - Ice') + , (1, 'K-FZ-S-B', 'Kitchen - Freezer - Shelf - Bottom') + , (1, 'K-FZ-S-M', 'Kitchen - Freezer - Shelf - Middle') + , (1, 'K-FZ-S-T', 'Kitchen - Freezer - Shelf - Top') + , (1, 'K-FZ-DOOR-XL', 'Kitchen - Freezer - Door - Extra Low') + , (1, 'K-FZ-DOOR-L', 'Kitchen - Freezer - Door - Lower') + , (1, 'K-FZ-DOOR-LM', 'Kitchen - Freezer - Door - Lower Middle') + , (1, 'K-FZ-DOOR-UM', 'Kitchen - Freezer - Door - Upper Middle') + , (1, 'K-FZ-DOOR-U', 'Kitchen - Freezer - Door - Upper') + , (1, 'K-FZ-DOOR-XU', 'Kitchen - Freezer - Door - Extra Up') + , (1, 'K-AFF', 'Kitchen - Above Fridge-Freezer') + , (1, 'K-CT', 'Kitchen - Counter Top') ; /* diff --git a/static/MySQL/7109_p_shop_get_many_storage_location.sql b/static/MySQL/7109_p_shop_get_many_storage_location.sql index d4de385e..35967c0e 100644 --- a/static/MySQL/7109_p_shop_get_many_storage_location.sql +++ b/static/MySQL/7109_p_shop_get_many_storage_location.sql @@ -12,7 +12,7 @@ BEGIN SET a_get_inactive_storage_location = IFNULL(a_get_inactive_storage_location, 0); SELECT - SL.id_storage_location + SL.id_location , P.id_plant , P.id_address , A.id_region diff --git a/static/MySQL/7212_p_shop_save_product_variation_test.sql b/static/MySQL/7212_p_shop_save_product_variation_test.sql index d211e8bb..45093ac4 100644 --- a/static/MySQL/7212_p_shop_save_product_variation_test.sql +++ b/static/MySQL/7212_p_shop_save_product_variation_test.sql @@ -157,6 +157,7 @@ BEGIN END // DELIMITER ;; +/* CALL partsltd_prod.p_shop_save_product_variation_test (); DELETE FROM partsltd_prod.Shop_Variation_Type_Temp; @@ -164,7 +165,6 @@ DELETE FROM partsltd_prod.Shop_Variation_Temp; DROP TABLE IF EXISTS tmp_Msg_Error; -/* delete from shop_variation_audit where id_variation = 3 diff --git a/static/MySQL/9000_populate.sql b/static/MySQL/9000_populate.sql index 75f21294..895ea9d4 100644 --- a/static/MySQL/9000_populate.sql +++ b/static/MySQL/9000_populate.sql @@ -109,6 +109,78 @@ INSERT INTO Shop_Storage_Location ( ) VALUES (1, 'K-F-1', 'Kitchen Fridge 1') + , (1, 'K-AHL-M-B', 'Kitchen - Above Hob Left Medial - Bottom') + , (1, 'K-AHL-M-M', 'Kitchen - Above Hob Left Medial - Middle') + , (1, 'K-AHL-M-T', 'Kitchen - Above Hob Left Medial - Top') + , (1, 'K-AHL-L-B', 'Kitchen - Above Hob Left Lateral - Bottom') + , (1, 'K-AHL-L-M', 'Kitchen - Above Hob Left Lateral - Middle') + , (1, 'K-AHL-L-T', 'Kitchen - Above Hob Left Lateral - Top') + , (1, 'K-AHR-M-B', 'Kitchen - Above Hob Left Medial - Bottom') + , (1, 'K-AHR-M-M', 'Kitchen - Above Hob Left Medial - Middle') + , (1, 'K-AHR-M-T', 'Kitchen - Above Hob Left Medial - Top') + , (1, 'K-AHL-M-B', 'Kitchen - Above Hob Left Medial - Bottom') + , (1, 'K-AHL-M-M', 'Kitchen - Above Hob Left Medial - Middle') + , (1, 'K-AHL-M-T', 'Kitchen - Above Hob Left Medial - Top') + , (1, 'K-AHL-L-B', 'Kitchen - Above Hob Left Lateral - Bottom') + , (1, 'K-AHL-L-M', 'Kitchen - Above Hob Left Lateral - Middle') + , (1, 'K-AHL-L-T', 'Kitchen - Above Hob Left Lateral - Top') + , (1, 'K-AHL-XL-B', 'Kitchen - Above Hob Left Extra Lateral - Bottom') + , (1, 'K-AHL-XL-M', 'Kitchen - Above Hob Left Extra Lateral - Middle') + , (1, 'K-AHL-XL-T', 'Kitchen - Above Hob Left Extra Lateral - Top') + , (1, 'K-BS-B', 'Kitchen - Below Sink - Bottom') + , (1, 'K-BS-T', 'Kitchen - Below Sink - Top') + , (1, 'K-LO-B', 'Kitchen - Left of Oven - Bottom') + , (1, 'K-LO-T', 'Kitchen - Left of Oven - Top') + , (1, 'K-RO-M-B', 'Kitchen - Right of Oven - Medial - Bottom') + , (1, 'K-RO-M-M', 'Kitchen - Right of Oven - Medial - Middle') + , (1, 'K-RO-M-T', 'Kitchen - Right of Oven - Medial - Top') + , (1, 'K-RO-L-B', 'Kitchen - Right of Oven - Lateral - Bottom') + , (1, 'K-RO-L-T', 'Kitchen - Right of Oven - Lateral - Top') + , (1, 'K-BBB-B', 'Kitchen - Below Breakfast Bar - Bottom') + , (1, 'K-BBB-T', 'Kitchen - Below Breakfast Bar - Top') + , (1, 'K-BSL-M-B', 'Kitchen - Bekow Sink Left - Medial - Bottom') + , (1, 'K-BSL-M-T', 'Kitchen - Bekow Sink Left - Medial - Top') + , (1, 'K-BSL-L-B', 'Kitchen - Bekow Sink Left - Lateral - Bottom') + , (1, 'K-BSL-L-T', 'Kitchen - Bekow Sink Left - Lateral - Top') + , (1, 'K-ASL-M-B', 'Kitchen - Above Sink Left - Medial - Bottom') + , (1, 'K-ASL-M-M', 'Kitchen - Above Sink Left - Medial - Middle') + , (1, 'K-ASL-M-T', 'Kitchen - Above Sink Left - Medial - Top') + , (1, 'K-ASL-L-B', 'Kitchen - Above Sink Left - Lateral - Bottom') + , (1, 'K-ASL-L-M', 'Kitchen - Above Sink Left - Lateral - Middle') + , (1, 'K-ASL-L-T', 'Kitchen - Above Sink Left - Lateral - Top') + , (1, 'K-ASL-XL-B', 'Kitchen - Above Sink Left - Extra Lateral - Bottom') + , (1, 'K-ASL-XL-M', 'Kitchen - Above Sink Left - Extra Lateral - Middle') + , (1, 'K-ASL-XL-T', 'Kitchen - Above Sink Left - Extra Lateral - Top') + , (1, 'K-T-B', 'Kitchen - Tower - Bottom') + , (1, 'K-T-LM', 'Kitchen - Tower - Lower Middle') + , (1, 'K-T-UM', 'Kitchen - Tower - Upper Middle') + , (1, 'K-T-T', 'Kitchen - Tower - Top') + , (1, 'K-FJ-MEAT', 'Kitchen - Fridge - Meat Drawer') + , (1, 'K-FJ-VEG', 'Kitchen - Fridge - Vegetables Drawer') + , (1, 'K-FJ-CHEESE', 'Kitchen - Fridge - Cheese Drawer') + , (1, 'K-FJ-S-B', 'Kitchen - Fridge - Shelf - Bottom') + , (1, 'K-FJ-S-LM', 'Kitchen - Fridge - Shelf - Lower Middle') + , (1, 'K-FJ-S-UM', 'Kitchen - Fridge - Shelf - Upper Middle') + , (1, 'K-FJ-S-T', 'Kitchen - Fridge - Shelf - Top') + , (1, 'K-FJ-DG-B', 'Kitchen - Door Shelf (Guarded) - Bottom') + , (1, 'K-FJ-DG-LM', 'Kitchen - Door Shelf (Guarded) - Lower Middle') + , (1, 'K-FJ-DG-UM', 'Kitchen - Door Shelf (Guarded) - Upper Middle') + , (1, 'K-FJ-DG-T', 'Kitchen - Door Shelf (Guarded) - Top') + , (1, 'K-FJ-DU', 'Kitchen - Door Shelf (Unguarded)') + , (1, 'K-FZ-DRAWER-B', 'Kitchen - Freezer - Drawer - Bottom') + , (1, 'K-FZ-DRAWER-T', 'Kitchen - Freezer - Drawer - Top') + , (1, 'K-FZ-DRAWER-I', 'Kitchen - Freezer - Drawer - Ice') + , (1, 'K-FZ-S-B', 'Kitchen - Freezer - Shelf - Bottom') + , (1, 'K-FZ-S-M', 'Kitchen - Freezer - Shelf - Middle') + , (1, 'K-FZ-S-T', 'Kitchen - Freezer - Shelf - Top') + , (1, 'K-FZ-DOOR-XL', 'Kitchen - Freezer - Door - Extra Low') + , (1, 'K-FZ-DOOR-L', 'Kitchen - Freezer - Door - Lower') + , (1, 'K-FZ-DOOR-LM', 'Kitchen - Freezer - Door - Lower Middle') + , (1, 'K-FZ-DOOR-UM', 'Kitchen - Freezer - Door - Upper Middle') + , (1, 'K-FZ-DOOR-U', 'Kitchen - Freezer - Door - Upper') + , (1, 'K-FZ-DOOR-XU', 'Kitchen - Freezer - Door - Extra Up') + , (1, 'K-AFF', 'Kitchen - Above Fridge-Freezer') + , (1, 'K-CT', 'Kitchen - Counter Top') ; /* diff --git a/static/css/layouts/table-main.css b/static/css/layouts/table-main.css index 097dfb26..dd8e72e0 100644 --- a/static/css/layouts/table-main.css +++ b/static/css/layouts/table-main.css @@ -9,6 +9,12 @@ justify-content: normal; } +#tableMain select, #tableMain input, #tableMain textarea, #tableMain div { + box-sizing: border-box; + width: 100%; + height: 100%; +} + #tableMain thead tr th, #tableMain tbody tr td { width: 20vh; min-width: 20vh; diff --git a/static/css/main.css b/static/css/main.css index d01cbda5..34ad825c 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -68,7 +68,6 @@ body { } *{ - /*box-sizing: border-box; */ margin: 0; } diff --git a/static/css/pages/store/stock_items.css b/static/css/pages/store/stock_items.css index ec4eb4b4..f8330705 100644 --- a/static/css/pages/store/stock_items.css +++ b/static/css/pages/store/stock_items.css @@ -20,16 +20,18 @@ th, td { #tableMain thead tr th.product_variations.collapsed, #tableMain tbody tr td.product_variations.collapsed { width: 10vh; min-width: 10vh; + display: table-cell !important; } #tableMain thead tr th.product_variations, #tableMain tbody tr td.product_variations { - width: 20vh; - min-width: 20vh; + width: 24vh; + min-width: 24vh; } -#tableMain tbody tr td.product_variations table thead tr th, #tableMain tbody tr td.product_variations table tbody tr td { +#tableMain tbody tr td.product_variations table thead tr th.product_variation_type, #tableMain tbody tr td.product_variations table tbody tr td.product_variation_type, +#tableMain tbody tr td.product_variations table thead tr th.product_variation, #tableMain tbody tr td.product_variations table tbody tr td.product_variation { width: 8vh; min-width: 8vh; } -#tableMain tbody tr td.product_variations table thead tr th:last-of-type, #tableMain tbody tr td.product_variations table tbody tr td:last-of-type { +#tableMain tbody tr td.product_variations table thead tr th.add, #tableMain tbody tr td.product_variations table tbody tr td.delete { width: 4vh; min-width: 4vh; } @@ -43,25 +45,27 @@ th, td { min-width: 11vh; } -#tableMain thead tr th.cost_local_vat_excl, #tableMain tbody tr td.cost_local_vat_excl, -#tableMain thead tr th.cost_local_vat_incl, #tableMain tbody tr td.cost_local_vat_incl { +#tableMain thead tr th.cost_unit_local_vat_excl, #tableMain tbody tr td.cost_unit_local_vat_excl, +#tableMain thead tr th.cost_unit_local_vat_incl, #tableMain tbody tr td.cost_unit_local_vat_incl { width: 9vh; min-width: 9vh; } -#tableMain thead tr th.storage-location.collapsed, #tableMain tbody tr td.storage-location.collapsed { +#tableMain thead tr th.storage_location.collapsed, #tableMain tbody tr td.storage_location.collapsed { width: 10vh; min-width: 10vh; } -#tableMain thead tr th.storage-location, #tableMain tbody tr td.storage-location { +#tableMain thead tr th.storage_location, #tableMain tbody tr td.storage_location { width: 20vh; min-width: 20vh; } -#tableMain tbody tr td.storage-location table thead tr th, #tableMain tbody tr td.storage-location table tbody tr td { +#tableMain tbody tr td.storage_location table thead tr th, +#tableMain tbody tr td.storage_location table tbody tr td { width: 8vh; min-width: 8vh; } -#tableMain tbody tr td.storage-location table thead tr th:last-of-type, #tableMain tbody tr td.storage-location table tbody tr td:last-of-type { +#tableMain tbody tr td.storage_location table thead tr th:last-of-type, +#tableMain tbody tr td.storage_location table tbody tr td:last-of-type { width: 4vh; min-width: 4vh; } diff --git a/static/dist/css/main.bundle.css b/static/dist/css/main.bundle.css index 94f9e664..471dd7fb 100644 --- a/static/dist/css/main.bundle.css +++ b/static/dist/css/main.bundle.css @@ -68,7 +68,6 @@ body { } *{ - /*box-sizing: border-box; */ margin: 0; } @@ -708,6 +707,12 @@ form.filter button.save, form.filter button.button-cancel { justify-content: normal; } +#tableMain select, #tableMain input, #tableMain textarea { + box-sizing: border-box; + width: 100%; + height: 100%; +} + #tableMain thead tr th, #tableMain tbody tr td { width: 20vh; min-width: 20vh; diff --git a/static/dist/css/store_stock_items.bundle.css b/static/dist/css/store_stock_items.bundle.css index 0fb18fe6..593ab181 100644 --- a/static/dist/css/store_stock_items.bundle.css +++ b/static/dist/css/store_stock_items.bundle.css @@ -77,16 +77,18 @@ th, td { #tableMain thead tr th.product_variations.collapsed, #tableMain tbody tr td.product_variations.collapsed { width: 10vh; min-width: 10vh; + display: table-cell !important; } #tableMain thead tr th.product_variations, #tableMain tbody tr td.product_variations { - width: 20vh; - min-width: 20vh; + width: 24vh; + min-width: 24vh; } -#tableMain tbody tr td.product_variations table thead tr th, #tableMain tbody tr td.product_variations table tbody tr td { +#tableMain tbody tr td.product_variations table thead tr th.product_variation_type, #tableMain tbody tr td.product_variations table tbody tr td.product_variation_type, +#tableMain tbody tr td.product_variations table thead tr th.product_variation, #tableMain tbody tr td.product_variations table tbody tr td.product_variation { width: 8vh; min-width: 8vh; } -#tableMain tbody tr td.product_variations table thead tr th:last-of-type, #tableMain tbody tr td.product_variations table tbody tr td:last-of-type { +#tableMain tbody tr td.product_variations table thead tr th.add, #tableMain tbody tr td.product_variations table tbody tr td.delete { width: 4vh; min-width: 4vh; } @@ -100,25 +102,27 @@ th, td { min-width: 11vh; } -#tableMain thead tr th.cost_local_vat_excl, #tableMain tbody tr td.cost_local_vat_excl, -#tableMain thead tr th.cost_local_vat_incl, #tableMain tbody tr td.cost_local_vat_incl { +#tableMain thead tr th.cost_unit_local_vat_excl, #tableMain tbody tr td.cost_unit_local_vat_excl, +#tableMain thead tr th.cost_unit_local_vat_incl, #tableMain tbody tr td.cost_unit_local_vat_incl { width: 9vh; min-width: 9vh; } -#tableMain thead tr th.storage-location.collapsed, #tableMain tbody tr td.storage-location.collapsed { +#tableMain thead tr th.storage_location.collapsed, #tableMain tbody tr td.storage_location.collapsed { width: 10vh; min-width: 10vh; } -#tableMain thead tr th.storage-location, #tableMain tbody tr td.storage-location { +#tableMain thead tr th.storage_location, #tableMain tbody tr td.storage_location { width: 20vh; min-width: 20vh; } -#tableMain tbody tr td.storage-location table thead tr th, #tableMain tbody tr td.storage-location table tbody tr td { +#tableMain tbody tr td.storage_location table thead tr th, +#tableMain tbody tr td.storage_location table tbody tr td { width: 8vh; min-width: 8vh; } -#tableMain tbody tr td.storage-location table thead tr th:last-of-type, #tableMain tbody tr td.storage-location table tbody tr td:last-of-type { +#tableMain tbody tr td.storage_location table thead tr th:last-of-type, +#tableMain tbody tr td.storage_location table tbody tr td:last-of-type { width: 4vh; min-width: 4vh; } diff --git a/static/dist/js/main.bundle.js b/static/dist/js/main.bundle.js index 53962296..0bafad5f 100644 --- a/static/dist/js/main.bundle.js +++ b/static/dist/js/main.bundle.js @@ -2347,7 +2347,7 @@ var TableBasePage = /*#__PURE__*/function (_BasePage) { if (!isPopState) { base_table_superPropGet(TableBasePage, "sharedInitialize", this, 3)([]); this.hookupFilters(); - this.hookupButtonsAddSaveCancel(); + this.hookupButtonsSaveCancel(); this.hookupTableMain(); OverlayConfirm.hookup(function () { if (isSinglePageApp) { @@ -2461,8 +2461,8 @@ var TableBasePage = /*#__PURE__*/function (_BasePage) { }); } }, { - key: "hookupButtonsAddSaveCancel", - value: function hookupButtonsAddSaveCancel() { + key: "hookupButtonsSaveCancel", + value: function hookupButtonsSaveCancel() { this.hookupButtonSave(); this.hookupButtonCancel(); this.toggleShowButtonsSaveCancel(false); @@ -4969,7 +4969,7 @@ var PageStoreProductPermutations = /*#__PURE__*/function (_TableBasePage) { this.hookupSubscriptionFields(); this.hookupIdStripeProductInputs(); this.hookupExpirationFields(); - this.hookupActiveCheckboxes(); + this.hookupFieldsActive(); } }, { key: "hookupFieldsProductCategory", @@ -5144,11 +5144,6 @@ var PageStoreProductPermutations = /*#__PURE__*/function (_TableBasePage) { value: function hookupCountIntervalExpirationUnsealedInputs() { this.hookupChangeHandlerTableCellsWhenNotCollapsed("change", idTableMain + ' td.' + flagCountUnitMeasurementIntervalExpirationUnsealed + ' input'); } - }, { - key: "hookupActiveCheckboxes", - value: function hookupActiveCheckboxes() { - this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagActive + ' input'); - } }, { key: "leave", value: function leave() { @@ -5811,7 +5806,7 @@ var PageStoreStockItems = /*#__PURE__*/function (_TableBasePage) { this.hookupSealingInputs(); this.hookupExpirationDateInputs(); this.hookupConsumationInputs(); - this.hookupActiveCheckboxes(); + this.hookupFieldsActive(); } }, { key: "hookupProductCategoryFields", @@ -5826,16 +5821,17 @@ var PageStoreStockItems = /*#__PURE__*/function (_TableBasePage) { value: function hookupProductFields() { this.hookupTableCellDdlPreviews(idTableMain + ' td.' + flagProduct, Utils.getListFromDict(products)); } - }, { - key: "handleClickProductPermutationVariationsPreview", - value: function handleClickProductPermutationVariationsPreview(event, element) { - var row = DOM.getRowFromElement(element); - var tdProduct = row.querySelector('td.' + flagProduct); - var idProduct = DOM.getElementValueCurrent(tdProduct); - var product = products[idProduct]; - if (!product[flagHasVariations]) return; - stock_items_superPropGet(PageStoreStockItems, "handleClickProductPermutationVariationsPreview", this, 3)([event, element]); + + /* + handleClickProductPermutationVariationsPreview(event, element) { + let row = DOM.getRowFromElement(element); + let tdProduct = row.querySelector('td.' + flagProduct); + let idProduct = DOM.getElementValueCurrent(tdProduct); + let product = products[idProduct]; + if (!product[flagHasVariations]) return; + super.handleClickProductPermutationVariationsPreview(event, element); } + */ }, { key: "handleClickButtonProductPermutationVariationsAdd", value: function handleClickButtonProductPermutationVariationsAdd(event, element) { @@ -5865,7 +5861,7 @@ var PageStoreStockItems = /*#__PURE__*/function (_TableBasePage) { key: "hookupStorageLocationFields", value: function hookupStorageLocationFields() { var _this3 = this; - this.hookupEventHandler("click", idTableMain + ' td.' + flagStorageLocation, function (event, element) { + this.hookupEventHandler("click", idTableMain + ' td.' + flagStorageLocation + ' div', function (event, element) { return _this3.handleClickStorageLocationPreview(event, element); }); } @@ -5877,7 +5873,7 @@ var PageStoreStockItems = /*#__PURE__*/function (_TableBasePage) { var idPlant = element.getAttribute(attrIdPlant); var idStorageLocation = element.getAttribute(attrIdStorageLocation); var tblStorageLocation = document.createElement("table"); - tblStorageLocation.classList.add(flagProductVariations); + tblStorageLocation.classList.add(flagStorageLocation); var thead = document.createElement("thead"); var thPlant = document.createElement("th"); thPlant.textContent = 'Plant'; @@ -5892,8 +5888,9 @@ var PageStoreStockItems = /*#__PURE__*/function (_TableBasePage) { var plant, optionPlantJson, optionPlant, storageLocation, optionStorageLocationJson, optionStorageLocation; var plantKeys = Object.keys(plants); var storageLocationKeys = Object.keys(storageLocations); - var plantJson = plants[idPlant]; - var storageLocationJson = storageLocations[idStorageLocation]; + debugger; + var plantJson = idPlant != null ? plants[idPlant] : stock_items_defineProperty({}, attrIdPlant, null); + var storageLocationJson = idStorageLocation != null ? storageLocations[idStorageLocation] : stock_items_defineProperty({}, attrIdStorageLocation, null); var tdPlant = document.createElement("td"); tdPlant.classList.add(flagPlant); DOM.setElementAttributesValuesCurrentAndPrevious(tdPlant, plantJson[attrIdPlant]); @@ -5907,7 +5904,10 @@ var PageStoreStockItems = /*#__PURE__*/function (_TableBasePage) { ddlPlant.appendChild(optionPlant); plantKeys.forEach(function (plantKey) { plant = plants[plantKey]; - optionPlantJson = BusinessObjects.getOptionJsonFromObjectJson(objectJson = plant, valueSelected = plantJson[attrIdPlant]); + optionPlantJson = BusinessObjects.getOptionJsonFromObjectJson(plant, + // objectJson + plantJson[attrIdPlant] // valueSelected + ); optionPlant = DOM.createOption(optionPlantJson); if (_verbose) { console.log("optionPlant: ", optionPlant); @@ -5925,9 +5925,12 @@ var PageStoreStockItems = /*#__PURE__*/function (_TableBasePage) { console.log("optionStorageLocation: ", optionStorageLocation); } ddlStorageLocation.appendChild(optionStorageLocation); - StorageLocationKeys.forEach(function (StorageLocationKey) { - storageLocation = StorageLocations[StorageLocationKey]; - optionStorageLocationJson = BusinessObjects.getOptionJsonFromObjectJson(objectJson = storageLocation, valueSelected = storageLocationJson[attrIdStorageLocation]); + storageLocationKeys.forEach(function (StorageLocationKey) { + storageLocation = storageLocations[StorageLocationKey]; + optionStorageLocationJson = BusinessObjects.getOptionJsonFromObjectJson(storageLocation, + // objectJson + storageLocationJson[attrIdStorageLocation] // valueSelected + ); optionStorageLocation = DOM.createOption(optionStorageLocationJson); if (_verbose) { console.log("optionStorageLocation: ", optionStorageLocation); @@ -5941,9 +5944,9 @@ var PageStoreStockItems = /*#__PURE__*/function (_TableBasePage) { trBody.appendChild(tdStorageLocation); tbody.appendChild(trBody); tblStorageLocation.appendChild(tbody); - var parent = element.parentElement; - parent.innerHTML = ''; - parent.appendChild(tblStorageLocation); + var tdParent = DOM.getCellFromElement(element); + tdParent.innerHTML = ''; + tdParent.appendChild(tblStorageLocation); if (_verbose) { console.log("tblStorageLocation: ", tblStorageLocation); } @@ -6036,11 +6039,6 @@ var PageStoreStockItems = /*#__PURE__*/function (_TableBasePage) { value: function hookupDateConsumedInputs() { this.hookupChangeHandlerTableCellsWhenNotCollapsed("change", idTableMain + ' td.' + flagDateConsumed + ' input'); } - }, { - key: "hookupActiveCheckboxes", - value: function hookupActiveCheckboxes() { - this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagActive + ' input'); - } }, { key: "leave", value: function leave() { diff --git a/static/js/pages/base_table.js b/static/js/pages/base_table.js index 3cbcfacd..21d89139 100644 --- a/static/js/pages/base_table.js +++ b/static/js/pages/base_table.js @@ -49,7 +49,7 @@ export default class TableBasePage extends BasePage { if (!isPopState) { super.sharedInitialize(); this.hookupFilters(); - this.hookupButtonsAddSaveCancel(); + this.hookupButtonsSaveCancel(); this.hookupTableMain(); OverlayConfirm.hookup(() => { if (isSinglePageApp) { @@ -139,7 +139,7 @@ export default class TableBasePage extends BasePage { }) .catch(error => console.error('Error:', error)); } - hookupButtonsAddSaveCancel() { + hookupButtonsSaveCancel() { this.hookupButtonSave(); this.hookupButtonCancel(); this.toggleShowButtonsSaveCancel(false); diff --git a/static/js/pages/store/product_permutations.js b/static/js/pages/store/product_permutations.js index 7c9de399..ba40e094 100644 --- a/static/js/pages/store/product_permutations.js +++ b/static/js/pages/store/product_permutations.js @@ -211,7 +211,7 @@ export default class PageStoreProductPermutations extends TableBasePage { this.hookupSubscriptionFields(); this.hookupIdStripeProductInputs(); this.hookupExpirationFields(); - this.hookupActiveCheckboxes(); + this.hookupFieldsActive(); } hookupFieldsProductCategory() { this.hookupTableCellDdlPreviews( @@ -338,9 +338,6 @@ export default class PageStoreProductPermutations extends TableBasePage { hookupCountIntervalExpirationUnsealedInputs(){ this.hookupChangeHandlerTableCellsWhenNotCollapsed("change", idTableMain + ' td.' + flagCountUnitMeasurementIntervalExpirationUnsealed + ' input'); } - hookupActiveCheckboxes(){ - this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagActive + ' input'); - } leave() { super.leave(); diff --git a/static/js/pages/store/stock_items.js b/static/js/pages/store/stock_items.js index bad199a9..3791249b 100644 --- a/static/js/pages/store/stock_items.js +++ b/static/js/pages/store/stock_items.js @@ -143,7 +143,7 @@ export default class PageStoreStockItems extends TableBasePage { this.hookupSealingInputs(); this.hookupExpirationDateInputs(); this.hookupConsumationInputs(); - this.hookupActiveCheckboxes(); + this.hookupFieldsActive(); } hookupProductCategoryFields() { this.hookupTableCellDdlPreviews( @@ -156,6 +156,7 @@ export default class PageStoreStockItems extends TableBasePage { this.hookupTableCellDdlPreviews(idTableMain + ' td.' + flagProduct, Utils.getListFromDict(products)); } + /* handleClickProductPermutationVariationsPreview(event, element) { let row = DOM.getRowFromElement(element); let tdProduct = row.querySelector('td.' + flagProduct); @@ -164,6 +165,7 @@ export default class PageStoreStockItems extends TableBasePage { if (!product[flagHasVariations]) return; super.handleClickProductPermutationVariationsPreview(event, element); } + */ handleClickButtonProductPermutationVariationsAdd(event, element) { let row = DOM.getRowFromElement(element); let tbody = row.querySelector('tbody'); @@ -186,7 +188,7 @@ export default class PageStoreStockItems extends TableBasePage { hookupStorageLocationFields(){ this.hookupEventHandler( "click", - idTableMain + ' td.' + flagStorageLocation, + idTableMain + ' td.' + flagStorageLocation + ' div', (event, element) => this.handleClickStorageLocationPreview(event, element) ); } @@ -195,7 +197,7 @@ export default class PageStoreStockItems extends TableBasePage { let idPlant = element.getAttribute(attrIdPlant); let idStorageLocation = element.getAttribute(attrIdStorageLocation); let tblStorageLocation = document.createElement("table"); - tblStorageLocation.classList.add(flagProductVariations); + tblStorageLocation.classList.add(flagStorageLocation); let thead = document.createElement("thead"); let thPlant = document.createElement("th"); thPlant.textContent = 'Plant'; @@ -212,8 +214,13 @@ export default class PageStoreStockItems extends TableBasePage { let plantKeys = Object.keys(plants); let storageLocationKeys = Object.keys(storageLocations); - let plantJson = plants[idPlant]; - let storageLocationJson = storageLocations[idStorageLocation]; + debugger; + let plantJson = idPlant != null ? plants[idPlant] : { + [attrIdPlant]: null, + }; + let storageLocationJson = idStorageLocation != null ? storageLocations[idStorageLocation] : { + [attrIdStorageLocation]: null, + }; let tdPlant = document.createElement("td"); tdPlant.classList.add(flagPlant); @@ -230,8 +237,8 @@ export default class PageStoreStockItems extends TableBasePage { plantKeys.forEach((plantKey) => { plant = plants[plantKey]; optionPlantJson = BusinessObjects.getOptionJsonFromObjectJson( - objectJson = plant, - valueSelected = plantJson[attrIdPlant] + plant, // objectJson + plantJson[attrIdPlant] // valueSelected ); optionPlant = DOM.createOption(optionPlantJson); if (_verbose) { console.log("optionPlant: ", optionPlant); } @@ -250,11 +257,11 @@ export default class PageStoreStockItems extends TableBasePage { if (_verbose) { console.log("optionStorageLocation: ", optionStorageLocation); } ddlStorageLocation.appendChild(optionStorageLocation); - StorageLocationKeys.forEach((StorageLocationKey) => { - storageLocation = StorageLocations[StorageLocationKey]; + storageLocationKeys.forEach((StorageLocationKey) => { + storageLocation = storageLocations[StorageLocationKey]; optionStorageLocationJson = BusinessObjects.getOptionJsonFromObjectJson( - objectJson = storageLocation, - valueSelected = storageLocationJson[attrIdStorageLocation] + storageLocation, // objectJson + storageLocationJson[attrIdStorageLocation] // valueSelected ); optionStorageLocation = DOM.createOption(optionStorageLocationJson); if (_verbose) { console.log("optionStorageLocation: ", optionStorageLocation); } @@ -269,9 +276,9 @@ export default class PageStoreStockItems extends TableBasePage { tbody.appendChild(trBody); tblStorageLocation.appendChild(tbody); - let parent = element.parentElement; - parent.innerHTML = ''; - parent.appendChild(tblStorageLocation); + let tdParent = DOM.getCellFromElement(element); + tdParent.innerHTML = ''; + tdParent.appendChild(tblStorageLocation); if (_verbose) { console.log("tblStorageLocation: ", tblStorageLocation); } this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagPlant + ' select', (event, element) => { this.handleChangeStoragePlantDdl(event, element); }); this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagStorageLocation + ' select', (event, element) => { this.handleChangeStorageLocationDdl(event, element); }); @@ -342,10 +349,6 @@ export default class PageStoreStockItems extends TableBasePage { this.hookupChangeHandlerTableCellsWhenNotCollapsed("change", idTableMain + ' td.' + flagDateConsumed + ' input'); } - hookupActiveCheckboxes(){ - this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagActive + ' input'); - } - leave() { super.leave(); } diff --git a/templates/pages/store/_stock_items.html b/templates/pages/store/_stock_items.html index 7ff12aa4..d1051322 100644 --- a/templates/pages/store/_stock_items.html +++ b/templates/pages/store/_stock_items.html @@ -116,10 +116,12 @@ #} var currencies = {{ model.convert_list_objects_to_dict_json_by_attribute_key_default(model.currencies) | tojson | safe }}; + var plants = {{ model.convert_list_objects_to_dict_json_by_attribute_key_default(model.plants) | tojson | safe }}; var products = {{ model.convert_list_objects_to_dict_json_by_attribute_key_default(model.category_list_filters.get_list_products()) | tojson | safe }}; var productCategories = {{ model.convert_list_objects_to_dict_json_by_attribute_key_default(model.category_list_filters.categories) | tojson | safe }}; var productVariations = {{ model.convert_list_objects_to_dict_json_by_attribute_key_default(model.variations) | tojson | safe }}; var productVariationTypes = {{ model.convert_list_objects_to_dict_json_by_attribute_key_default(model.variation_types) | tojson | safe }}; + var storageLocations = {{ model.convert_list_objects_to_dict_json_by_attribute_key_default(model.storage_locations) | tojson | safe }}; {# var unitMeasurements = {{ units_measurement_dict | tojson | safe }}; var unitMeasurementsTime = {{ units_measurement_time_dict | tojson | safe }};