Skip to content

Commit

Permalink
Merge pull request #735 from ecomplus/master
Browse files Browse the repository at this point in the history
chore: create link abandoned cart list, fix bug in scroll image with a lot of image, fix delete video bug, add search by spec
  • Loading branch information
matheusgnreis authored Oct 27, 2023
2 parents 40adf1f + 906226b commit 99053dc
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 19 deletions.
3 changes: 3 additions & 0 deletions scss/_main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
28 changes: 18 additions & 10 deletions src/controllers/abandoned-cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<a href="https://${platform}.whatsapp.com/send?phone=${data}&text=${window.sessionStorage.getItem('whatsapp') || i18n(i19shopNow)} ${row[3]}" target="_blank">${data}</a>`
}
return `<a href="https://${platform}.whatsapp.com/send?phone=${data}&text=${i18n(i19shopNow)} ${row[3]}" target="_blank">${data}</a>`
return data
}
return data
}
}]
},
{
"targets": 3,
render: (data, type, row) => {
return `<a href="${data}" target="_blank">${data}</a>`
}
}
]
}

const dictionary = {
Expand Down
13 changes: 11 additions & 2 deletions src/controllers/best-sellers.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function () {
<td>${entry._id}</td>
<td>${entry.name}</td>
<td>${formatMoney(entry.amount / (entry.count || 1))}</td>
<td>${formatMoney(entry.count || 0)}</td>
<td>${entry.count || 0}</td>
<td>${formatMoney(entry.amount)}</td>
</tr>`
})
Expand Down Expand Up @@ -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 = []
Expand Down
10 changes: 10 additions & 0 deletions src/controllers/resources/form/products.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
59 changes: 57 additions & 2 deletions src/controllers/resources/list/products.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default function () {
const { tabId, $, callApi, app, quickview, lang, handleInputs, stringToNumber, unsetSaveAction, Tabs, i18n, formatMoney, ecomUtils } = window
var Tab = Tabs[tabId]
Tab.selectedSkus = []

/*
var elContainer = $('#t' + tabId + '-tab-normal')
// prefix tab ID on content elements IDs
Expand Down Expand Up @@ -155,6 +156,10 @@ export default function () {
'<input class="form-control text-monospace" placeholder="SKU" type="text" name="sku" ' +
'data-filter="term"/>' +
'</div>',
'<div class="form-group">' +
'<input class="form-control text-monospace" placeholder="tamanho: M" type="text" name="specs" ' +
'data-filter="term"/>' +
'</div>',
$customFilters,
'<label>' +
'<span>' + `${i18n(i19price)}` + '</span>' +
Expand Down Expand Up @@ -226,6 +231,13 @@ export default function () {
'<span data-lang="pt_br">Indisponíveis</span>' +
'</label>' +
'</div>' +
'<div class="custom-control custom-radio mb-0">' +
'<input type="radio" class="custom-control-input" name="offers" data-filter="term" value="false"/>' +
'<label class="custom-control-label i18n">' +
'<span data-lang="en_us">Offers</span>' +
'<span data-lang="pt_br">Ofertas</span>' +
'</label>' +
'</div>' +
'</div>' +
'</div>'
]
Expand Down Expand Up @@ -797,7 +809,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
Expand Down Expand Up @@ -858,6 +870,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
}
Expand Down Expand Up @@ -901,7 +939,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)
}
}
})
}
Expand Down
15 changes: 10 additions & 5 deletions src/controllers/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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'))
})
}
9 changes: 9 additions & 0 deletions src/views/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,15 @@ <h4 class="card-title i18n">
</label>
</div>
</div>
<div class="custom-controls-stacked" id="without-variations">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="without-variations-input">
<label class="custom-control-label i18n">
<span data-lang="en_us">Remove variations from feed</span>
<span data-lang="pt_br">Remover variações do feed</span>
</label>
</div>
</div>
<div class="form-group" id="id-categoria-google">
<label class="i18n">
<span data-lang="en_us">Google category ID</span>
Expand Down

0 comments on commit 99053dc

Please sign in to comment.