Skip to content

Instantly share code, notes, and snippets.

View YuraKolesnikov's full-sized avatar

JurijsKolesnikovs YuraKolesnikov

  • Riga, Latvia
View GitHub Profile
const payload = {
spaces: [
{
id: '123',
name: 'My Space',
notes: [{ id: 'note_1', name: 'Note 1' }],
folders: [{ id: 'folder_1', name: 'Folder 1', notes: [{ id: 'note_2', name: 'Note 2' }] }]
projects: [
{
id: 'project_1',
<template>
<transition
:enter-class="$style.Modal_slide_enter"
:enter-active-class="$style.Modal_slide_active"
:leave-active-class="$style.Modal_slide_leaveActive"
:leave-to-class="$style.Modal_slide_leaveTo"
>
<div
:class="modalClassList"
v-if="isOpen"
import { withDesign } from 'storybook-addon-designs'
import { withPadding, withContainer } from '../../.storybook/helpers'
import VDomainCard from './VDomainCard'
import { domains } from './domains'
export default {
title: 'Simple Components / VDomainCard',
decorators: [withContainer, withPadding, withDesign]
}
import axios from './axios';
export const CustomerApi = {
async getCustomers (query = null) {
return await axios.get('/customers?expand=orders', {
params: query
});
},
async createCustomer (payload) {
return await axios.post('/customers', payload);
/* Так как фильтр множественный, делаем так. Есть инпуты/селекты. На keydown.enter/change ебашим filterData.
Функция проверяет, есть ли такой фильтр уже в массиве, если нет, добавляет, если есть - проверяет, новое значение
пустое или нет. Если пустое - нахрен из массива, фильтр не нужен. Если не пустое - обновить значение. */
methods: {
async filterData({target}, id) {
const index = this.filters.findIndex(filter => filter.key == id)
const keyinFilters = this.filters[index]
if (keyinFilters) {
keyinFilters.value = target.value
if (keyinFilters.value == '') {
@YuraKolesnikov
YuraKolesnikov / TestPlugin.js
Created August 15, 2019 13:13
vuex-persistedstate performance in modular Vuex
import VuexPersistedState from 'vuex-persistedstate'
export const TestPlugin = VuexPersistedState({
key: 'test',
storage: window.localStorage,
paths: ['value']
})
@YuraKolesnikov
YuraKolesnikov / array.js
Created July 9, 2019 10:42
Working with array
const array = [
{ name: 'Alfred', ranking: 3 },
{ name: 'Boris', ranking: 5 },
{ name: 'Chris', ranking: 2 },
{ name: 'Dylan', ranking: 1 },
{ name: 'Fitzgerald', ranking: 4 }
]
const sortByRanking = () => array.sort((a, b) => a.ranking > b.ranking)
const array = [
{ name: 'Alfred', ranking: 3 },
{ name: 'Boris', ranking: 5 },
{ name: 'Chris', ranking: 2 },
{ name: 'Dylan', ranking: 1 },
{ name: 'Fitzgerald', ranking: 4 }
]
const sortByRanking = () => array.sort((a, b) => a.ranking > b.ranking)
@YuraKolesnikov
YuraKolesnikov / index.html
Created July 7, 2019 16:38
Select on change fetch
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<select name="category" id="category-select">
const path = require('path');
module.exports = {
entry: './src/app.js',
output: {
path: path.resolve(__dirname, './public'),
filename: 'app.js',
publicPath: '/public'
},
module: {