-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Final project #91
base: master
Are you sure you want to change the base?
Final project #91
Conversation
@@ -0,0 +1,96 @@ | |||
import SortableList from '../../components/sortable-list/index.js'; | |||
|
|||
export default class Category { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good 👍
лайк за выделение данного функционала в отдельный компонент
|
||
initComponents() { | ||
const sortableList = new SortableList({ | ||
items: this.category.subcategories.map(item => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
может вынести данную логику в отдельный метод?
чтобы не загромождать инициализацию SortableList?
components; | ||
|
||
constructor(category = {}) { | ||
this.category = category; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
category or categories?
категоря одна или их много?
this.remove(); | ||
this.element = null; | ||
|
||
for (const component of Object.values(this.components)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 good
лайк за дестрой внутренних компонент
data; | ||
|
||
constructor({url = '', range = {from: new Date(), to: new Date()}, label = '', link = '', formatHeading = (str => `${str}`)} = {}) { | ||
this.url = new URL(url, vars.BACKEND_URL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 good
@@ -1,89 +1,107 @@ | |||
import fetchJson from '../../utils/fetch-json.js'; | |||
import vars from '../../utils/vars.js'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
очень странное имя vars
может лучше назвать данный файл "config.js"?
} | ||
|
||
getTemplate() { | ||
const linkA = this.link ? `<a href=${this.link} class="column-chart__link">View all</a>` : ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
что такое linkA?
почему А?
return date.toLocaleString('ru', {dateStyle: 'short'}) | ||
months = [ | ||
'январь', | ||
'февраль', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
подумайте как сгенерировать данный список динамично
|
||
static formatDate(date) { | ||
const year = date.getFullYear(); | ||
const month = (date.getMonth() + 1) < 10 ? '0' + (date.getMonth() + 1) : (date.getMonth() + 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
что такое 10
{url = '', isSortLocally = false, | ||
sorted = {id: headerConfig.find(item => item.sortable).id, order: 'asc'}} = {}) { | ||
this.headerConfig = headerConfig; | ||
this.url = new URL(url, vars.BACKEND_URL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 good
</span>` | ||
: ''; | ||
getRows() { | ||
const bodyRows = Array.from(this.subElements.body.querySelectorAll('.sortable-table__row')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
почему используется Array.from a не spread syntax?
destroy() { | ||
this.remove(); | ||
this.subElements = {}; | ||
document.addEventListener('scroll', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good 👍
this.element.classList.add('sortable-table_empty'); | ||
} | ||
destroy() { | ||
this.remove(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а где удаление обработчика скрола?
destroy() { | ||
this.remove(); | ||
this.subElements = {}; | ||
document.addEventListener('scroll', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а где удаление обработчика скрола?
|
||
} | ||
|
||
initEventListeners() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
почему пустой метод?
this.element = null; | ||
|
||
for (const component of Object.values(this.components)) { | ||
component.destroy(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 good
|
||
this.element = element.firstElementChild; | ||
const promiseCategory = fetchJson(this.urlCategory); | ||
const promiseProduct = id ? fetchJson(this.urlProduct) : Promise.resolve(this.defaultData); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 good
|
||
this.dispatchEvent(result.id); | ||
} catch (error) { | ||
console.error('error', error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
можно также показать нотификейшен в случае ошибки
fileInput.click(); | ||
}; | ||
|
||
onSubmit = event => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 good
import SortableTable from '../../../components/sortable-table/index.js'; | ||
import DoubleSlider from "../../../components/double-slider/index.js" | ||
|
||
const header = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
может стоит вынести конфиг хедера в отдельный файл?
isSortLocally: false, | ||
sorted: {id: 'title', order: 'asc'} | ||
}); | ||
// const productId = '101-planset-lenovo-yt3-x90l-64-gb-3g-lte-cernyj'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не оставляйте закомментированный код
sortable: true, | ||
sortType: 'date', | ||
template: date => { | ||
const data = new Date(Date.parse(date)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
шаблон должен содержать логику отображения, а не бизнес-логику
@@ -0,0 +1,13 @@ | |||
const vars = { | |||
BACKEND_URL: 'https://course-js.javascript.ru', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
часть из этих значений следует взять из переменных окружения,
они доступны через process.env
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
посмотрите пожалуйста комментарии
Часть функционала еще не доделана. Не прикручена форма добавления/редактирования товара.