-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from vvvyat/module4-task2
- Loading branch information
Showing
10 changed files
with
101 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
import FilterView from './view/filter-view.js'; | ||
import SortView from './view/sort-view.js'; | ||
import ListPresenter from './presenter/list-presenter.js'; | ||
import PointsModel from './model/points-model.js'; | ||
import {render} from './framework/render.js'; | ||
|
||
const filterContainer = document.querySelector('.trip-controls__filters'); | ||
const pointsContainer = document.querySelector('.trip-events'); | ||
const pointsListContainer = document.querySelector('.trip-events'); | ||
|
||
const pointsModel = new PointsModel(); | ||
const listPresenter = new ListPresenter({ | ||
container: pointsContainer, | ||
container: pointsListContainer, | ||
pointsModel | ||
}); | ||
|
||
render(new FilterView(), filterContainer); | ||
render(new SortView(), pointsContainer); | ||
listPresenter.init(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,27 @@ | ||
import AbstractView from '../framework/view/abstract-view.js'; | ||
import {FILTERS, DEFAULT_FILTER} from '../const.js'; | ||
|
||
function createFilterTemplate() { | ||
function createFilterTemplate(filterName, count) { | ||
const filter = filterName.toLowerCase(); | ||
const isChecked = filterName === DEFAULT_FILTER ? 'checked' : ''; | ||
const isDisabled = count === 0 ? 'disabled' : ''; | ||
return ` | ||
<form class="trip-filters" action="#" method="get"> | ||
<div class="trip-filters__filter"> | ||
<input id="filter-everything" class="trip-filters__filter-input visually-hidden" type="radio" name="trip-filter" value="everything"> | ||
<label class="trip-filters__filter-label" for="filter-everything">Everything</label> | ||
</div> | ||
<div class="trip-filters__filter"> | ||
<input id="filter-future" class="trip-filters__filter-input visually-hidden" type="radio" name="trip-filter" value="future"> | ||
<label class="trip-filters__filter-label" for="filter-future">Future</label> | ||
</div> | ||
<div class="trip-filters__filter"> | ||
<input id="filter-present" class="trip-filters__filter-input visually-hidden" type="radio" name="trip-filter" value="present"> | ||
<label class="trip-filters__filter-label" for="filter-present">Present</label> | ||
</div> | ||
<div class="trip-filters__filter"> | ||
<input id="filter-past" class="trip-filters__filter-input visually-hidden" type="radio" name="trip-filter" value="past" checked> | ||
<label class="trip-filters__filter-label" for="filter-past">Past</label> | ||
</div> | ||
<button class="visually-hidden" type="submit">Accept filter</button> | ||
</form> | ||
<div class="trip-filters__filter"> | ||
<input id="filter-${filter}" class="trip-filters__filter-input visually-hidden" type="radio" name="trip-filter" value="${filter}" ${isChecked} ${isDisabled}> | ||
<label class="trip-filters__filter-label" for="filter-${filter}">${filterName}</label> | ||
</div> | ||
`; | ||
} | ||
|
||
export default class FilterView extends AbstractView { | ||
get template() { | ||
return createFilterTemplate(); | ||
const filtersTemplate = Object.entries(FILTERS).map(([filter, count]) => createFilterTemplate(filter, count)).join(''); | ||
|
||
return ` | ||
<form class="trip-filters" action="#" method="get"> | ||
${filtersTemplate} | ||
<button class="visually-hidden" type="submit">Accept filter</button> | ||
</form> | ||
`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import AbstractView from '../framework/view/abstract-view.js'; | ||
|
||
function createNoPointsTemplate() { | ||
return '<p class="trip-events__msg">Click New Event to create your first point</p>'; | ||
} | ||
|
||
export default class NoPointsView extends AbstractView { | ||
get template() { | ||
return createNoPointsTemplate(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters