Skip to content

Commit

Permalink
Добавление обработчиков в поинт вью
Browse files Browse the repository at this point in the history
  • Loading branch information
Phoenix8483 committed Sep 30, 2024
1 parent 9db963c commit 84f0521
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
25 changes: 13 additions & 12 deletions src/presenter/board-presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,34 @@ import {render} from '../framework/render.js';
const siteMainElement = document.querySelector('.page-body');
const siteTripInfo = siteMainElement.querySelector('.trip-info'); // Инфо в шапке про маршрут
export default class BoardPresenter {

#container = null;
#pointsModel = null;
constructor({container, pointsModel}) {
this.container = container;
this.pointsModel = pointsModel;
this.#container = container;
this.#pointsModel = pointsModel;
}

init() {

render(new TripInfoView(), siteTripInfo); // Отображение информации в шапке про маршрут
this.boardPoints = [...this.pointsModel.points];
this.boardPoints = [...this.#pointsModel.points];

this.boardOffers = [...this.pointsModel.offers];
this.boardOffers = [...this.#pointsModel.offers];
const offersView = new OffersView({
point: this.boardPoints[0],
allOffers: this.pointsModel.getOffersByType(this.boardPoints[0].type),
pointDestination: this.pointsModel.getDestinationsById(this.boardPoints[0].destination),
allDestination: this.pointsModel.destinations
allOffers: this.#pointsModel.getOffersByType(this.boardPoints[0].type),
pointDestination: this.#pointsModel.getDestinationsById(this.boardPoints[0].destination),
allDestination: this.#pointsModel.destinations
});
render(offersView, this.container); //Отображение формы редактирования
render(offersView, this.#container); //Отображение формы редактирования

for (let i = 0; i < this.boardPoints.length; i++) {
const point = new PointView({
point: this.boardPoints[i],
offers: [...this.pointsModel.getOffersById(this.boardPoints[i].type, this.boardPoints[i].offers)],
destination: this.pointsModel.getDestinationsById(this.boardPoints[i].destination)
offers: [...this.#pointsModel.getOffersById(this.boardPoints[i].type, this.boardPoints[i].offers)],
destination: this.#pointsModel.getDestinationsById(this.boardPoints[i].destination)
});
render(point, this.container); //Отображение поинтов
render(point, this.#container); //Отображение поинтов
}
}
}
Expand Down
16 changes: 15 additions & 1 deletion src/view/trip-point-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,28 @@ export default class PointView extends AbstractView{
#point = null;
#offers = null;
#destination = null;
constructor({point, offers, destination}) {
#onOpenEditButtonClick = null;
constructor({point, offers, destination, onOpenEditButtonClick}) {
super();
this.#point = point;
this.#offers = offers;
this.#destination = destination;
this.#onOpenEditButtonClick = onOpenEditButtonClick;
this.#setEventListeners();
}

get template() {
return createListTemplate(this.#point, this.#offers, this.#destination);
}

#setEventListeners() {
this.element
.querySelector('.event__rollup-btn')
.addEventListener('click', this.#openEditButtonClickHandler);
}

#openEditButtonClickHandler = (evt) => {
evt.preventDefault(evt);
this.#onOpenEditButtonClick();
};
}

0 comments on commit 84f0521

Please sign in to comment.