diff --git a/src/main.js b/src/main.js index 6ddf100..e8d3c44 100644 --- a/src/main.js +++ b/src/main.js @@ -37,8 +37,7 @@ const filterPresenter = new PresenterFilter({ const presenterInfoPanel = new PresenterInfoPanel({ tripInfoContainer: tripMainElement, - pointsModel, - presenter: presenter + pointsModel }); function handleNewPointButtonClick() { diff --git a/src/model/points-model.js b/src/model/points-model.js index 1e556a3..5c21470 100644 --- a/src/model/points-model.js +++ b/src/model/points-model.js @@ -47,7 +47,7 @@ export default class PointsModel extends Observable { this.#offers = offers; this.#destinations = destinations; - } catch (err) { + } catch (error) { this.#points = []; this.#offers = []; this.#destinations = []; @@ -73,7 +73,7 @@ export default class PointsModel extends Observable { ]; this._notify(updateType, updatedPoint); - } catch (err) { + } catch (error) { throw new Error('Can\'t update point'); } } @@ -89,7 +89,7 @@ export default class PointsModel extends Observable { ]; this._notify(updateType, newPoint); - } catch (err) { + } catch (error) { throw new Error('Can\'t add point'); } @@ -109,7 +109,7 @@ export default class PointsModel extends Observable { ]; this._notify(updateType); - } catch (err) { + } catch (error) { throw new Error('Can\'t delete point'); } } diff --git a/src/presenter/presenter-info-panel.js b/src/presenter/presenter-info-panel.js index c898b0b..f9e8a6c 100644 --- a/src/presenter/presenter-info-panel.js +++ b/src/presenter/presenter-info-panel.js @@ -5,19 +5,15 @@ export default class PresenterInfoPanel { #tripInfoContainer = null; #pointsModel = null; #tripInfoComponent = null; - #presenter = null; - constructor({ tripInfoContainer, pointsModel, presenter }) { + constructor({ tripInfoContainer, pointsModel }) { this.#tripInfoContainer = tripInfoContainer; - this.#presenter = presenter; this.#pointsModel = pointsModel; - this.#pointsModel.addObserver(this.#handleModelEvent); } init() { - // const points = this.#presenter.points; const points = this.#pointsModel.events; const offers = this.#pointsModel.offers; const destinations = this.#pointsModel.destinations; diff --git a/src/presenter/presenter-main.js b/src/presenter/presenter-main.js index 3bfc5c8..bce2524 100644 --- a/src/presenter/presenter-main.js +++ b/src/presenter/presenter-main.js @@ -94,7 +94,7 @@ export default class PresenterMain { this.#pointPresenterItems.get(update.id).setSaving(); await this.#pointsModel.updatePoint(updateType, update); - } catch (err) { + } catch (error) { this.#pointPresenterItems.get(update.id).setAborting(); } break; @@ -102,7 +102,7 @@ export default class PresenterMain { try { this.#presenterNewPoint.setSaving(); await this.#pointsModel.addPoint(updateType, update); - } catch (err) { + } catch (error) { this.#presenterNewPoint.setAborting(); } break; @@ -110,7 +110,7 @@ export default class PresenterMain { this.#pointPresenterItems.get(update.id).setDeleting(); try { await this.#pointsModel.deletePoint(updateType, update); - } catch (err) { + } catch (error) { this.#pointPresenterItems.get(update.id).setAborting(); } break; @@ -259,6 +259,4 @@ export default class PresenterMain { this.#listEmptyMessage(); } }; - - } diff --git a/src/view/list-empty.js b/src/view/list-empty.js index 19d65a8..0b93574 100644 --- a/src/view/list-empty.js +++ b/src/view/list-empty.js @@ -1,7 +1,7 @@ import AbstractView from '../framework/view/abstract-view.js'; import { tripMessagesEmpty } from '../utils/filter.js'; -const createtListempty = (filterType) => `

${tripMessagesEmpty[filterType]}

`; +const createListEmpty = (filterType) => `

${tripMessagesEmpty[filterType]}

`; export default class ListEmpty extends AbstractView { #filterType = null; @@ -12,6 +12,6 @@ export default class ListEmpty extends AbstractView { } get template() { - return createtListempty(this.#filterType); + return createListEmpty(this.#filterType); } } diff --git a/src/view/waypoint-edit.js b/src/view/waypoint-edit.js index efaf8d0..95761e3 100644 --- a/src/view/waypoint-edit.js +++ b/src/view/waypoint-edit.js @@ -93,9 +93,7 @@ const createWaypointForm = (waypoint, destinations, offers, pointsModel) => { const { type, dateFrom, dateTo, basePrice, offers: offersPoint, isDisabled, isSaving, isDeleting } = waypoint; - // const offerCurrent = offers.find((item) => item.type === waypoint.type); const destinationCurrent = destinations.find((item) => item.id === waypoint.destination); - const createPointDestinationList = createPointDestination(destinationCurrent); const createPointOffersList = createPointOffers(offers, offersPoint); const cityList = createCityList(destinations); @@ -159,17 +157,15 @@ export default class WaypointEdit extends AbstractStatefulView { #onEditFormRollupButtonClick = null; #onDeleteForm = null; #destinations = null; - #offers = null; #datepickerFrom = null; #datepickerTo = null; #onEditFormSave = null; #pointsModel = null; #getOffersByType = null; - constructor({ waypoint = BLANK_POINT, onEditFormSave, onEditFormRollupButtonClick, onDeleteForm, offers, pointsModel, destinations, getOffersByType }) { + constructor({ waypoint = BLANK_POINT, onEditFormSave, onEditFormRollupButtonClick, onDeleteForm, pointsModel, destinations, getOffersByType }) { super(); this._setState(WaypointEdit.parsePointToState(waypoint)); - this.#offers = offers; this.#destinations = destinations; this.#onEditFormRollupButtonClick = onEditFormRollupButtonClick; this.#onEditFormSave = onEditFormSave;