diff --git a/src/main.js b/src/main.js index 0605f4f..11793dc 100644 --- a/src/main.js +++ b/src/main.js @@ -17,7 +17,7 @@ import OffersApiService from './api-service/offers-api-server.js'; import { AUTHORIZATION, END_POINT } from './const.js'; -const siteMainElement = document.querySelector('.page-main'); +const siteMainElement = document.querySelector('.trip-events'); const tripInfoElement = document.querySelector('.trip-main'); const filterElement = tripInfoElement.querySelector('.trip-controls__filters'); diff --git a/src/model/point-model.js b/src/model/point-model.js index 5da8d66..6c04122 100644 --- a/src/model/point-model.js +++ b/src/model/point-model.js @@ -5,7 +5,7 @@ export default class PointsModel extends Observable { #pointsApiService = null; #points = []; - constructor({pointsApiService}) { + constructor({ pointsApiService }) { super(); this.#pointsApiService = pointsApiService; } diff --git a/src/presenter/point-presenter.js b/src/presenter/point-presenter.js index a5835e8..338e75f 100644 --- a/src/presenter/point-presenter.js +++ b/src/presenter/point-presenter.js @@ -79,25 +79,26 @@ export default class PointPresenter { remove(prevPointEditComponent); } - setSaving = () => { + setSaving() { if (this.#mode === Mode.EDITING) { this.#pointEditComponent.updateElement({ isDisabled: true, isSaving: true }); } - }; + } - setDeleting = () => { + setDeleting() { this.#pointEditComponent.updateElement({ isDisabled: true, isDeleting: true }); - }; + } - setAborting = () => { + setAborting() { if (this.#mode === Mode.DEFAULT) { this.#pointComponent.shake(); + return; } const resetFormState = () => { @@ -107,9 +108,8 @@ export default class PointPresenter { isDeleting: false, }); }; - this.#pointEditComponent.shake(resetFormState); - }; + } destroy() { remove(this.#pointComponent); diff --git a/src/presenter/trip-presenter.js b/src/presenter/trip-presenter.js index 8207319..2fbc76f 100644 --- a/src/presenter/trip-presenter.js +++ b/src/presenter/trip-presenter.js @@ -183,12 +183,20 @@ export default class TripPresenter { switch(actionType) { case UserAction.UPDATE_POINT: - try { - this.#pointPresenters.get(update.id).setSaving(); - await this.#pointsModel.updatePoint(updateType, update); - } catch (err) { - this.#pointPresenters.get(update.point.id).setAborting(); - } + if(update.point){ + try { + this.#pointPresenters.get(update.point.id).setSaving(); + await this.#pointsModel.updatePoint(updateType, update.point); + } catch (err) { + this.#pointPresenters.get(update.point.id).setAborting(); + } + } else { + try { + this.#pointPresenters.get(update.id).setSaving(); + await this.#pointsModel.updatePoint(updateType, update); + } catch (err) { + this.#pointPresenters.get(update.id).setAborting(); + }} break; case UserAction.ADD_POINT: try { diff --git a/src/template/editing-form-template.js b/src/template/editing-form-template.js index 495a5a3..426a5e2 100644 --- a/src/template/editing-form-template.js +++ b/src/template/editing-form-template.js @@ -13,12 +13,12 @@ function createPointType({ currentType, isDisabled }) { function createPointOffer({ offers, currentOffers, isDisabled }) { return currentOffers.offers?.map((offer) => `