From 63fa8842495e43dddd96b4272e625af6ec4712f5 Mon Sep 17 00:00:00 2001 From: kirsty-hames Date: Wed, 16 Aug 2023 15:32:44 +0100 Subject: [PATCH 1/4] Update item count for grouped items --- js/BoxMenuGroupView.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/js/BoxMenuGroupView.js b/js/BoxMenuGroupView.js index 59f4146..3dff073 100644 --- a/js/BoxMenuGroupView.js +++ b/js/BoxMenuGroupView.js @@ -11,6 +11,19 @@ class BoxMenuGroupView extends MenuItemView { _.defer(this.addChildren.bind(this)); this.$el.imageready(this.setReadyStatus.bind(this)); this.$el.parents('.boxmenu__item-container').addClass('has-groups'); + this.updateItemCount(); + } + + updateItemCount() { + let nthChild = 0; + const models = this.model.getChildren().models; + models.forEach(model => { + nthChild++; + model.set({ + _nthChild: nthChild, + _totalChild: models.length + }); + }); } } From 159248360db04c548527fcd2588c4224727670d8 Mon Sep 17 00:00:00 2001 From: kirsty-hames Date: Wed, 16 Aug 2023 16:36:49 +0100 Subject: [PATCH 2/4] remove _nthChild from updated item count --- js/BoxMenuGroupView.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/js/BoxMenuGroupView.js b/js/BoxMenuGroupView.js index 3dff073..fc462a6 100644 --- a/js/BoxMenuGroupView.js +++ b/js/BoxMenuGroupView.js @@ -15,12 +15,9 @@ class BoxMenuGroupView extends MenuItemView { } updateItemCount() { - let nthChild = 0; const models = this.model.getChildren().models; models.forEach(model => { - nthChild++; model.set({ - _nthChild: nthChild, _totalChild: models.length }); }); From a4cbeda6f892e665ff3bfa0dcfad3e16e88ef274 Mon Sep 17 00:00:00 2001 From: kirsty-hames Date: Thu, 24 Aug 2023 10:41:47 +0100 Subject: [PATCH 3/4] set models.length to a variable Co-authored-by: Brad Simpson --- js/BoxMenuGroupView.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/BoxMenuGroupView.js b/js/BoxMenuGroupView.js index fc462a6..191b25b 100644 --- a/js/BoxMenuGroupView.js +++ b/js/BoxMenuGroupView.js @@ -16,9 +16,10 @@ class BoxMenuGroupView extends MenuItemView { updateItemCount() { const models = this.model.getChildren().models; + const totalChildren = models.length; models.forEach(model => { model.set({ - _totalChild: models.length + _totalChild: totalChildren }); }); } From 454485af44c6156eca8d3af657d7a4201e70a630 Mon Sep 17 00:00:00 2001 From: Oliver Foster Date: Tue, 5 Sep 2023 15:47:43 +0100 Subject: [PATCH 4/4] Update js/BoxMenuGroupView.js --- js/BoxMenuGroupView.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/js/BoxMenuGroupView.js b/js/BoxMenuGroupView.js index 191b25b..2230d29 100644 --- a/js/BoxMenuGroupView.js +++ b/js/BoxMenuGroupView.js @@ -17,11 +17,7 @@ class BoxMenuGroupView extends MenuItemView { updateItemCount() { const models = this.model.getChildren().models; const totalChildren = models.length; - models.forEach(model => { - model.set({ - _totalChild: totalChildren - }); - }); + models.forEach(model => model.set('_totalChild', totalChildren)); } }