From 13a4f350bbbe0e184bcedafddc522fa20238833e Mon Sep 17 00:00:00 2001 From: teddy Date: Fri, 15 Nov 2024 10:04:38 +0000 Subject: [PATCH] Fix: Product Permutations save on production. --- .../3206_tri_Shop_Product_Permutation.sql | 4 +- static/MySQL/9000_populate.sql | 53 +++++++++---------- static/dist/js/main.bundle.js | 19 ++++--- static/js/pages/base_table.js | 3 +- 4 files changed, 39 insertions(+), 40 deletions(-) diff --git a/static/MySQL/3206_tri_Shop_Product_Permutation.sql b/static/MySQL/3206_tri_Shop_Product_Permutation.sql index 9754d86b..de1a23a4 100644 --- a/static/MySQL/3206_tri_Shop_Product_Permutation.sql +++ b/static/MySQL/3206_tri_Shop_Product_Permutation.sql @@ -32,7 +32,7 @@ BEGIN IF (NOT ( 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 SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Recurrence interval ID must be a unit of time.'; @@ -40,7 +40,7 @@ BEGIN IF (NOT ( 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 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' diff --git a/static/MySQL/9000_populate.sql b/static/MySQL/9000_populate.sql index 33a86131..fcba86bb 100644 --- a/static/MySQL/9000_populate.sql +++ b/static/MySQL/9000_populate.sql @@ -636,50 +636,49 @@ INSERT INTO partsltd_prod.Shop_Product_Change_Set ( ) VALUES ( 'Update Variation Display Orders' ) ; -WITH RECURSIVE RANKED AS ( +UPDATE partsltd_prod.Shop_Variation V +INNER JOIN ( SELECT V.id_variation, RANK() OVER (ORDER BY - CONCAT( - CASE WHEN V.count_unit_measurement = FLOOR(V.count_unit_measurement) THEN - LPAD(CAST(V.count_unit_measurement AS CHAR), 25, '0') - ELSE - CONCAT( - LPAD( - CAST(FLOOR(V.count_unit_measurement) AS CHAR) - , 25 - , '0' - ) - , SUBSTRING( - CAST(V.count_unit_measurement AS CHAR) - FROM LOCATE('.', CAST(V.count_unit_measurement AS CHAR)) - ) - ) - END + CONCAT( + CASE WHEN V.count_unit_measurement = FLOOR(V.count_unit_measurement) THEN + LPAD(CAST(V.count_unit_measurement AS CHAR), 25, '0') + ELSE + CONCAT( + LPAD( + CAST(FLOOR(V.count_unit_measurement) AS CHAR) + , 25 + , '0' + ) + , SUBSTRING( + CAST(V.count_unit_measurement AS CHAR) + FROM LOCATE('.', CAST(V.count_unit_measurement AS CHAR)) + ) + ) + END , ' ' , IFNULL(IFNULL(UM.symbol, UM.name_singular), '(No Unit of Measurement)') - ) - ) as new_order + ) + ) as new_order FROM partsltd_prod.Shop_Variation V 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 WHERE - V.id_type = 2 -) -UPDATE partsltd_prod.Shop_Variation V -INNER JOIN RANKED ON V.id_variation = RANKED.id_variation + V.id_type = 2 +) AS RANKED ON V.id_variation = RANKED.id_variation JOIN ( - SELECT CS.id_change_set + SELECT CS.id_change_set FROM partsltd_prod.Shop_Product_Change_Set CS ORDER BY CS.id_change_set DESC LIMIT 1 ) AS CS SET - V.display_order = RANKED.new_order + V.display_order = RANKED.new_order , V.id_change_set = CS.id_change_set WHERE - V.id_type = 2 + V.id_type = 2 ; # Product Permutation Variation Links diff --git a/static/dist/js/main.bundle.js b/static/dist/js/main.bundle.js index 51ba5f36..55abc5e1 100644 --- a/static/dist/js/main.bundle.js +++ b/static/dist/js/main.bundle.js @@ -2012,12 +2012,9 @@ var OverlayError = /*#__PURE__*/function () { ;// CONCATENATED MODULE: ./static/js/pages/base_table.js function base_table_typeof(o) { "@babel/helpers - typeof"; return base_table_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, base_table_typeof(o); } -function base_table_defineProperty(e, r, t) { return (r = base_table_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } function base_table_classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } function base_table_defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, base_table_toPropertyKey(o.key), o); } } function base_table_createClass(e, r, t) { return r && base_table_defineProperties(e.prototype, r), t && base_table_defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; } -function base_table_toPropertyKey(t) { var i = base_table_toPrimitive(t, "string"); return "symbol" == base_table_typeof(i) ? i : i + ""; } -function base_table_toPrimitive(t, r) { if ("object" != base_table_typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != base_table_typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } function base_table_callSuper(t, o, e) { return o = base_table_getPrototypeOf(o), base_table_possibleConstructorReturn(t, base_table_isNativeReflectConstruct() ? Reflect.construct(o, e || [], base_table_getPrototypeOf(t).constructor) : o.apply(t, e)); } function base_table_possibleConstructorReturn(t, e) { if (e && ("object" == base_table_typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return base_table_assertThisInitialized(t); } function base_table_assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; } @@ -2028,6 +2025,9 @@ function base_table_superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) & function base_table_getPrototypeOf(t) { return base_table_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, base_table_getPrototypeOf(t); } function base_table_inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && base_table_setPrototypeOf(t, e); } function base_table_setPrototypeOf(t, e) { return base_table_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, base_table_setPrototypeOf(t, e); } +function base_table_defineProperty(e, r, t) { return (r = base_table_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } +function base_table_toPropertyKey(t) { var i = base_table_toPrimitive(t, "string"); return "symbol" == base_table_typeof(i) ? i : i + ""; } +function base_table_toPrimitive(t, r) { if ("object" != base_table_typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != base_table_typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } @@ -2047,12 +2047,18 @@ var TableBasePage = /*#__PURE__*/function (_BasePage) { var _this; base_table_classCallCheck(this, TableBasePage); _this = base_table_callSuper(this, TableBasePage, [router]); + base_table_defineProperty(_this, "getAndLoadFilteredTableContent", function () { + _this.callFilterTableContent()["catch"](function (error) { + return console.error('Error:', error); + }); + }); _this.cursorYInitial = null; _this.rowInitial = null; _this.placeholder = null; _this.dragSrcEl = null; _this.dragSrcRow = null; _this.hookupTableCellDdls = _this.hookupTableCellDdls.bind(_this); + _this.getAndLoadFilteredTableContent = _this.getAndLoadFilteredTableContent.bind(_this); return _this; } base_table_inherits(TableBasePage, _BasePage); @@ -2130,13 +2136,6 @@ var TableBasePage = /*#__PURE__*/function (_BasePage) { _this3.getAndLoadFilteredTableContent(); }); } - }, { - key: "getAndLoadFilteredTableContent", - value: function getAndLoadFilteredTableContent() { - this.callFilterTableContent()["catch"](function (error) { - return console.error('Error:', error); - }); - } }, { key: "getFormFilters", value: function getFormFilters() { diff --git a/static/js/pages/base_table.js b/static/js/pages/base_table.js index 3c59b31b..f266c045 100644 --- a/static/js/pages/base_table.js +++ b/static/js/pages/base_table.js @@ -25,6 +25,7 @@ export default class TableBasePage extends BasePage { this.dragSrcRow = null; this.hookupTableCellDdls = this.hookupTableCellDdls.bind(this); + this.getAndLoadFilteredTableContent = this.getAndLoadFilteredTableContent.bind(this); } initialize(isPopState = false) { @@ -87,7 +88,7 @@ export default class TableBasePage extends BasePage { this.getAndLoadFilteredTableContent(); }); } - getAndLoadFilteredTableContent() { + getAndLoadFilteredTableContent = () => { this.callFilterTableContent() .catch(error => console.error('Error:', error)); }