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

Дополнительная функциональность #14

Merged
merged 5 commits into from
May 27, 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
3 changes: 0 additions & 3 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ <h2 class="visually-hidden">Filter events</h2>
<!-- Фильтры -->
</div>
</div>

<button class="trip-main__event-add-btn btn btn--big btn--yellow" type="button">New event</button>
</div>
</div>
</header>
<main class="page-body__page-main page-main">
Expand Down
53 changes: 15 additions & 38 deletions src/const.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
const DEFAULT_TYPE = 'taxi';

const AUTHORIZATION = 'Basic mofy87osm1d';
const END_POINT = 'https://21.objects.htmlacademy.pro/big-trip';

//пустая точка
const POINT_EMPTY = {
basePrice: 0,
basePrice: 1,
dateFrom: null,
dateTo: null,
destination: null,
Expand All @@ -23,37 +26,6 @@ const POINT_TYPE = [
'Restaurant'
];

const DESTINATION = [
'Ekaterinburg',
'Moscow',
'Tokyo',
'Kawaguchiko',
'Shibuya',
'Harayuki',
'Roppongi',
'Kyoto',
'Gose Palace',
'Kinkaku-ji',
'Hiroshima',
'Miyajima Island',
'Nikko Park'
];

const DESCRIPTION = [
'Nullam nunc ex, convallis sed finibus eget, sollicitudin eget ante.',
'Phasellus eros mauris, condimentum sed nibh vitae, sodales efficitur ipsum.',
'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
'Aliquam erat volutpat.'
];

const OFFERS = [
'Add luggage',
'Switch to comfort class',
'Add meal',
'Choose seats',
'Travel by train',
];

const FilterType = {
EVERYTHING: 'everything',
FUTURE: 'future',
Expand All @@ -66,11 +38,11 @@ const Mode = {
EDITING: 'EDITING',
};

const SortType = [{
const SortType = {
DAY: 'day',
TIME: 'time',
PRICE: 'price'
}];
};

const UserAction = {
UPDATE_POINT: 'UPDATE_POINT',
Expand Down Expand Up @@ -105,16 +77,21 @@ const ButtonLabels = {
SAVE_IN_PROGRESS: 'Saving...'
};

const TimeLimit = {
LOWER_LIMIT: 350,
UPPER_LIMIT: 1000,
};

export {POINT_EMPTY,
AUTHORIZATION,
END_POINT,
POINT_TYPE,
DESTINATION,
DESCRIPTION,
OFFERS,
FilterType,
Mode,
SortType,
UserAction,
EditingType,
UpdateType,
Method,
ButtonLabels};
ButtonLabels,
TimeLimit};
5 changes: 1 addition & 4 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ import FilterModel from './model/filter-model.js';

import PointsApiService from './api-service/points-api-service.js';

const AUTHORIZATION = 'Basic mofy87osm1d';
const END_POINT = 'https://21.objects.htmlacademy.pro/big-trip';
import { AUTHORIZATION, END_POINT } from './const.js';

//const filterHeaderElement = document.querySelector('.trip-controls');
//const siteFilterElement = filterHeaderElement.querySelector('.trip-controls__filters');
const siteMainElement = document.querySelector('.page-main');
const tripInfoElement = document.querySelector('.trip-main');

Expand Down
12 changes: 11 additions & 1 deletion src/presenter/trip-presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import EventListEmptyView from '../view/event-list-empty-view.js';
import SortPointsView from '../view/sort-points-view.js';
import LoadingView from '../view/loading-view.js';

import UiBlocker from '../framework/ui-blocker/ui-blocker.js';
import { remove, render, RenderPosition } from '../framework/render.js';

import PointPresenter from './point-presenter.js';
import NewPointPresenter from './new-point-presenter.js';

import { sortPointsByTime, sortPointsByPrice } from '../utils/points.js';
import { filter } from '../utils/filter.js';
import { SortType, UserAction, UpdateType, FilterType } from '../const.js';
import { SortType, UserAction, UpdateType, FilterType, TimeLimit } from '../const.js';
//import EditPointView from '../view/editing-form-view.js';

export default class TripPresenter {
Expand All @@ -29,6 +30,11 @@ export default class TripPresenter {
#filterType = FilterType.EVERYTHING;
#isLoading = true;

#uiBlocker = new UiBlocker({
lowerLimit: TimeLimit.LOWER_LIMIT,
upperLimit: TimeLimit.UPPER_LIMIT
});

#pointPresenters = new Map();
#newPointPresenter = null;

Expand Down Expand Up @@ -146,6 +152,8 @@ export default class TripPresenter {
};

#handleViewAction = async (actionType, updateType, update) => {
this.#uiBlocker.block();

switch(actionType) {
case UserAction.UPDATE_POINT:
this.#pointPresenters.get(update.id).setSaving();
Expand All @@ -172,6 +180,8 @@ export default class TripPresenter {
}
break;
}

this.#uiBlocker.unblock();
};

#clearBoard = ({resetSortType = false} = {}) => {
Expand Down
94 changes: 0 additions & 94 deletions src/template/additional-new-point-template.js

This file was deleted.

Loading
Loading