Skip to content

Commit

Permalink
Merge pull request #8 from Talurion/module7-task1
Browse files Browse the repository at this point in the history
  • Loading branch information
keksobot authored Oct 18, 2024
2 parents d2cf2ad + 8fd9d6d commit 07f697b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/presenter/board-presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import EventPresenter from './event-presenter.js';
import NoEventsView from '../view/no-events-view.js';
import NewEventPresenter from './new-event-presenter.js';
import { SortType, UpdateType, UserAction, FilterType } from '../const.js';
import { sortEventsPrice, sortEventsTime } from '../utils/event.js';
import { sortEventsPrice, sortEventsTime, sortEventsDate } from '../utils/event.js';
import { filter } from '../utils/filter.js';


Expand Down Expand Up @@ -61,7 +61,7 @@ export default class BoardPresenter {
case SortType.TIME:
return filteredEvents.sort(sortEventsTime);
}
return filteredEvents;
return filteredEvents.sort(sortEventsDate);
}

init () {
Expand Down
5 changes: 4 additions & 1 deletion src/utils/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@ const sortEventsTime = (eventA, eventB) => {
return durationB - durationA;
};

const sortEventsDate = (eventA, eventB) => new Date(eventA.dateFrom) - new Date(eventB.dateFrom);

export {
humanizeDueDate,
isEventFuture,
isEventPresent,
isEventPast,
isDatesEqual,
sortEventsPrice,
sortEventsTime
sortEventsTime,
sortEventsDate
};
5 changes: 3 additions & 2 deletions src/view/new-event-edit-element-view.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import he from 'he';
import AbstractStatefulView from '../framework/view/abstract-stateful-view';
import { EVENTS_TYPES } from '../const';
import flatpickr from 'flatpickr';
Expand Down Expand Up @@ -111,7 +112,7 @@ const createNewEventEditElementTemplate = (eventData, destinationsList, isDefaul
<label class="event__label event__type-output" for="event-destination-1">
${type}
</label>
<input class="event__input event__input--destination" id="${destination.id === undefined ? '' : destination.id}" type="text" name="event-destination" value="${destination.name === undefined ? '' : destination.name}" list="destination-list-1">
<input class="event__input event__input--destination" id="${destination.id === undefined ? '' : destination.id}" type="text" name="event-destination" value="${destination.name === undefined ? '' : he.encode(destination.name)}" list="destination-list-1">
<datalist id="destination-list-1">
${createDestinations(destinationsList)}
</datalist>
Expand All @@ -130,7 +131,7 @@ const createNewEventEditElementTemplate = (eventData, destinationsList, isDefaul
<span class="visually-hidden">Price</span>
&euro;
</label>
<input class="event__input event__input--price" id="event-price-1" type="text" name="event-price" value="${basePrice}">
<input class="event__input event__input--price" id="event-price-1" type="number" name="event-price" value="${basePrice}">
</div>
<button class="event__save-btn btn btn--blue" type="submit">Save</button>
Expand Down
3 changes: 2 additions & 1 deletion src/view/new-events-item-view.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import he from 'he';
import dayjs from 'dayjs';
import AbstractView from '../framework/view/abstract-view';
import { humanizeDueDate } from '../utils/event';
Expand Down Expand Up @@ -57,7 +58,7 @@ const createNewTripEventsItemTemplate = (eventData) => {
<div class="event__type">
<img class="event__type-icon" width="42" height="42" src="img/icons/${type}.png" alt="Event type icon">
</div>
<h3 class="event__title">${type} ${destination.name}</h3>
<h3 class="event__title">${type} ${he.encode(destination.name)}</h3>
<div class="event__schedule">
<p class="event__time">
<time class="event__start-time" datetime="${dateFrom}">${humanizedStartTime}</time>
Expand Down
6 changes: 3 additions & 3 deletions src/view/no-events-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { FilterType } from '../const.js';

const NoTasksTextType = {
[FilterType.EVERYTHING]: 'Click New Event to create your first point',
[FilterType.FUTURE]: 'There are no future events',
[FilterType.PRESENT]: 'There are no present events',
[FilterType.PAST]: 'There are no past events',
[FilterType.FUTURE]: 'There are no future events now',
[FilterType.PRESENT]: 'There are no present events now',
[FilterType.PAST]: 'There are no past events now',
};

const createNoEventsViewTemplate = (filterType) => {
Expand Down

0 comments on commit 07f697b

Please sign in to comment.