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

финальные правки #25

Merged
merged 2 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/model/cities-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ export default class CitiesModel {
this.#pointApiService = pointApiService;
}

async init() {
this.#cities = await this.#pointApiService.destinations;
get cities() {
return this.#cities;
}

get cities() {
async init() {
this.#cities = await this.#pointApiService.destinations;
return this.#cities;
}

Expand Down
6 changes: 3 additions & 3 deletions src/model/offers-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ export default class OffersModel {
this.#pointApiService = pointApiService;
}

async init() {
this.#offers = await this.#pointApiService.offers;
get offers() {
return this.#offers;
}

get offers() {
async init() {
this.#offers = await this.#pointApiService.offers;
return this.#offers;
}

Expand Down
8 changes: 4 additions & 4 deletions src/model/point-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export default class TaskModel extends Observable {
this.#points = [];
}

get points() {
return this.#points.sort(sortByDay);
}

async init() {
try {
const points = await this.#pointApiService.points;
Expand All @@ -24,10 +28,6 @@ export default class TaskModel extends Observable {
this._notify(UpdateType.INIT);
}

get points() {
return this.#points.sort(sortByDay);
}

async updatePoint(updateType, update) {
try {
const response = await this.#pointApiService.updatePoint(update);
Expand Down
8 changes: 4 additions & 4 deletions src/presenter/board-presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ export default class BoardPresenter {
this.#filterModel.addObserver(this.#handleModelPoint);
}

init() {
this.#renderBoard();
}

get points() {
this.#filterType = this.#filterModel.filter;
const points = this.#pointModel.points;
Expand All @@ -75,6 +71,10 @@ export default class BoardPresenter {
return filteredPoints;
}

init() {
this.#renderBoard();
}

createPoint() {
this.#currentSortType = SortType.DAY;
this.#filterModel.setFilter(UpdateType.MAJOR, FilterType.EVERYTHING);
Expand Down
20 changes: 10 additions & 10 deletions src/presenter/filter-presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ export default class FilterPresenter {
this.#filterModel.addObserver(this.#handleModelPoint);
}

get filters() {
const points = this.#pointModel.points;

return Object.values(FilterType).map((type) => ({
type,
name: type.toUpperCase(),
count: filters[type](points).length
}));
}

init() {
const filter = this.filters;
const prevFilterComponent = this.#filterComponent;
Expand All @@ -37,16 +47,6 @@ export default class FilterPresenter {
remove(prevFilterComponent);
}

get filters() {
const points = this.#pointModel.points;

return Object.values(FilterType).map((type) => ({
type,
name: type.toUpperCase(),
count: filters[type](points).length
}));
}

#handleModelPoint = () => {
this.init();
};
Expand Down
1 change: 0 additions & 1 deletion src/presenter/new-point-presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export default class NewPointPresenter {
UpdateType.MINOR,
point,
);
this.destroy();
};

#handleResetClick = () => {
Expand Down
4 changes: 4 additions & 0 deletions src/presenter/point-presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ export default class PointPresenter {
}

setAborting() {
if (this.#mode === Mode.DEFAULT){
this.#pointComponent.shake();
return;
}
const resetFormState = () => {
this.#pointEditComponent.updateElement({
isDisabled: false,
Expand Down
3 changes: 2 additions & 1 deletion src/view/point-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { getDateDifference, getMonthAndDate, getTime } from '../utils/point-util

function createPointTemplate(point, pointCity, pointOffers) {
const { type, offers, dateFrom, dateTo, basePrice, isFavorite } = point;
const favoriteClass = isFavorite ? 'event_favorite-btn--active' : '';
return (
`<li class="trip-events__item">
<div class="event">
Expand Down Expand Up @@ -32,7 +33,7 @@ function createPointTemplate(point, pointCity, pointOffers) {
<span class="event__offer-price">${offer.price}</span>
</li>` : '').join('')}
</ul>
<button class="event__favorite-btn ${isFavorite}" type="button">
<button class="event__favorite-btn ${favoriteClass}" type="button">
<span class="visually-hidden">Add to favorite</span>
<svg class="event__favorite-icon" width="28" height="28" viewBox="0 0 28 28">
<path d="M14 21l-8.22899 4.3262 1.57159-9.1631L.685209 9.67376 9.8855 8.33688 14 0l4.1145 8.33688 9.2003 1.33688-6.6574 6.48934 1.5716 9.1631L14 21z"/>
Expand Down
Loading