From ed4c933abbce3a0b72b418768f6ff69d8f4c7cfe Mon Sep 17 00:00:00 2001 From: matheusgnreis Date: Thu, 26 Oct 2023 17:31:19 -0300 Subject: [PATCH 1/5] 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/5] 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/5] 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 a813bf5e11e9d2ddfe652677899ebc06b54367d0 Mon Sep 17 00:00:00 2001 From: matheusgnreis Date: Fri, 27 Oct 2023 00:53:11 -0300 Subject: [PATCH 4/5] chore(product): remove typeahead not used --- src/controllers/resources/list/products.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/controllers/resources/list/products.js b/src/controllers/resources/list/products.js index 1f68ec4b..1ff5f3f6 100644 --- a/src/controllers/resources/list/products.js +++ b/src/controllers/resources/list/products.js @@ -37,19 +37,6 @@ export default function () { 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 From 7b6d7ef3ff4c71935686dce64792745ef4552d92 Mon Sep 17 00:00:00 2001 From: matheusgnreis Date: Fri, 27 Oct 2023 00:54:56 -0300 Subject: [PATCH 5/5] chore(product-list): remove unused code --- src/controllers/resources/list/products.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/controllers/resources/list/products.js b/src/controllers/resources/list/products.js index 1ff5f3f6..c886407d 100644 --- a/src/controllers/resources/list/products.js +++ b/src/controllers/resources/list/products.js @@ -1073,8 +1073,6 @@ 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