Skip to content

Commit

Permalink
test3 fix merge pull requests
Browse files Browse the repository at this point in the history
  • Loading branch information
ershegm committed Apr 14, 2024
1 parent 7fbe5c5 commit 6047947
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 227 deletions.
134 changes: 32 additions & 102 deletions src/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,17 @@ const HOUR_IN_DAY = 24;
const MAX_PRICE_VALUE = 200;
const MSEC_IN_HOUR = MSEC_IN_SEC * SEC_IN_MIN * MIN_IN_HOUR;
const MSEC_IN_DAY = MSEC_IN_HOUR * HOUR_IN_DAY;
const MAX_IMAGES_COUNT = 5;

const EVENT_TYPES = [
'taxi',
'bus',
'train',
'ship',
'drive',
'flight',
'check-in',
'sightseeing',
'restaurant',
];
'Taxi',
'Bus',
'Train',
'Ship', 'Drive',
'Flight',
'Check-in',
'Sightseeing',
'Restaurant'];


const CITIES = [
'Paris',
Expand All @@ -31,109 +29,41 @@ const CITIES = [
'San-Francisco'
];

const DESCRIPTIONS = [

const DESCCRIPTIONS = [
'Lorem ipsum dolor sit amet consectetur adipisicing elit. Incidunt architecto labore atque!',
'Lorem ipsum, dolor sit amet consectetur adipisicing elit. Voluptatem exercitationem culpa, molestias qui eveniet corrupti?',
'Lorem ipsum dolor sit amet consectetur, adipisicing elit. Eius, dolorem.',
'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Odit ad eaque cupiditate praesentium maxime.',
];

const Price = {
MIN: 1,
MAX: 500,
};

const MocksMaxCount = {
OFFERS: 7,
POINTS: 5,
};

const DateFormat = {
TIME: 'HH:mm',
SHORT: 'MMM DD',
FULL: 'YYYY-MM-DDTHH:mm',
WITH_DELIMITER: 'DD/MM/YY HH:mm',
};

const DurationFormat = {
DAYS: 'DD[D] HH[H] mm[M]',
HOURS: 'HH[H] mm[M]',
MINS: 'mm[M]',
};

const FilterType = {
ANY: 'any',
FUTURE: 'future',
PRESENT: 'present',
PAST: 'past'
const DATE_FORMATS = {
time: 'HH:mm',
shortDate: 'MMM DD',
formDateTime: 'DD/MM/YY HH:mm'
};

const SortType = {
DAY: 'day',
EVENT: 'event',
TIME: 'time',
PRICE: 'price',
OFFER: 'offer',
};

const FilterSettings = {
[FilterType.ANY]: {
label: 'Everything',
defaultSelected: true,
},
[FilterType.FUTURE]: { label: 'Future' },
[FilterType.PRESENT]: { label: 'Present' },
[FilterType.PAST]: { label: 'Past' },
const DURATION_FORMATS = {
days: 'DD[D] HH[H] mm[M]',
hours: 'HH[H] mm[M]',
mins: 'mm[M]'
};

const SORTING_COLUMNS = [
{
type: SortType.DAY,
label: 'Day',
active: true,
defaultSelected: true,
},
{
type: SortType.EVENT,
label: 'Event',
active: false,
},
{
type: SortType.TIME,
label: 'Time',
active: true,
},
{
type: SortType.PRICE,
label: 'Price',
active: true,
},
{
type: SortType.OFFER,
label: 'Offer',
active: false,
},
];

export {
POINTS_COUNT,
MSEC_IN_SEC,
SEC_IN_MIN,
MIN_IN_HOUR,
HOUR_IN_DAY,
MAX_PRICE_VALUE,
MSEC_IN_HOUR,
MSEC_IN_DAY,
MAX_IMAGES_COUNT,
EVENT_TYPES,
CITIES,
DESCRIPTIONS,
Price,
MocksMaxCount,
DateFormat,
DurationFormat,
FilterType,
FilterSettings,
SortType,
SORTING_COLUMNS,
POINTS_COUNT,
MSEC_IN_SEC,
SEC_IN_MIN,
MIN_IN_HOUR,
HOUR_IN_DAY,
MAX_PRICE_VALUE,
MSEC_IN_HOUR,
MSEC_IN_DAY,
EVENT_TYPES,
CITIES,
DESCCRIPTIONS,
DATE_FORMATS,
DURATION_FORMATS,
};
2 changes: 1 addition & 1 deletion src/framework/api-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default class ApiService {
/**
* Метод для обработки ответа
* @param {Response} response Объект ответа
* @returns {Promise}
* @returns {Promise<JSON>}
*/
static parseResponse(response) {
return response.json();
Expand Down
6 changes: 3 additions & 3 deletions src/framework/ui-blocker/ui-blocker.css
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
.ui-blocker {
display: none;
place-content: center;
position: fixed;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
min-width: 100%;
min-height: 100%;
z-index: 1000;
cursor: wait;
background-color: rgba(255, 255, 255, 0.5);
Expand Down
96 changes: 31 additions & 65 deletions src/framework/view/abstract-view.js
Original file line number Diff line number Diff line change
@@ -1,65 +1,31 @@
import {createElement} from '../render.js';
import './abstract-view.css';

/** @const {string} Класс, реализующий эффект "покачивания головой" */
const SHAKE_CLASS_NAME = 'shake';

/** @const {number} Время анимации в миллисекундах */
const SHAKE_ANIMATION_TIMEOUT = 600;

/**
* Абстрактный класс представления
*/
export default class AbstractView {
/** @type {HTMLElement|null} Элемент представления */
#element = null;

constructor() {
if (new.target === AbstractView) {
throw new Error('Can\'t instantiate AbstractView, only concrete one.');
}
}

/**
* Геттер для получения элемента
* @returns {HTMLElement} Элемент представления
*/
get element() {
if (!this.#element) {
this.#element = createElement(this.template);
}

return this.#element;
}

/**
* Геттер для получения разметки элемента
* @abstract
* @returns {string} Разметка элемента в виде строки
*/
get template() {
throw new Error('Abstract method not implemented: get template');
}

/** Метод для удаления элемента */
removeElement() {
this.#element = null;
}

/**
* Метод, реализующий эффект "покачивания головой"
* @param {shakeCallback} [callback] Функция, которая будет вызвана после завершения анимации
*/
shake(callback) {
this.element.classList.add(SHAKE_CLASS_NAME);
setTimeout(() => {
this.element.classList.remove(SHAKE_CLASS_NAME);
callback?.();
}, SHAKE_ANIMATION_TIMEOUT);
}
}

/**
* Функция, которая будет вызвана методом shake после завершения анимации
* @callback shakeCallback
*/
import {
render,
RenderPosition
} from './render.js';
import TripInfoView from './view/create-trip.js';
import FiltersView from './view/create-filter.js';
import PointsPresenter from './presenter/board-presenter.js';

const tripMainContainer = document.querySelector('.trip-main');
const tripEventsContainer = document.querySelector('.trip-events');
const filtersContainer = tripMainContainer.querySelector('.trip-controls__filters');

import PointsModel from './model/event-points-model.js';
import OffersModel from './model/offers-model.js';
import DestinationsModel from './model/destinations-model.js';

const pointsModel = new PointsModel();
const offersModel = new OffersModel();
const destinationsModel = new DestinationsModel();

const pointsPresenter = new PointsPresenter({
tripEventsContainer,
pointsModel,
offersModel,
destinationsModel
});

render(new TripInfoView(), tripMainContainer, RenderPosition.AFTERBEGIN);
render(new FiltersView(), filtersContainer);

pointsPresenter.init();
14 changes: 6 additions & 8 deletions src/model/destinations-model.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
export default class DestinationsModel {
#service = null;
#destinations = null;
import { getDestinations } from '../mock/destinations.js';

constructor(service) {
this.#service = service;
this.#destinations = this.#service.destinations;
export default class DestinationsModel {
constructor() {
this.destinations = getDestinations();
}

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

getById(id) {
return this.#destinations.find((destination) => destination.id === id);
return this.destinations.find((destination) => destination.id === id);
}
}
16 changes: 7 additions & 9 deletions src/model/event-points-model.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
export default class PointsModel {
#service = null;
#points = null;
import { getRandomEventPoint } from '../mock/event-points.js';
import { POINTS_COUNT } from '../const.js';

constructor(service) {
this.#service = service;
this.#points = this.#service.points;
export default class PointsModel {
constructor() {
this.points = Array.from({ length: POINTS_COUNT }, getRandomEventPoint);
}

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

14 changes: 6 additions & 8 deletions src/model/offers-model.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
export default class OffersModel {
#service = null;
#offers = null;
import { getOffers } from '../mock/offers.js';

constructor(service) {
this.#service = service;
this.#offers = this.#service.offers;
export default class OffersModel {
constructor() {
this.offers = getOffers();
}

get() {
return this.#offers;
return this.offers;
}

getByType(type) {
return this.#offers.find((offers) => offers.type === type.toLowerCase()).offers;
return this.offers.find((offers) => offers.type === type.toLowerCase()).offers;
}
}
Loading

0 comments on commit 6047947

Please sign in to comment.