name="delivery"
, data-post
- пусть оба будут или delivery, или post). Сделайте пустыми строками значения option'ов, которые соответствуют всем вариантам.$('.result-btn').on('click', function() {
const values = $('select')
.get()
.filter(n => n.value)
.map(n => [ n.name, n.value.toLowerCase() ]);
$('.delivery-table-item')
.show()
.filter((i, { dataset: d }) => values.some(([ k, v ]) => d[k].toLowerCase() !== v))
.hide();
});
key = lambda item: (item[0], item[3])
keys = set(map(key, list_in))
list_out = [ [ k[0], sum(int(n[2]) for n in list_in if k == key(n)), k[1] ] for k in keys ]
$sql = "{$action} * FROM {$table} WHERE {$field} {$operator} ?";
DELETE * FROM ...
. Круто. Не знал, что так можно. Или всё-таки нельзя? const filterByProps = Object.entries(this.state.filters).filter(n => n[1]).map(n => n[0]);
const filteredItems = this.state.items.filter(n => filterByProps.every(m => n[m]));
const markerData = [
{ coord: [ ... ], content: '...' },
{ coord: [ ... ], content: '...' },
...
];
markerData.forEach(function(n) {
const marker = new google.maps.Marker({
position: new google.maps.LatLng(...n.coord),
map,
});
marker.addListener('click', function() {
infowindow.setContent(n.content);
infowindow.open(map, marker);
});
});
const colors = [
{ color: '...', image: '...' },
{ color: '...', image: '...' },
...
];
background-color
на background-image
:const colorsItems = colors
.map(n => `
<button
style="background-image: url(${n.image})"
class="palette-button"
data-color="${n.color}"
></button>`)
.join('');
.palette-button
- приводите в порядок background:background-position: center;
background-size: contain;
background-repeat: no-repeat;
el.dispatchEvent(new Event('click'));
// или, если обработчик клика висит не на самом svg, а выше
el.dispatchEvent(new Event('click', { bubbles: true }));
const isEqual = (a, b) =>
a.length === b.length && a.every((n, i) => Object.is(n, b[i]));
const includes = (arrs, search) =>
arrs.some(n => isEqual(n, search));
console.log(includes(array, [ 21, 81 ]));
. function getGridSize() {
const w = window.innerWidth;
return [ 500, 700, 1225, Infinity ].findIndex(n => n > w) + 1;
}
function getGridSize() {
const w = window.innerWidth;
return [
{ size: 1, maxWidth: 500 },
{ size: 2, maxWidth: 700 },
{ size: 3, maxWidth: 1225 },
{ size: 4, maxWidth: Infinity },
].find(n => n.maxWidth > w).size;
}
computed: {
groupedItems() {
const { items } = this;
const statuses = [...new Set(items.map(n => n.status))];
const positions = [...new Set(items.map(n => n.position))];
return items.reduce(
(acc, n) => (acc[n.status][n.position].push(n), acc),
Object.fromEntries(statuses.map(status => [
status,
Object.fromEntries(positions.map(position => [
position,
[]
]))
]))
);
},
},
<ul>
<li v-for="(statusGroup, status) in groupedItems">
<h2>{{ status }}</h2>
<ul>
<li v-for="(positionGroup, position) in statusGroup">
<h3>{{ position }}</h3>
<ul>
<li v-for="n in positionGroup">{{ n.name }}</li>
</ul>
</li>
</ul>
</li>
</ul>
name: 'v-tree',
props: [ 'items' ],
<ul v-if="items instanceof Object">
<li v-for="n in items">
<b>{{ n.name }}</b>
<v-tree :items="n.children" />
</li>
</ul>
const group = (arr, keys) =>
arr.reduce((acc, n) => {
keys.reduce((g, k, i, a) => {
const name = n[k];
return (g[name] = g[name] || {
name,
children: i === a.length - 1 ? [] : {},
}).children;
}, acc).push(n);
return acc;
}, keys.length ? {} : []);
computed: {
groupedItems() {
return group(this.items, [ 'status', 'position' ]);
},
},
<v-tree :items="groupedItems" />
phonesProcessed() {
const classes = Object.fromEntries(this.classes.map(({ classinfoName: c, items }) => [
c,
Object.fromEntries(items.map(n => [
n[`id${c[0].toUpperCase()}${c.slice(1)}`],
n.name,
])),
]));
return this.phones.map(n =>
Object.fromEntries(Object.entries(n).map(([ k, v ]) => [
k,
classes.hasOwnProperty(k) ? classes[k][v] : v,
]))
);
},
created() {
[
[ '5ad979f4-7393-11ea-b9b1-d7fe1923484d', 'classinfo', 'classes' ],
[ '46bf408d-739d-11ea-b9b1-5301e3b2b9ba', 'phones', 'phones' ],
].forEach(([ key, apiPropName, componentPropName ]) => {
axios
.get(`https://jsonblob.com/api/${key}`)
.then(({ data: { [apiPropName]: d } }) => this[componentPropName] = d)
.catch(e => this.errors.push(e));
});
},