diff --git a/src/const.js b/src/const.js index 31e6f7d..f232a5c 100644 --- a/src/const.js +++ b/src/const.js @@ -1,77 +1,3 @@ -// export const TYPES = ['taxi', 'bus', 'train', 'ship', 'drive', 'flight', 'check-in', 'sightseeing', 'restaurant']; - -// export const OFFERS = [ -// 'Add luggage', -// 'Switch to comfort class', -// 'Add meal', -// 'Choose seats', -// 'Add a child safety seat' -// ]; - -// export const CITIES = ['Magnolia', 'Greed Island', 'Soul Society', 'Amestris', 'Death City', 'Karakura', 'Z-City', 'Alubarna', 'Aincrad']; - -// export const DESCRIPTIONS = [ -// 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', -// 'Maecenas dapibus sed enim in ultrices.', -// 'Praesent non ex turpis.', -// 'Nunc mollis sed tortor a faucibus.', -// 'Morbi ac convallis erat, vel volutpat nisl.', -// 'Phasellus a interdum lacus. Aenean consectetur magna vel diam fringilla, at commodo sem placerat.', -// 'Etiam a pellentesque massa.', -// 'Sed sed nisi sed augue convallis suscipit in sed felis.', -// 'Aliquam erat volutpat.' -// ]; - -// export const Duration = { -// MIN: 60, -// HOUR: 10, -// DAY: 3 -// }; - -// export const DateFormat = { -// LONG: 'YYYY-MM-DDTHH:mm', -// SHORT: 'MMM DD' -// }; - -// export const Price = { -// MIN: 0, -// MAX: 1000 -// }; - -// export const MILLISECONDS_IN_DAY = 86400000; - -// export const MILLISECONDS_IN_HOUR = 3600000; - -// export const Mode = { -// DEFAULT: 'DEFAULT', -// EDITING: 'EDITING' -// }; - -// export const UserAction = { -// UPDATE_POINT: 'UPDATE_POINT', -// ADD_POINT: 'ADD_POINT', -// DELETE_POINT: 'DELETE_POINT' -// }; - -// export const UpdateType = { -// PATCH: 'PATCH', -// MAJOR: 'MAJOR', -// INIT: 'INIT' -// }; - -// export const POINT_COUNT_PER_STEP = 7; - -// export const ApiServiceMethod = { -// GET: 'GET', -// PUT: 'PUT', -// POST: 'POST', -// DELETE: 'DELETE' -// }; - -// export const TimeLimit = { -// LOWER_LIMIT: 350, -// UPPER_LIMIT: 1000, -// }; export const TYPES = ['taxi', 'bus', 'train', 'ship', 'drive', 'flight', 'check-in', 'sightseeing', 'restaurant']; export const FilterType = { diff --git a/src/model/point-model.js b/src/model/point-model.js index 1d46757..fc80a52 100644 --- a/src/model/point-model.js +++ b/src/model/point-model.js @@ -18,7 +18,7 @@ export default class PointModel extends Observable{ const points = await this.#pointsApiService.points; this.#points = points.map(this.#adaptToClient); } catch (error){ - this.#points = null; + this.#points = []; } this._notify(UpdateType.INIT); } diff --git a/src/presenter/point-presenter.js b/src/presenter/point-presenter.js index b5bf03e..f19b045 100644 --- a/src/presenter/point-presenter.js +++ b/src/presenter/point-presenter.js @@ -146,7 +146,6 @@ export default class PointPresenter{ UserAction.UPDATE_POINT, UpdateType.MINOR, update); - // this.#editPointComponent.reset(update); }; #handleDeleteClick = (point) => { diff --git a/src/presenter/trip-presenter.js b/src/presenter/trip-presenter.js index 9bb5057..89e07aa 100644 --- a/src/presenter/trip-presenter.js +++ b/src/presenter/trip-presenter.js @@ -42,7 +42,7 @@ class TripPresenter { this.#filtersModel = filtersModel; this.#newPointPresenter = new NewPointPresenter({ - pointListContainer: this.#container, + pointListContainer: this.#component.element, onFavoriteChange: this.#handleViewAction, onDestroy: onNewPointDestroy, destinationsModel: this.#destinationsModel, @@ -75,6 +75,7 @@ class TripPresenter { createPoint() { this.#currentSortType = SortType.DEFAULT; this.#filtersModel.setFilter(UpdateType.MAJOR, FilterType.EVERYTHING); + render(this.#component, this.#container); this.#newPointPresenter.init(); } diff --git a/src/view/edit-point-view.js b/src/view/edit-point-view.js index e92320e..fa44e51 100644 --- a/src/view/edit-point-view.js +++ b/src/view/edit-point-view.js @@ -231,7 +231,14 @@ export default class EditingPointView extends AbstractStatefulView{ #changeDestinationHandler = (event) => { event.preventDefault(); - const destination = this.#destinations.find((dest) => dest.name === event.target.value); + const inputDestinationName = event.target.value; + const destination = this.#destinations.find((dest) => dest.name === inputDestinationName); + + if (!destination) { + event.target.value = this._state.destination.name; + return; + } + this.updateElement({ destination: destination.id, }); diff --git a/src/view/new-point-view.js b/src/view/new-point-view.js deleted file mode 100644 index 05e4e81..0000000 --- a/src/view/new-point-view.js +++ /dev/null @@ -1,133 +0,0 @@ -import AbstractView from '../framework/view/abstract-view'; -import {humanizePointDate} from '../utils/point'; - -export const newPoint = (crNewPoint) => { - const {type, startDate, endDate, price} = crNewPoint; - const dateFrom = startDate !== null ? humanizePointDate(startDate, 'DD/MM/YY HH:mm') : ''; - const dateTo = endDate !== null ? humanizePointDate(endDate, 'DD/MM/YY HH:mm') : ''; - - return(`
  • -
    -
    -
    - - - -
    -
    - Event type - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    -
    -
    -
    - -
    - - - - - - - -
    - -
    - - - — - - -
    - -
    - - -
    - - - -
    -
    -
    -

    Offers

    - -
    -
    -
    - -
    -

    Destination

    -

    -
    -
    -
    -
    -
    -
    -
    -
  • - `); -}; - -export default class NewPointView extends AbstractView{ - constructor(crNewPoint) { - super(); - this.crNewPoint = crNewPoint; - } - - get template(){ - return newPoint(this.crNewPoint); - } -}