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

исправление ошибок #7

Closed
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
32 changes: 15 additions & 17 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import { render } from './render.js';
import FilterView from './view/filter.js';
import TripEventsPresenter from './presenter/trippresenter.js';
import DestinationsModel from './model/destinations-model';
import OffersModel from './model/offers';
import PointsModel from './model/points';
import DestinationsModel from './models/directions';
import OffersModel from './models/offers';
import PointsModel from './models/points';
import BoardPresenter from './presenters/boardpresenter';
import FilterPresenter from './presenters/filterpresenter';


const tripControlsFilters = document.querySelector('.trip-controls__filters');
const filterContainer = document.querySelector('.trip-controls__filters');
const boardContainer = document.querySelector('.trip-events');
const destinationsModel = new DestinationsModel();
const offersModel = new OffersModel();
const pointsModel = new PointsModel(destinationsModel, offersModel);
const tripEventsPresenter = new TripEventsPresenter({
container: boardContainer,
destinationsModel,
offersModel,
pointsModel
});

render(new FilterView(), tripControlsFilters);
const filterPresenter = new FilterPresenter({container: filterContainer});
const boardPresenter = new BoardPresenter({
container: boardContainer,
destinationsModel,
offersModel,
pointsModel
});

tripEventsPresenter.init();
filterPresenter.init();
boardPresenter.init();
73 changes: 36 additions & 37 deletions src/mock/const.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,37 @@
const CITIES = [
'Moscow',
'Saint Petersburg',
'Novosibirsk',
'Yekaterinburg',
'Kazan',
'Nizhny Novgorod',
'Chelyabinsk',
'Krasnoyarsk',
'Samara',
'Ufa',
];

const DESCRIPTION = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras aliquet varius magna, non porta ligula feugiat eget. Fusce tristique felis at fermentum pharetra. Aliquam id orci ut lectus varius viverra. Nullam nunc ex, convallis sed finibus eget, sollicitudin eget ante. Phasellus eros mauris, condimentum sed nibh vitae, sodales efficitur ipsum. Sed blandit, eros vel aliquam faucibus, purus ex euismod diam, eu luctus nunc ante ut dui. Sed sed nisi sed augue convallis suscipit in sed felis. Aliquam erat volutpat. Nunc fermentum tortor ac porta dapibus. In rutrum ac purus sit amet tempus.';

const OFFERS_NAMES = [
'Upgrade to a business class',
'Add luggage',
'Switch to comfort class',
'Add meal',
'Choose seats',
'Travel by train'
];

const POINT_TYPES = [
'taxi',
'bus',
'train',
'ship',
'drive',
'flight',
'check-in',
'sightseeing',
'restaurant',
];

export { CITIES, DESCRIPTION, OFFERS_NAMES, POINT_TYPES };

'Moscow',
'Saint Petersburg',
'Novosibirsk',
'Yekaterinburg',
'Kazan',
'Nizhny Novgorod',
'Chelyabinsk',
'Krasnoyarsk',
'Samara',
'Ufa',
];

const DESCRIPTION = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras aliquet varius magna, non porta ligula feugiat eget. Fusce tristique felis at fermentum pharetra. Aliquam id orci ut lectus varius viverra. Nullam nunc ex, convallis sed finibus eget, sollicitudin eget ante. Phasellus eros mauris, condimentum sed nibh vitae, sodales efficitur ipsum. Sed blandit, eros vel aliquam faucibus, purus ex euismod diam, eu luctus nunc ante ut dui. Sed sed nisi sed augue convallis suscipit in sed felis. Aliquam erat volutpat. Nunc fermentum tortor ac porta dapibus. In rutrum ac purus sit amet tempus.';

const OFFERS_NAMES = [
'Upgrade to a business class',
'Add luggage',
'Switch to comfort class',
'Add meal',
'Choose seats',
'Travel by train'
];

const POINT_TYPES = [
'taxi',
'bus',
'train',
'ship',
'drive',
'flight',
'check-in',
'sightseeing',
'restaurant',
];

export { CITIES, DESCRIPTION, OFFERS_NAMES, POINT_TYPES };
12 changes: 12 additions & 0 deletions src/presenters/filterpresenter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { render } from '../render';
import FilterView from '../view/filter-view';

export default class FilterPresenter {
constructor({ container }) {
this.container = container;
}

init() {
render(new FilterView(), this.container);
}
}
16 changes: 7 additions & 9 deletions src/presenters/trippresenter.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { render } from '../render';
import SortView from '../view/sort.js';
import ListView from '../view/list.js';
import EditablePointView from '../view/modpoint.js';
import PointListView from '../view/list.js';
import PointView from '../view/point.js';
import {render} from '../render.js';
import EditablePointView from '../view/modpoint.js';

export default class TripEventsPresenter {
listComponent = new ListView();
constructor({container, destinationsModel, offersModel, pointsModel }) {
export default class BoardPresenter {
constructor({ container, destinationsModel, offersModel, pointsModel }) {
this.container = container;
this.destinationsModel = destinationsModel;
this.offersModel = offersModel;
Expand All @@ -15,10 +14,9 @@ export default class TripEventsPresenter {

init() {
render(new SortView(), this.container);
const eventList = new ListView();
const eventList = new PointListView();
render(eventList, this.container);
const points = [...this.pointsModel.get()];

render(new EditablePointView({
point: points[0],
pointDestination: this.destinationsModel.getById(points[0].destination),
Expand All @@ -31,6 +29,6 @@ export default class TripEventsPresenter {
const pointOffers = this.offersModel.getByType(point.type);
const pointView = new PointView({ point, pointDestination, pointOffers });
render(pointView, eventList.getElement());
}
}
}
}
Loading