Skip to content

Commit

Permalink
feat: add private class fields, add getters instead of functions
Browse files Browse the repository at this point in the history
  • Loading branch information
KseniaTry committed Sep 15, 2024
1 parent 41e1fe4 commit 18ac080
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
18 changes: 9 additions & 9 deletions src/model/point-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ import { getDestinations } from '../mock/destinations-mock';
import { getOffers } from '../mock/offers-mock';

export default class PointModel {
points = getPoints();
destinations = getDestinations();
offers = getOffers();
#points = getPoints();
#destinations = getDestinations();
#offers = getOffers();

getPoints() {
return this.points;
get points() {
return this.#points;
}

getDestinations() {
return this.destinations;
get destinations() {
return this.#destinations;
}

getOffers() {
return this.offers;
get offers() {
return this.#offers;
}
}
29 changes: 17 additions & 12 deletions src/presenter/main-presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,30 @@ import { render } from '../framework/render';


export default class MainPresenter {
pointsListComponent = new PointListView();
#pointsListComponent = new PointListView();
#pointsContainer = null;
#pointModel = null;
#points = [];
#destinations = [];
#offers = [];

constructor({pointsContainer, pointModel}) {
this.pointsContainer = pointsContainer;
this.pointModel = pointModel;
this.#pointsContainer = pointsContainer;
this.#pointModel = pointModel;
}

init() {
this.points = [...this.pointModel.getPoints()];
this.destinations = [...this.pointModel.getDestinations()];
this.offers = [...this.pointModel.getOffers()];
this.#points = [...this.#pointModel.points];
this.#destinations = [...this.#pointModel.destinations];
this.#offers = [...this.#pointModel.offers];

render(new SortingView(), this.pointsContainer);
render(this.pointsListComponent, this.pointsContainer);
render(new EditPoint({point: this.points[0], offers: this.offers, destinations: this.destinations}), this.pointsListComponent.element);
render(new CreatePoint(), this.pointsListComponent.element);
render(new SortingView(), this.#pointsContainer);
render(this.#pointsListComponent, this.#pointsContainer);
render(new EditPoint({point: this.#points[0], offers: this.#offers, destinations: this.#destinations}), this.#pointsListComponent.element);
render(new CreatePoint(), this.#pointsListComponent.element);

for (let i = 1; i < this.points.length; i++) {
render(new PointItemView({point: this.points[i], offers: this.offers, destinations: this.destinations}), this.pointsListComponent.element);
for (let i = 1; i < this.#points.length; i++) {
render(new PointItemView({point: this.#points[i], offers: this.#offers, destinations: this.#destinations}), this.#pointsListComponent.element);
}
}
}

0 comments on commit 18ac080

Please sign in to comment.