diff --git a/assets/js/src/newsletter_editor/blocks/posts.js b/assets/js/src/newsletter_editor/blocks/posts.js index 7300d00d06..0e9134fbd4 100644 --- a/assets/js/src/newsletter_editor/blocks/posts.js +++ b/assets/js/src/newsletter_editor/blocks/posts.js @@ -95,7 +95,7 @@ Module.PostsBlockModel = base.BlockModel.extend({ this.fetchAvailablePosts(); this.on('change', this._updateDefaults, this); - this.on('change:amount change:contentType change:terms change:inclusionType change:postStatus change:search change:sortBy', refreshAvailablePosts); + this.on('change:contentType change:terms change:postStatus change:search', refreshAvailablePosts); this.on('loadMorePosts', this._loadMorePosts, this); this.listenTo(this.get('_selectedPosts'), 'add remove reset', refreshTransformedPosts); @@ -480,9 +480,7 @@ PostsDisplayOptionsSettingsView = base.BlockSettingsView.extend({ 'change .mailpoet_posts_title_format': 'changeTitleFormat', 'change .mailpoet_posts_title_as_links': _.partial(this.changeBoolField, 'titleIsLink'), 'change .mailpoet_posts_show_divider': _.partial(this.changeBoolField, 'showDivider'), - 'input .mailpoet_posts_show_amount': _.partial(this.changeField, 'amount'), 'change .mailpoet_posts_content_type': _.partial(this.changeField, 'contentType'), - 'change .mailpoet_posts_include_or_exclude': _.partial(this.changeField, 'inclusionType'), 'change .mailpoet_posts_title_alignment': _.partial(this.changeField, 'titleAlignment'), 'change .mailpoet_posts_image_full_width': _.partial(this.changeBoolField, 'imageFullWidth'), 'change .mailpoet_posts_featured_image_position': _.partial(this.changeField, 'featuredImagePosition'), @@ -491,7 +489,6 @@ PostsDisplayOptionsSettingsView = base.BlockSettingsView.extend({ 'change .mailpoet_posts_show_categories': _.partial(this.changeField, 'showCategories'), 'input .mailpoet_posts_categories': _.partial(this.changeField, 'categoriesPrecededBy'), 'input .mailpoet_posts_read_more_text': _.partial(this.changeField, 'readMoreText'), - 'change .mailpoet_posts_sort_by': _.partial(this.changeField, 'sortBy'), 'change .mailpoet_automated_latest_content_title_position': _.partial(this.changeField, 'titlePosition'), }; }, diff --git a/assets/js/src/newsletter_editor/blocks/products.js b/assets/js/src/newsletter_editor/blocks/products.js index 1c8af450fd..4bb2e3b155 100644 --- a/assets/js/src/newsletter_editor/blocks/products.js +++ b/assets/js/src/newsletter_editor/blocks/products.js @@ -91,7 +91,7 @@ Module.ProductsBlockModel = base.BlockModel.extend({ this.fetchAvailableProducts(); this.on('change', this._updateDefaults, this); - this.on('change:amount change:terms change:inclusionType change:postStatus change:search change:sortBy', refreshAvailableProducts); + this.on('change:terms change:postStatus change:search', refreshAvailableProducts); this.on('loadMoreProducts', this._loadMoreProducts, this); this.listenTo(this.get('_selectedProducts'), 'add remove reset', refreshTransformedProducts); @@ -282,7 +282,7 @@ Module.ProductsBlockSettingsView = base.BlockSettingsView.extend({ }); ProductSelectionCollectionView = Marionette.CollectionView.extend({ - className: 'mailpoet_post_scroll_container', + className: 'mailpoet_products_scroll_container', childView: function childView() { return SingleProductSelectionSettingsView; }, emptyView: function emptyView() { return EmptyProductSelectionSettingsView; }, childViewOptions: function childViewOptions() { @@ -297,8 +297,8 @@ ProductSelectionCollectionView = Marionette.CollectionView.extend({ scroll: 'onProductsScroll', }, onProductsScroll: function onProductsScroll(event) { - var $postsBox = jQuery(event.target); - if ($postsBox.scrollTop() + $postsBox.innerHeight() >= $postsBox[0].scrollHeight) { + var $productsBox = jQuery(event.target); + if ($productsBox.scrollTop() + $productsBox.innerHeight() >= $productsBox[0].scrollHeight) { // Load more posts if scrolled to bottom this.blockModel.trigger('loadMoreProducts'); } @@ -322,7 +322,7 @@ ProductSelectionSettingsView = Marionette.View.extend({ 'change:offset': function changeOffset(model, value) { // Scroll posts view to top if settings are changed if (value === 0) { - this.$('.mailpoet_post_scroll_container').scrollTop(0); + this.$('.mailpoet_products_scroll_container').scrollTop(0); } }, loadingMoreProducts: function loadingMoreProducts() { @@ -461,21 +461,18 @@ ProductsDisplayOptionsSettingsView = base.BlockSettingsView.extend({ }, events: function events() { return { - 'click .mailpoet_posts_select_button': 'showButtonSettings', - 'click .mailpoet_posts_select_divider': 'showDividerSettings', - 'change .mailpoet_posts_read_more_type': 'changeReadMoreType', + 'click .mailpoet_products_select_button': 'showButtonSettings', + 'click .mailpoet_products_select_divider': 'showDividerSettings', + 'change .mailpoet_products_read_more_type': 'changeReadMoreType', 'change .mailpoet_products_display_type': 'changeDisplayType', 'change .mailpoet_products_title_format': 'changeTitleFormat', 'change .mailpoet_products_title_as_links': _.partial(this.changeBoolField, 'titleIsLink'), - 'change .mailpoet_posts_show_divider': _.partial(this.changeBoolField, 'showDivider'), - 'input .mailpoet_posts_show_amount': _.partial(this.changeField, 'amount'), - 'change .mailpoet_posts_include_or_exclude': _.partial(this.changeField, 'inclusionType'), + 'change .mailpoet_products_show_divider': _.partial(this.changeBoolField, 'showDivider'), 'change .mailpoet_products_title_alignment': _.partial(this.changeField, 'titleAlignment'), 'change .mailpoet_products_image_full_width': _.partial(this.changeBoolField, 'imageFullWidth'), 'change .mailpoet_products_featured_image_position': _.partial(this.changeField, 'featuredImagePosition'), 'change .mailpoet_products_price_position': _.partial(this.changeField, 'pricePosition'), - 'input .mailpoet_posts_read_more_text': _.partial(this.changeField, 'readMoreText'), - 'change .mailpoet_posts_sort_by': _.partial(this.changeField, 'sortBy'), + 'input .mailpoet_products_read_more_text': _.partial(this.changeField, 'readMoreText'), 'change .mailpoet_products_title_position': _.partial(this.changeField, 'titlePosition'), }; }, @@ -508,11 +505,11 @@ ProductsDisplayOptionsSettingsView = base.BlockSettingsView.extend({ changeReadMoreType: function changeReadMoreType(event) { var value = jQuery(event.target).val(); if (value === 'link') { - this.$('.mailpoet_posts_read_more_text').removeClass('mailpoet_hidden'); - this.$('.mailpoet_posts_select_button').addClass('mailpoet_hidden'); + this.$('.mailpoet_products_read_more_text').removeClass('mailpoet_hidden'); + this.$('.mailpoet_products_select_button').addClass('mailpoet_hidden'); } else if (value === 'button') { - this.$('.mailpoet_posts_read_more_text').addClass('mailpoet_hidden'); - this.$('.mailpoet_posts_select_button').removeClass('mailpoet_hidden'); + this.$('.mailpoet_products_read_more_text').addClass('mailpoet_hidden'); + this.$('.mailpoet_products_select_button').removeClass('mailpoet_hidden'); } this.changeField('readMoreType', event); }, diff --git a/tests/acceptance/EditorProductsCest.php b/tests/acceptance/EditorProductsCest.php index 7588e837b9..4699168a0b 100644 --- a/tests/acceptance/EditorProductsCest.php +++ b/tests/acceptance/EditorProductsCest.php @@ -114,9 +114,9 @@ class EditorProductsCest { // Multiple result for category $I->selectOptionInSelect2(self::CATEGORY_MULTIPLE_RESULTS); - $I->waitForElementNotVisible('.mailpoet_post_scroll_container > div:nth-child(' . (self::PRODUCTS_COUNT + 1) . ')'); - $I->waitForText(self::PRODUCT_PREFIX_CATEGORY, 10, '.mailpoet_post_scroll_container'); - $I->seeNumberOfElements('.mailpoet_post_scroll_container > div', self::PRODUCTS_COUNT); + $I->waitForElementNotVisible('.mailpoet_products_scroll_container > div:nth-child(' . (self::PRODUCTS_COUNT + 1) . ')'); + $I->waitForText(self::PRODUCT_PREFIX_CATEGORY, 10, '.mailpoet_products_scroll_container'); + $I->seeNumberOfElements('.mailpoet_products_scroll_container > div', self::PRODUCTS_COUNT); $this->clearCategories($I); // Click select2 to hide results @@ -128,9 +128,9 @@ class EditorProductsCest { // Multiple result for keyword $I->fillField('.mailpoet_products_search_term', self::KEYWORD_MULTIPLE_RESULTS); - $I->waitForElementNotVisible('.mailpoet_post_scroll_container > div:nth-child(' . (self::PRODUCTS_COUNT + 1) . ')'); - $I->waitForText(self::KEYWORD_MULTIPLE_RESULTS, 10, '.mailpoet_post_scroll_container'); - $I->seeNumberOfElements('.mailpoet_post_scroll_container > div', self::PRODUCTS_COUNT); + $I->waitForElementNotVisible('.mailpoet_products_scroll_container > div:nth-child(' . (self::PRODUCTS_COUNT + 1) . ')'); + $I->waitForText(self::KEYWORD_MULTIPLE_RESULTS, 10, '.mailpoet_products_scroll_container'); + $I->seeNumberOfElements('.mailpoet_products_scroll_container > div', self::PRODUCTS_COUNT); // Searching for existing post should return zero results $I->fillField('.mailpoet_products_search_term', self::POST_TITLE); @@ -138,11 +138,11 @@ class EditorProductsCest { // Product is clickable $I->fillField('.mailpoet_products_search_term', self::PRODUCT_NAME); - $I->waitForText(self::PRODUCT_NAME, 10, '.mailpoet_post_scroll_container'); - $I->waitForElementVisible('#mailpoet_select_post_0'); - $I->click('#mailpoet_select_post_0'); - $I->seeCheckboxIsChecked('#mailpoet_select_post_0'); - $I->click('#mailpoet_select_post_1'); + $I->waitForText(self::PRODUCT_NAME, 10, '.mailpoet_products_scroll_container'); + $I->waitForElementVisible('#mailpoet_select_product_0'); + $I->click('#mailpoet_select_product_0'); + $I->seeCheckboxIsChecked('#mailpoet_select_product_0'); + $I->click('#mailpoet_select_product_1'); $I->waitForElement(self::EDITOR_PRODUCT_SELECTOR); } @@ -193,11 +193,11 @@ class EditorProductsCest { // Test "Buy now" button $I->see('Buy now', self::EDITOR_PRODUCT_SELECTOR . ' .mailpoet_wp_post + p'); - $I->fillField('.mailpoet_posts_read_more_text', 'Go Shopping'); + $I->fillField('.mailpoet_products_read_more_text', 'Go Shopping'); $this->waitForChange($I); $I->dontSee('Buy now', self::EDITOR_PRODUCT_SELECTOR . ' .mailpoet_wp_post + p'); $I->see('Go Shopping', self::EDITOR_PRODUCT_SELECTOR . ' .mailpoet_wp_post + p'); - $I->clickLabelWithInput('mailpoet_posts_read_more_type', 'button'); + $I->clickLabelWithInput('mailpoet_products_read_more_type', 'button'); $this->waitForChange($I); $I->dontSeeElementInDOM(self::EDITOR_PRODUCT_SELECTOR . ' .mailpoet_wp_post + p'); $I->seeElementInDOM(self::EDITOR_PRODUCT_SELECTOR . ' .mailpoet_editor_button'); @@ -205,12 +205,12 @@ class EditorProductsCest { // Test "Divider" $I->seeElementInDOM(self::EDITOR_PRODUCTS_SELECTOR . ' .mailpoet_divider_block'); $I->assertAttributeContains(self::EDITOR_PRODUCTS_SELECTOR . ' .mailpoet_divider', 'style', '3px'); - $I->click('.mailpoet_posts_select_divider'); + $I->click('.mailpoet_products_select_divider'); $I->fillField('.mailpoet_field_divider_border_width_input', 10); $this->waitForChange($I); $I->click('.mailpoet_done_editing'); $I->assertAttributeContains(self::EDITOR_PRODUCTS_SELECTOR . ' .mailpoet_divider', 'style', '10px'); - $I->clickLabelWithInput('mailpoet_posts_show_divider', 'false'); + $I->clickLabelWithInput('mailpoet_products_show_divider', 'false'); $this->waitForChange($I); $I->dontSeeElementInDOM(self::EDITOR_PRODUCTS_SELECTOR . ' .mailpoet_divider_block'); diff --git a/views/newsletter/templates/blocks/products/settingsDisplayOptions.hbs b/views/newsletter/templates/blocks/products/settingsDisplayOptions.hbs index 004c274aa6..1bd2d9132c 100644 --- a/views/newsletter/templates/blocks/products/settingsDisplayOptions.hbs +++ b/views/newsletter/templates/blocks/products/settingsDisplayOptions.hbs @@ -182,23 +182,23 @@
<%= __('"Buy now" text') %>
- +
- <%= __('Design a button') %> + <%= __('Design a button') %>
@@ -208,18 +208,18 @@
<%= __('Show divider between posts') %>
- <%= __('Select divider') %> + <%= __('Select divider') %>
diff --git a/views/newsletter/templates/blocks/products/settingsSinglePost.hbs b/views/newsletter/templates/blocks/products/settingsSinglePost.hbs index 72394352f3..e4ed3858ac 100644 --- a/views/newsletter/templates/blocks/products/settingsSinglePost.hbs +++ b/views/newsletter/templates/blocks/products/settingsSinglePost.hbs @@ -1,6 +1,6 @@