From ed4c933abbce3a0b72b418768f6ff69d8f4c7cfe Mon Sep 17 00:00:00 2001 From: matheusgnreis Date: Thu, 26 Oct 2023 17:31:19 -0300 Subject: [PATCH 1/7] fix: get filter table to export --- src/controllers/best-sellers.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/controllers/best-sellers.js b/src/controllers/best-sellers.js index 4dd63b26..9121acf3 100644 --- a/src/controllers/best-sellers.js +++ b/src/controllers/best-sellers.js @@ -35,7 +35,7 @@ export default function () { ${entry._id} ${entry.name} ${formatMoney(entry.amount / (entry.count || 1))} - ${formatMoney(entry.count || 0)} + ${entry.count || 0} ${formatMoney(entry.amount)} ` }) @@ -185,7 +185,16 @@ export default function () { $(`#t${tabId}-loading`).hide() } $exportBestSeller.click(() => { - renderTable(dataQuery, 1, dataQuery.length, start, end) + let filter, searched; + filter = $('#search-best-seller').val() + searched = dataQuery + if (filter) { + filter = filter.toLowerCase(); + searched = dataQuery.filter(option => { + return option._id.indexOf(filter) > -1 || option.name.toLowerCase().indexOf(filter) > -1 + }) + } + renderTable(searched, 1, searched.length, start, end) const data = [] $('#best-seller-list').find('tr:not(:first)').each(function(i, row) { const cols = [] From fce83b711a558660a10b0fbbd83e25bf753a07a8 Mon Sep 17 00:00:00 2001 From: matheusgnreis Date: Thu, 26 Oct 2023 22:07:49 -0300 Subject: [PATCH 2/7] feat: add filter spec and offer --- src/controllers/resources/list/products.js | 74 +++++++++++++++++++++- 1 file changed, 72 insertions(+), 2 deletions(-) diff --git a/src/controllers/resources/list/products.js b/src/controllers/resources/list/products.js index 77f09fd7..1f68ec4b 100644 --- a/src/controllers/resources/list/products.js +++ b/src/controllers/resources/list/products.js @@ -36,6 +36,20 @@ export default function () { const { tabId, $, callApi, app, quickview, lang, handleInputs, stringToNumber, unsetSaveAction, Tabs, i18n, formatMoney, ecomUtils } = window var Tab = Tabs[tabId] Tab.selectedSkus = [] + + const Typeahead = function ($el, name, source) { + // abstraction to setup typeahead addon + // input autocomplete + $el.typeahead({ + hint: true, + highlight: true, + minLength: 1 + }, { + name: name, + source: source + }) + } + /* var elContainer = $('#t' + tabId + '-tab-normal') // prefix tab ID on content elements IDs @@ -155,6 +169,10 @@ export default function () { '' + '', + '
' + + '' + + '
', $customFilters, '' + '' + + '
' + + '' + + '' + + '
' + '' + '' ] @@ -797,7 +822,7 @@ export default function () { var agg = aggs[prop] // create select element for current aggregation field var buckets = Aggs[prop].buckets - if (buckets.length) { + if (buckets && buckets.length) { var elOptions = '' for (i = 0; i < buckets.length; i++) { // field value @@ -858,6 +883,32 @@ export default function () { value = value.trim() } } + if (prop === 'specs' && value.includes(':')) { + const gridsOptions = value.split(':') + filters.push({ + nested: { + path: "specs", + query: { + bool: { + filter: [ + { + term: { + "specs.grid": gridsOptions[0].trim() + } + }, + { + terms: { + "specs.text": [ + gridsOptions[1].trim() + ] + } + } + ] + } + } + } + }) + } if (isNaN(value) || value === '') { value = null } @@ -901,7 +952,24 @@ export default function () { filter[filterType][prop] = {} filter[filterType][prop][operator] = value } - filters.push(filter) + if (prop === 'offers') { + const timestamp = Date.now() + filters.push({ + script: { + script: { + lang: 'painless', + source: "doc['price'].value > 0 && doc['base_price'].value > 0" + + " && (doc['price_effective_date.start'].empty || " + + `doc['price_effective_date.start'].date.millis <= ${timestamp}L)` + + " && (doc['price_effective_date.end'].empty || " + + `doc['price_effective_date.end'].date.millis >= ${timestamp}L)` + + " ? doc['base_price'].value > doc['price'].value : false" + } + } + }) + } else { + filters.push(filter) + } } }) } @@ -1018,6 +1086,8 @@ export default function () { } } + $('#spec-search').click($('.search-specifications').slideToggle()) + // checkbox to select all $('#select-all-products').on('change', function () { // check or uncheck all list items From 8392e8136f543a7b698f16c4ca56ba8c8e983a71 Mon Sep 17 00:00:00 2001 From: matheusgnreis Date: Fri, 27 Oct 2023 00:08:21 -0300 Subject: [PATCH 3/7] fix(product): scroller image too tiny and could not delete video --- scss/_main.scss | 3 +++ src/controllers/resources/form/products.js | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/scss/_main.scss b/scss/_main.scss index b5b09a11..e11cbc21 100644 --- a/scss/_main.scss +++ b/scss/_main.scss @@ -175,6 +175,9 @@ a:focus { #app-nav-container > .scrollable > .ps-scrollbar-x-rail { top: 2px !important; } +.select-image.scrollable.scrollable-x .ps-scrollbar-x { + height: 15px; +} #app-nav-container > .scrollable > .ps-scrollbar-y-rail { display: none !important; } diff --git a/src/controllers/resources/form/products.js b/src/controllers/resources/form/products.js index a42ae4e2..9bb45860 100644 --- a/src/controllers/resources/form/products.js +++ b/src/controllers/resources/form/products.js @@ -2100,6 +2100,8 @@ export default function () { $inputQnt.attr('readonly', true) } + + if (data.price_effective_date) { // manually reset date range const { start, end } = data.price_effective_date @@ -2132,6 +2134,14 @@ export default function () { renderKitItems({ tabId }) renderRelatedItems(tabId) + $form.find('input[name="videos[].0.url"]').on('input', function () { + if ($(this).val() === '') { + const data = Data() + delete data.videos + commit(data, true) + } + }) + setTimeout(() => { listOrders(tabId) }, 1500) From 08a9300af49503aac57bf9a8c3d6e94f14036dbe Mon Sep 17 00:00:00 2001 From: matheusgnreis Date: Fri, 27 Oct 2023 00:17:43 -0300 Subject: [PATCH 4/7] chore(abandoned-cart): use link instead of text in cart link --- src/controllers/abandoned-cart.js | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/controllers/abandoned-cart.js b/src/controllers/abandoned-cart.js index 678e0a92..4a70d883 100644 --- a/src/controllers/abandoned-cart.js +++ b/src/controllers/abandoned-cart.js @@ -18,18 +18,26 @@ export default function () { pageLength: 20, bLengthChange: false, order: [[3, 'desc']], - columnDefs: [{ - "targets": 2, - render: (data, type, row) => { - if (data !== 'Sem número' && data !== 'Without number') { - if (!data.includes('+')) { - data = '+55' + data + columnDefs: [ + { + "targets": 2, + render: (data, type, row) => { + if (data !== 'Sem número' && data !== 'Without number') { + if (!data.includes('+')) { + data = '+55' + data + } + return `${data}` } - return `${data}` + return data } - return data - } - }] + }, + { + "targets": 3, + render: (data, type, row) => { + return `${data}` + } + } + ] } const dictionary = { From 18b2dab09c3de24b25337d803a6c71f0cc10e456 Mon Sep 17 00:00:00 2001 From: matheusgnreis Date: Fri, 27 Oct 2023 00:48:45 -0300 Subject: [PATCH 5/7] feat(settings): option to skip variations --- src/controllers/settings.js | 15 ++++++++++----- src/views/settings.html | 9 +++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/controllers/settings.js b/src/controllers/settings.js index 39575fa3..abe0869c 100644 --- a/src/controllers/settings.js +++ b/src/controllers/settings.js @@ -95,26 +95,31 @@ export default () => { } }) - const setProductsFeedUri = (isAllProducts, googleProductCategory, filter) => { + const setProductsFeedUri = (isAllProducts, googleProductCategory, filter, skipVariations) => { setTimeout(() => { - const uri = `https://storefront.e-com.plus/products-feed${isAllProducts ? '/all' : ''}.xml?store_id=${storeId}&domain=${window.Store.domain}${googleProductCategory ? `&set_properties={"google_product_category_id":${googleProductCategory}}` : ''}${filter && filter.resource ? `&search_field=${filter.resource}.slug&search_value=${filter.slug}` : ''}` + const uri = `https://storefront.e-com.plus/products-feed${isAllProducts ? '/all' : ''}.xml?store_id=${storeId}&domain=${window.Store.domain}${googleProductCategory ? `&set_properties={"google_product_category_id":${googleProductCategory}}` : ''}${filter && filter.resource ? `&search_field=${filter.resource}.slug&search_value=${filter.slug}` : ''}${skipVariations ? '&skip_variations=true' : ''}` $form.find('#products-feed-uri').val(uri) }, 300) } const $allProductsInput = $form.find('#all-products-input') const $googleCategoryInput = $form.find('#id-categoria-google-input') const $selectedResource = $form.find('#filter-resource-input') + const $skipVariations = $form.find('#without-variations-input') $form.find('[name=domain]').change(setProductsFeedUri) setProductsFeedUri() $form.find('#xml-more-options').click((e) => { $('#xml-options').slideToggle() }) $form.find('#all-products').change(function () { - setProductsFeedUri($(this).find('input').is(':checked'), $googleCategoryInput.val()) + setProductsFeedUri($(this).find('input').is(':checked'), $googleCategoryInput.val(), undefined, $skipVariations.prop('checked')) + }) + $form.find('#without-variations').change(function () { + const isAllProducts = $allProductsInput.prop('checked') + setProductsFeedUri(isAllProducts, $googleCategoryInput.val(), isAllProducts ? undefined : JSON.parse($selectedResource.val()) , $(this).find('input').is(':checked')) }) $form.find('#id-categoria-google').on('input', function () { const isAllProducts = $allProductsInput.prop('checked') - setProductsFeedUri(isAllProducts, $(this).find('input').val(), isAllProducts ? undefined : JSON.parse($selectedResource.val())) + setProductsFeedUri(isAllProducts, $(this).find('input').val(), isAllProducts ? undefined : JSON.parse($selectedResource.val()), $skipVariations.prop('checked')) }) $form.find('#filter-resource-option input').change(function (e) { $form.find('#filter-resource').slideUp() @@ -149,6 +154,6 @@ export default () => { }) }) $form.find('#filter-resource').change(function () { - setProductsFeedUri(false, $googleCategoryInput.val(), JSON.parse($(this).find('#filter-resource-input').val())) + setProductsFeedUri(false, $googleCategoryInput.val(), JSON.parse($(this).find('#filter-resource-input').val()), $skipVariations.prop('checked')) }) } diff --git a/src/views/settings.html b/src/views/settings.html index 33aebf32..d2f8b083 100644 --- a/src/views/settings.html +++ b/src/views/settings.html @@ -330,6 +330,15 @@

+
+
+ + +
+