Fix: Product Permutations save on production.

This commit is contained in:
2024-11-15 12:33:46 +00:00
parent 13a4f350bb
commit 667fbca06e
5 changed files with 48 additions and 40 deletions

View File

@@ -4569,7 +4569,7 @@ BEGIN
IF (NOT ( IF (NOT (
NEW.id_unit_measurement_interval_recurrence IS NULL NEW.id_unit_measurement_interval_recurrence IS NULL
OR NEW.id_unit_measurement_interval_recurrence NOT IN (SELECT id_unit_measurement FROM Shop_Unit_Measurement WHERE is_unit_of_time = 1) OR NEW.id_unit_measurement_interval_recurrence IN (SELECT id_unit_measurement FROM Shop_Unit_Measurement WHERE is_unit_of_time = 1)
)) THEN )) THEN
SIGNAL SQLSTATE '45000' SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'Recurrence interval ID must be a unit of time.'; SET MESSAGE_TEXT = 'Recurrence interval ID must be a unit of time.';
@@ -4577,7 +4577,7 @@ BEGIN
IF (NOT ( IF (NOT (
NEW.id_unit_measurement_interval_expiration_unsealed IS NULL NEW.id_unit_measurement_interval_expiration_unsealed IS NULL
OR NEW.id_unit_measurement_interval_expiration_unsealed NOT IN (SELECT id_unit_measurement FROM Shop_Unit_Measurement WHERE is_unit_of_time = 1) OR NEW.id_unit_measurement_interval_expiration_unsealed IN (SELECT id_unit_measurement FROM Shop_Unit_Measurement WHERE is_unit_of_time = 1)
)) THEN )) THEN
SET v_msg := CONCAT('Unsealed expiration interval ID must be a unit of time. Invalid value: ', CAST(NEW.id_unit_measurement_interval_expiration_unsealed AS CHAR)); SET v_msg := CONCAT('Unsealed expiration interval ID must be a unit of time. Invalid value: ', CAST(NEW.id_unit_measurement_interval_expiration_unsealed AS CHAR));
SIGNAL SQLSTATE '45000' SIGNAL SQLSTATE '45000'
@@ -24028,50 +24028,49 @@ INSERT INTO partsltd_prod.Shop_Product_Change_Set (
) )
VALUES ( 'Update Variation Display Orders' ) VALUES ( 'Update Variation Display Orders' )
; ;
WITH RECURSIVE RANKED AS ( UPDATE partsltd_prod.Shop_Variation V
INNER JOIN (
SELECT SELECT
V.id_variation, V.id_variation,
RANK() OVER (ORDER BY RANK() OVER (ORDER BY
CONCAT( CONCAT(
CASE WHEN V.count_unit_measurement = FLOOR(V.count_unit_measurement) THEN CASE WHEN V.count_unit_measurement = FLOOR(V.count_unit_measurement) THEN
LPAD(CAST(V.count_unit_measurement AS CHAR), 25, '0') LPAD(CAST(V.count_unit_measurement AS CHAR), 25, '0')
ELSE ELSE
CONCAT( CONCAT(
LPAD( LPAD(
CAST(FLOOR(V.count_unit_measurement) AS CHAR) CAST(FLOOR(V.count_unit_measurement) AS CHAR)
, 25 , 25
, '0' , '0'
) )
, SUBSTRING( , SUBSTRING(
CAST(V.count_unit_measurement AS CHAR) CAST(V.count_unit_measurement AS CHAR)
FROM LOCATE('.', CAST(V.count_unit_measurement AS CHAR)) FROM LOCATE('.', CAST(V.count_unit_measurement AS CHAR))
) )
) )
END END
, ' ' , ' '
, IFNULL(IFNULL(UM.symbol, UM.name_singular), '(No Unit of Measurement)') , IFNULL(IFNULL(UM.symbol, UM.name_singular), '(No Unit of Measurement)')
) )
) as new_order ) as new_order
FROM partsltd_prod.Shop_Variation V FROM partsltd_prod.Shop_Variation V
INNER JOIN partsltd_prod.Shop_Unit_Measurement UM INNER JOIN partsltd_prod.Shop_Unit_Measurement UM
ON V.id_unit_measurement = UM.id_unit_measurement ON V.id_unit_measurement = UM.id_unit_measurement
AND UM.active = 1 AND UM.active = 1
WHERE WHERE
V.id_type = 2 V.id_type = 2
) ) AS RANKED ON V.id_variation = RANKED.id_variation
UPDATE partsltd_prod.Shop_Variation V
INNER JOIN RANKED ON V.id_variation = RANKED.id_variation
JOIN ( JOIN (
SELECT CS.id_change_set SELECT CS.id_change_set
FROM partsltd_prod.Shop_Product_Change_Set CS FROM partsltd_prod.Shop_Product_Change_Set CS
ORDER BY CS.id_change_set DESC ORDER BY CS.id_change_set DESC
LIMIT 1 LIMIT 1
) AS CS ) AS CS
SET SET
V.display_order = RANKED.new_order V.display_order = RANKED.new_order
, V.id_change_set = CS.id_change_set , V.id_change_set = CS.id_change_set
WHERE WHERE
V.id_type = 2 V.id_type = 2
; ;
# Product Permutation Variation Links # Product Permutation Variation Links

View File

@@ -324,6 +324,8 @@ var DOM = /*#__PURE__*/function () {
returnVal = element.value; returnVal = element.value;
} else if (element.tagName === 'BUTTON' && element.classList.contains(flagActive)) { } else if (element.tagName === 'BUTTON' && element.classList.contains(flagActive)) {
returnVal = element.classList.contains(flagDelete); returnVal = element.classList.contains(flagDelete);
} else if (element.tagName === 'TD') {
returnVal = DOM.getElementAttributeValueCurrent(element);
} else { } else {
returnVal = element.textContent; returnVal = element.textContent;
} }
@@ -2470,9 +2472,9 @@ var TableBasePage = /*#__PURE__*/function (_BasePage) {
wasDirtyParentRows: wasDirtyParentRows wasDirtyParentRows: wasDirtyParentRows
}); });
} }
var td = DOM.getCellFromElement(element);
DOM.setElementAttributeValueCurrent(td, DOM.getElementAttributeValueCurrent(element));
if (isDirtyElement != wasDirtyElement) { if (isDirtyElement != wasDirtyElement) {
var td = DOM.getCellFromElement(element);
DOM.setElementAttributeValueCurrent(td, DOM.getElementAttributeValueCurrent(element));
DOM.handleDirtyElement(td, isDirtyElement); DOM.handleDirtyElement(td, isDirtyElement);
this.updateAndToggleShowButtonsSaveCancel(); this.updateAndToggleShowButtonsSaveCancel();
this.cascadeChangedIsDirtyNestedElementCellTable(element, isDirtyElement, wasDirtyParentRows); this.cascadeChangedIsDirtyNestedElementCellTable(element, isDirtyElement, wasDirtyParentRows);
@@ -3025,14 +3027,14 @@ var TableBasePage = /*#__PURE__*/function (_BasePage) {
}, { }, {
key: "handleChangeDdlProductVariationOrVariationType", key: "handleChangeDdlProductVariationOrVariationType",
value: function handleChangeDdlProductVariationOrVariationType(event, element) { value: function handleChangeDdlProductVariationOrVariationType(event, element) {
this.updateProductPermutationVariations(element);
this.handleChangeNestedElementCellTable(event, element); this.handleChangeNestedElementCellTable(event, element);
this.updateProductPermutationVariations(element);
} }
}, { }, {
key: "hookupDdlsProductPermutationVariation", key: "hookupDdlsProductPermutationVariation",
value: function hookupDdlsProductPermutationVariation() { value: function hookupDdlsProductPermutationVariation() {
var _this22 = this; var _this22 = this;
this.hookupTableCellDdls(idTableMain + ' td.' + flagProductVariations + ' td.' + flagProductVariation, function (event, ddlVariation) { this.hookupTableCellDdls(idTableMain + ' td.' + flagProductVariations + ' td.' + flagProductVariation + ' select', function (event, ddlVariation) {
_this22.handleChangeDdlProductVariationOrVariationType(event, ddlVariation); _this22.handleChangeDdlProductVariationOrVariationType(event, ddlVariation);
}); });
} }
@@ -3073,7 +3075,7 @@ var TableBasePage = /*#__PURE__*/function (_BasePage) {
var variationsCell = element.closest('td.' + flagProductVariations); var variationsCell = element.closest('td.' + flagProductVariations);
var variationPairsString = this.getProductPermutationVariationsText(variationsCell); var variationPairsString = this.getProductPermutationVariationsText(variationsCell);
DOM.setElementAttributeValueCurrent(variationsCell, variationPairsString); DOM.setElementAttributeValueCurrent(variationsCell, variationPairsString);
DOM.isElementDirty(variationsCell); this.handleChangeNestedElementCellTable(null, variationsCell);
} }
}, { }, {
key: "getProductPermutationVariationsText", key: "getProductPermutationVariationsText",
@@ -4739,6 +4741,7 @@ var PageStoreProductPermutations = /*#__PURE__*/function (_TableBasePage) {
this.hookupFieldsProductPermutationVariation(); this.hookupFieldsProductPermutationVariation();
this.hookupDescriptionTextareas(); this.hookupDescriptionTextareas();
this.hookupCostFields(); this.hookupCostFields();
this.hookupProfitFields();
this.hookupLatencyManufactureInputs(); this.hookupLatencyManufactureInputs();
this.hookupQuantityFields(); this.hookupQuantityFields();
this.hookupSubscriptionFields(); this.hookupSubscriptionFields();
@@ -4797,6 +4800,7 @@ var PageStoreProductPermutations = /*#__PURE__*/function (_TableBasePage) {
}, { }, {
key: "hookupProfitInputs", key: "hookupProfitInputs",
value: function hookupProfitInputs() { value: function hookupProfitInputs() {
debugger;
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagProfitLocalMin + ' input'); this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagProfitLocalMin + ' input');
} }
}, { }, {

View File

@@ -123,6 +123,9 @@ export default class DOM {
else if (element.tagName === 'BUTTON' && element.classList.contains(flagActive)) { else if (element.tagName === 'BUTTON' && element.classList.contains(flagActive)) {
returnVal = element.classList.contains(flagDelete); returnVal = element.classList.contains(flagDelete);
} }
else if (element.tagName === 'TD') {
returnVal = DOM.getElementAttributeValueCurrent(element);
}
else { else {
returnVal = element.textContent; returnVal = element.textContent;
} }

View File

@@ -362,9 +362,9 @@ export default class TableBasePage extends BasePage {
let wasDirtyElement = element.classList.contains(flagDirty); let wasDirtyElement = element.classList.contains(flagDirty);
let isDirtyElement = DOM.updateAndCheckIsElementDirty(element); let isDirtyElement = DOM.updateAndCheckIsElementDirty(element);
if (_verbose) { console.log({isDirtyElement, wasDirtyElement, wasDirtyParentRows}); } if (_verbose) { console.log({isDirtyElement, wasDirtyElement, wasDirtyParentRows}); }
let td = DOM.getCellFromElement(element);
DOM.setElementAttributeValueCurrent(td, DOM.getElementAttributeValueCurrent(element));
if (isDirtyElement != wasDirtyElement) { if (isDirtyElement != wasDirtyElement) {
let td = DOM.getCellFromElement(element);
DOM.setElementAttributeValueCurrent(td, DOM.getElementAttributeValueCurrent(element));
DOM.handleDirtyElement(td, isDirtyElement); DOM.handleDirtyElement(td, isDirtyElement);
this.updateAndToggleShowButtonsSaveCancel(); this.updateAndToggleShowButtonsSaveCancel();
this.cascadeChangedIsDirtyNestedElementCellTable(element, isDirtyElement, wasDirtyParentRows); this.cascadeChangedIsDirtyNestedElementCellTable(element, isDirtyElement, wasDirtyParentRows);
@@ -849,11 +849,11 @@ export default class TableBasePage extends BasePage {
); );
} }
handleChangeDdlProductVariationOrVariationType(event, element) { handleChangeDdlProductVariationOrVariationType(event, element) {
this.updateProductPermutationVariations(element);
this.handleChangeNestedElementCellTable(event, element); this.handleChangeNestedElementCellTable(event, element);
this.updateProductPermutationVariations(element);
} }
hookupDdlsProductPermutationVariation() { hookupDdlsProductPermutationVariation() {
this.hookupTableCellDdls(idTableMain + ' td.' + flagProductVariations + ' td.' + flagProductVariation, (event, ddlVariation) => { this.handleChangeDdlProductVariationOrVariationType(event, ddlVariation); }); this.hookupTableCellDdls(idTableMain + ' td.' + flagProductVariations + ' td.' + flagProductVariation + ' select', (event, ddlVariation) => { this.handleChangeDdlProductVariationOrVariationType(event, ddlVariation); });
} }
hookupButtonsProductPermutationVariationAddDelete() { hookupButtonsProductPermutationVariationAddDelete() {
let selectorButton = idTableMain + ' td.' + flagProductVariations + ' tr.' + flagProductVariation + ' button'; let selectorButton = idTableMain + ' td.' + flagProductVariations + ' tr.' + flagProductVariation + ' button';
@@ -884,7 +884,7 @@ export default class TableBasePage extends BasePage {
let variationsCell = element.closest('td.' + flagProductVariations); let variationsCell = element.closest('td.' + flagProductVariations);
let variationPairsString = this.getProductPermutationVariationsText(variationsCell); let variationPairsString = this.getProductPermutationVariationsText(variationsCell);
DOM.setElementAttributeValueCurrent(variationsCell, variationPairsString); DOM.setElementAttributeValueCurrent(variationsCell, variationPairsString);
DOM.isElementDirty(variationsCell); this.handleChangeNestedElementCellTable(null, variationsCell);
} }
getProductPermutationVariationsText(variationsTd) { getProductPermutationVariationsText(variationsTd) {
let rows = variationsTd.querySelectorAll(':scope tbody tr'); let rows = variationsTd.querySelectorAll(':scope tbody tr');

View File

@@ -213,6 +213,7 @@ export default class PageStoreProductPermutations extends TableBasePage {
this.hookupFieldsProductPermutationVariation(); this.hookupFieldsProductPermutationVariation();
this.hookupDescriptionTextareas(); this.hookupDescriptionTextareas();
this.hookupCostFields(); this.hookupCostFields();
this.hookupProfitFields();
this.hookupLatencyManufactureInputs(); this.hookupLatencyManufactureInputs();
this.hookupQuantityFields(); this.hookupQuantityFields();
this.hookupSubscriptionFields(); this.hookupSubscriptionFields();
@@ -256,7 +257,8 @@ export default class PageStoreProductPermutations extends TableBasePage {
this.hookupTableCellDdlPreviews(idTableMain + ' td.' + flagCurrency, Utils.getListFromDict(currencies)); this.hookupTableCellDdlPreviews(idTableMain + ' td.' + flagCurrency, Utils.getListFromDict(currencies));
} }
*/ */
hookupProfitInputs(){ hookupProfitInputs() {
debugger;
this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagProfitLocalMin + ' input'); this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagProfitLocalMin + ' input');
} }
hookupLatencyManufactureInputs(){ hookupLatencyManufactureInputs(){