From 596503a04373ad21bdde6fd591974c167f36f93d Mon Sep 17 00:00:00 2001 From: Bahlai Pavlo Date: Fri, 28 Feb 2025 14:43:24 +0200 Subject: [PATCH 1/7] magento/magento2#39481: Completely removing a gallery-image from be keeps scope roles/types set (base/small/thumbnail) and after re-adding "old" roles/types appear - fixed issue with "old" roles/types after re-adding images --- .../Magento/Catalog/view/adminhtml/web/js/product-gallery.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/code/Magento/Catalog/view/adminhtml/web/js/product-gallery.js b/app/code/Magento/Catalog/view/adminhtml/web/js/product-gallery.js index c281e780d9173..2796fb476ec31 100644 --- a/app/code/Magento/Catalog/view/adminhtml/web/js/product-gallery.js +++ b/app/code/Magento/Catalog/view/adminhtml/web/js/product-gallery.js @@ -355,6 +355,11 @@ define([ imageData.isRemoved = true; $imageContainer.addClass('removed').hide().find('.is-removed').val(1); + $.each(this.options.types, $.proxy(function (index, type) { + this.element.find('.image-' + type.code).val('no_selection'); + this.options.types[index].value = 'no_selection'; + }, this)); + this._contentUpdated(); }, From baf8e32f2d7c7f2152ac751e496baf8ced33e7fe Mon Sep 17 00:00:00 2001 From: Bahlai Pavlo Date: Fri, 28 Feb 2025 15:59:15 +0200 Subject: [PATCH 2/7] magento/magento2#39481: Completely removing a gallery-image from be keeps scope roles/types set (base/small/thumbnail) and after re-adding "old" roles/types appear - changed copyright --- .../Magento/Catalog/view/adminhtml/web/js/product-gallery.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Catalog/view/adminhtml/web/js/product-gallery.js b/app/code/Magento/Catalog/view/adminhtml/web/js/product-gallery.js index 2796fb476ec31..0a4baa2dc40e8 100644 --- a/app/code/Magento/Catalog/view/adminhtml/web/js/product-gallery.js +++ b/app/code/Magento/Catalog/view/adminhtml/web/js/product-gallery.js @@ -1,6 +1,6 @@ /** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. + * Copyright 2015 Adobe + * All Rights Reserved. */ /** From 8b59433d9fbd7fac86c0527476d688e8895c8f64 Mon Sep 17 00:00:00 2001 From: Bahlai Pavlo Date: Mon, 3 Mar 2025 14:52:23 +0200 Subject: [PATCH 3/7] magento/magento2#39640: Completely removing a gallery-image from be keeps scope roles/types set (base/small/thumbnail) and after re-adding "old" roles/types appear - rolled back a file that was changed by mistake for another issue --- .../view/adminhtml/web/js/product-gallery.js | 9 ++------- .../view/base/web/js/dynamic-rows/dynamic-rows.js | 15 +++++++-------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/app/code/Magento/Catalog/view/adminhtml/web/js/product-gallery.js b/app/code/Magento/Catalog/view/adminhtml/web/js/product-gallery.js index 0a4baa2dc40e8..c281e780d9173 100644 --- a/app/code/Magento/Catalog/view/adminhtml/web/js/product-gallery.js +++ b/app/code/Magento/Catalog/view/adminhtml/web/js/product-gallery.js @@ -1,6 +1,6 @@ /** - * Copyright 2015 Adobe - * All Rights Reserved. + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. */ /** @@ -355,11 +355,6 @@ define([ imageData.isRemoved = true; $imageContainer.addClass('removed').hide().find('.is-removed').val(1); - $.each(this.options.types, $.proxy(function (index, type) { - this.element.find('.image-' + type.code).val('no_selection'); - this.options.types[index].value = 'no_selection'; - }, this)); - this._contentUpdated(); }, diff --git a/app/code/Magento/Ui/view/base/web/js/dynamic-rows/dynamic-rows.js b/app/code/Magento/Ui/view/base/web/js/dynamic-rows/dynamic-rows.js index c0606e44e964f..243f4a8de293c 100644 --- a/app/code/Magento/Ui/view/base/web/js/dynamic-rows/dynamic-rows.js +++ b/app/code/Magento/Ui/view/base/web/js/dynamic-rows/dynamic-rows.js @@ -1,6 +1,6 @@ /** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. + * Copyright 2015 Adobe + * All Rights Reserved. */ /** @@ -691,12 +691,11 @@ define([ processingAddChild: function (ctx, index, prop) { this.bubble('addChild', false); - if (this.relatedData.length && this.relatedData.length % this.pageSize === 0) { - this.pages(this.pages() + 1); - this.nextPage(); - } else if (~~this.currentPage() !== this.pages()) { - this.currentPage(this.pages()); - } + var newTotal = this.relatedData.length + 1; + var newPages = Math.ceil(newTotal / this.pageSize); + + this.pages(newPages); + this.currentPage(newPages); this.addChild(ctx, index, prop); }, From 01ef9889f3f0406bd6bbe4710cd1917ddff775da Mon Sep 17 00:00:00 2001 From: Bahlai Pavlo Date: Tue, 4 Mar 2025 14:23:48 +0200 Subject: [PATCH 4/7] magento/magento2#39640: Issue with the Customizable Options grid on the product page in the admin panel - fixed "var" declaration in method --- .../Ui/view/base/web/js/dynamic-rows/dynamic-rows.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Ui/view/base/web/js/dynamic-rows/dynamic-rows.js b/app/code/Magento/Ui/view/base/web/js/dynamic-rows/dynamic-rows.js index 243f4a8de293c..8d88e49fb30d4 100644 --- a/app/code/Magento/Ui/view/base/web/js/dynamic-rows/dynamic-rows.js +++ b/app/code/Magento/Ui/view/base/web/js/dynamic-rows/dynamic-rows.js @@ -689,10 +689,13 @@ define([ * @param {Number|String} prop - additional property to element */ processingAddChild: function (ctx, index, prop) { + var newTotal, + newPages; + this.bubble('addChild', false); - var newTotal = this.relatedData.length + 1; - var newPages = Math.ceil(newTotal / this.pageSize); + newTotal = this.relatedData.length + 1; + newPages = Math.ceil(newTotal / this.pageSize); this.pages(newPages); this.currentPage(newPages); From 93e0a343911723537ddf78c36b75a3a1bb5cac1d Mon Sep 17 00:00:00 2001 From: Bahlai Pavlo Date: Tue, 8 Apr 2025 17:04:09 +0300 Subject: [PATCH 5/7] magento/magento2#39640: Issue with the Customizable Options grid on the product page in the admin panel - changed copyright --- .../Magento/Ui/view/base/web/js/dynamic-rows/dynamic-rows.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Ui/view/base/web/js/dynamic-rows/dynamic-rows.js b/app/code/Magento/Ui/view/base/web/js/dynamic-rows/dynamic-rows.js index 8d88e49fb30d4..8b4aeab762e13 100644 --- a/app/code/Magento/Ui/view/base/web/js/dynamic-rows/dynamic-rows.js +++ b/app/code/Magento/Ui/view/base/web/js/dynamic-rows/dynamic-rows.js @@ -1,5 +1,5 @@ /** - * Copyright 2015 Adobe + * Copyright 2016 Adobe * All Rights Reserved. */ From 57b2ab03e209a1855bde9c0160e37d5caa7908dc Mon Sep 17 00:00:00 2001 From: engcom-Dash Date: Mon, 12 May 2025 16:47:12 +0530 Subject: [PATCH 6/7] Added Jasmine test coverage for fix --- .../base/js/dynamic-rows/dynamic-rows.test.js | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/dynamic-rows/dynamic-rows.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/dynamic-rows/dynamic-rows.test.js index 1101770b0faa2..c889344b5a81c 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/dynamic-rows/dynamic-rows.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/dynamic-rows/dynamic-rows.test.js @@ -1,6 +1,6 @@ /** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. + * Copyright 2017 Adobe + * All Rights Reserved. */ /* eslint-disable max-nested-callbacks */ @@ -204,5 +204,36 @@ define([ expect(model.pages()).toEqual(2); expect(model.currentPage()).toEqual(2); }); + + it('should process pages before addChild', function () { + var ctx = {}; // Mock context + var index = 5; + var prop = 'someProp'; + model.pageSize = 2; + model.relatedData = [ + { + name: 'first' + }, + { + name: 'second' + }, + { + name: 'third' + }, + { + name: 'fourth' + }, + { + name: 'fifth' + } + ]; + model.bubble = jasmine.createSpy(); + model.addChild = jasmine.createSpy(); + model.processingAddChild(ctx, index, prop); + expect(model.bubble).toHaveBeenCalledWith('addChild', false); + expect(model.pages()).toEqual(3); + expect(model.currentPage()).toEqual(3); + expect(model.addChild).toHaveBeenCalledWith(ctx, index, prop); + }); }); }); From 9e58f2f5f2093cd7870ebebacbd1224b9006ac75 Mon Sep 17 00:00:00 2001 From: engcom-Dash Date: Wed, 14 May 2025 11:16:37 +0530 Subject: [PATCH 7/7] Fixed Static Failure --- .../Magento/Ui/base/js/dynamic-rows/dynamic-rows.test.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/dynamic-rows/dynamic-rows.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/dynamic-rows/dynamic-rows.test.js index c889344b5a81c..31ac28d598578 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/dynamic-rows/dynamic-rows.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/dynamic-rows/dynamic-rows.test.js @@ -206,9 +206,10 @@ define([ }); it('should process pages before addChild', function () { - var ctx = {}; // Mock context - var index = 5; - var prop = 'someProp'; + var ctx = {}, + index = 5, + prop = 'someProp'; + model.pageSize = 2; model.relatedData = [ {