Skip to content
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 v1.0 #87

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open

Conversation

EgorTglhf
Copy link

No description provided.

chartHeight = 50;
import fetchJson from '../../utils/fetch-json.js';

const BACKEND_URL = process.env.BACKEND_URL;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good 👍
лайк за использование переменных окружения

this.chartHeight = 50;

this.range = range;
this.url = new URL(url, BACKEND_URL);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 good

elementLink.href = this.link;
elementLink.classList.add('column-chart__link');
elementLink.textContent = 'View all';
this.element.querySelector('.column-chart__title').append(elementLink);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

было бы неплохо получить ссылку на этот эл-т заранее и не искать его в этом методе

@@ -0,0 +1,198 @@
export default class DoubleSlider {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 good

this.render();
}

static currentElement;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лучше располагать данное св-во до констурктора

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вообще все статические св-ва лучше располагать до констурктора

this.element = element.firstElementChild;
}

show(element = document.body) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 good

@@ -2,9 +2,10 @@ import SortableList from '../sortable-list/index.js';
import escapeHtml from '../../utils/escape-html.js';
import fetchJson from '../../utils/fetch-json.js';

const IMGUR_CLIENT_ID = process.env.IMGUR_CLIENT_ID;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 good


fileInput.onchange = async () => {
const [file] = fileInput.files;
elementInputFile.onchange = async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

здесь не критично, так как мы уверены что будет только один обработчик события, но на практике лучше всегда использовать метод addEventListener

template() {
return `
<div class="product-form">
this.urlCategory = new URL('api/rest/categories', BACKEND_URL);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

может следует вынести данную логику инициализации url в отдельный метод с целью разгрузить конструктор?

}
async loadData() {
const resultCategoryPromise = fetchJson(this.urlCategory);
const resultProductPromise = this.isNewProduct
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 good

? parseInt(productForm[field].value)
: productForm[field].value;
}
const [resultCategory, resultProduct] = await Promise.all([resultCategoryPromise, resultProductPromise]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 good
лайк за параллельную загрузку независимых данных

if (this.categories) {
for (const category of this.categories) {
for (const subCategory of category.subcategories) {
let newOption = new Option(`${category.title} > ${subCategory.title}`, subCategory.id);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 good
лайк за использование new Option

const element = productForm.querySelector(`#${item}`);
wrapper.innerHTML = `
<li class="products-edit__imagelist-item sortable-list__item" style="">
<input type="hidden" name="url" value="${escapeHtml(url)}">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good 👍
лайк за использование escapeHTML


async loadCategoriesList() {
return await fetchJson(`${process.env.BACKEND_URL}api/rest/categories?_sort=weight&_refs=subcategory`);
const sortableListImages = new SortableList({ items });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good 👍

@@ -1,50 +1,48 @@
export default class SortableList {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good 👍


const BACKEND_URL = 'https://course-js.javascript.ru';
const BACKEND_URL = process.env.BACKEND_URL;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good 👍

this.step = step;
this.start = start;
this.end = end;
this.url = new URL(url, BACKEND_URL);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good 👍

sortLocally(id, order) {
const sortedData = this.sortData(id, order);
initEventListener() {
window.addEventListener('scroll', async (event) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good 👍

if (this.params.id) this.url.searchParams.set('_sort', this.params.id);
if (this.params.order) this.url.searchParams.set('_order', this.params.order);

await fetchJson(this.url)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не смешивайте await с then

this.renderData();
this.isLoading = false;
})
.catch(error => console.error('Something went wrong: ' + error));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

здесь обработку ошибки следует делать через try...catch


await fetchJson(this.url)
.then(data => {
this.data = this.data.concat(data);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.data = [...this.data, ...data];

}

destroy() {
this.remove();
this.element = null;
document.removeEventListener('pointerover', this.onMouseOver);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good 👍

components = {};
categories;

constructor() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good 👍

}

onSortableListReordered = async (event) => {
console.log('got it', event.target);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не оставляйте консоли в готовом проекте


this.notificationCategoryOrderedSaved();
} catch (error) {
console.error('something went wrong', error);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 good

destroy () {
destroy() {
this.remove();
this.element = null;
for (const component of Object.values(this.components)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good 👍
лайк за destroy компонент

destroy() {
this.remove();
this.element = null;
for (const component of Object.values(this.components)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good 👍

const rangePicker = new RangePicker(this.range);

this.sales = {
url: `api/rest/orders?createdAt_gte=${rangePicker.selected.from.toISOString()}&createdAt_lte=${rangePicker.selected.to.toISOString()}`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не забывайте за new URL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants