Skip to content

Commit

Permalink
Merge pull request #734 from ecomplus/products-view
Browse files Browse the repository at this point in the history
fix(products): unable to delete videos and scroll image too tiny
  • Loading branch information
matheusgnreis authored Oct 27, 2023
2 parents 7a044c6 + 7b6d7ef commit 906226b
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 4 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
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

0 comments on commit 906226b

Please sign in to comment.