Skip to content

Commit

Permalink
верстка
Browse files Browse the repository at this point in the history
  • Loading branch information
dashuulka committed Jun 10, 2024
1 parent 995b2f3 commit e699b52
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
2 changes: 1 addition & 1 deletion src/model/point-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default class PointsModel extends Observable {
#pointsApiService = null;
#points = [];

constructor({pointsApiService}) {
constructor({ pointsApiService }) {
super();
this.#pointsApiService = pointsApiService;
}
Expand Down
14 changes: 7 additions & 7 deletions src/presenter/point-presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand All @@ -107,9 +108,8 @@ export default class PointPresenter {
isDeleting: false,
});
};

this.#pointEditComponent.shake(resetFormState);
};
}

destroy() {
remove(this.#pointComponent);
Expand Down
20 changes: 14 additions & 6 deletions src/presenter/trip-presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}}

Check failure on line 199 in src/presenter/trip-presenter.js

View workflow job for this annotation

GitHub Actions / Check

Expected indentation of 10 spaces but found 8
break;
case UserAction.ADD_POINT:
try {
Expand Down
26 changes: 15 additions & 11 deletions src/template/editing-form-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ function createPointType({ currentType, isDisabled }) {
function createPointOffer({ offers, currentOffers, isDisabled }) {
return currentOffers.offers?.map((offer) => `
<div class="event__offer-selector">
<input class="event__offer-checkbox visually-hidden" data-offer-id="${offer.id}"
id="event-offer-${offer.id}-1" type="checkbox" name="event-offer-${offer.id}" ${offers.includes(offer.id) ? 'checked' : ''} ${isDisabled ? 'disabled' : ''}>
<label class="event__offer-label" for="event-offer-${offer.id}">
<span class="event__offer-title">${offer.title}</span>
<input class="event__offer-checkbox visually-hidden" ${isDisabled ? "disabled" : ""} data-offer-id="${offer.id}"

Check failure on line 16 in src/template/editing-form-template.js

View workflow job for this annotation

GitHub Actions / Check

Strings must use singlequote

Check failure on line 16 in src/template/editing-form-template.js

View workflow job for this annotation

GitHub Actions / Check

Strings must use singlequote
id="event-offer-${he.encode(offer.id)}-1" type="checkbox" name="event-offer-${he.encode(offer.title)}" ${offers.includes(offer.id) ? 'checked' : ''}>
<label class="event__offer-label" for="event-offer-${he.encode(offer.id)}">
<span class="event__offer-title">${he.encode(offer.title)}</span>
&plus;&euro;&nbsp;
<span class="event__offer-price">${offer.price}</span>
<span class="event__offer-price">${he.encode(String(offer.price))}</span>
</label>
</div>`).join('');
}
Expand Down Expand Up @@ -79,10 +79,10 @@ function createButtonsTemplate({ pointType, isSaving, isDeleting, isDisabled })

function createEditPointTemplate({state, pointDestinations, pointOffers, pointType}) {
const { point, isDisabled, isSaving, isDeleting } = state;
const { type, dateFrom, dateTo, basePrice, offers } = state.point;
const { dateFrom, dateTo, basePrice, offers, type } = point;

const currentDestination = pointDestinations.find((destination) => destination.id === state.point.destination);
const currentOffers = pointOffers.find((offer) => offer.type === state.point.type);
const currentDestination = pointDestinations.find((destination) => destination.id === point.destination);
const currentOffers = pointOffers.find((offer) => offer.type === point.type);
const destinationName = (currentDestination) ? currentDestination.name : '';

return (`
Expand Down Expand Up @@ -128,11 +128,15 @@ function createEditPointTemplate({state, pointDestinations, pointOffers, pointTy
${createButtonsTemplate({ pointType, isSaving, isDeleting, isDisabled })}
</header>
<section class="event__details">
${currentOffers.offers.length ? `
<section class="event__section event__section--offers">
<h3 class="event__section-title event__section-title--offers">Offers</h3>
${createPointOffer({ offers, currentOffers, isDisabled })}
</section>
${currentDestination ? `<section class="event__section event__section--destination">
<div class="event__available-offers">
${createPointOffer({ offers, currentOffers, isDisabled })}
</div>
</section>` : ''}
${currentDestination?.description && currentDestination?.pictures.length ? `<section class="event__section event__section--destination">
${createDestination(currentDestination)}
</section>` : ''}
</section>
Expand Down
2 changes: 1 addition & 1 deletion src/view/event-list-empty-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createEmptyListPointsTemplate } from '../template/event-list-empty-temp
export default class EventListEmptyView extends AbstractView {
#filterType = null;

constructor({filterType}) {
constructor({ filterType }) {
super();
this.#filterType = filterType;
}
Expand Down
2 changes: 1 addition & 1 deletion src/view/filter-points-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default class FilterPointsView extends AbstractView {
#currentFilter = null;
#handleFilterTypeChange = null;

constructor({filters, currentFilter, onFilterTypeChange}) {
constructor({ filters, currentFilter, onFilterTypeChange }) {
super();
this.#filters = filters;
this.#currentFilter = currentFilter;
Expand Down
2 changes: 1 addition & 1 deletion src/view/trip-info-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createTripInfoTemplate } from '../template/trip-info-template.js';
export default class TripInfoView extends AbstractView {
#info = null;

constructor({info}) {
constructor({ info }) {
super();
this.#info = info;
}
Expand Down

0 comments on commit e699b52

Please sign in to comment.