-
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.
нажимаю звездочку - рисует новую кнопку в хэдере
- Loading branch information
1 parent
d77acda
commit 6ef1e91
Showing
8 changed files
with
138 additions
and
21 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
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,15 +1,18 @@ | ||
import Observable from '../framework/observable.js'; | ||
|
||
export default class ClickModel extends Observable { | ||
#currentState = null; | ||
#currentState = { | ||
isCreating: false | ||
}; | ||
|
||
get clickState() { | ||
return this.#currentState; | ||
} | ||
|
||
setclickState(updateType, state) { | ||
this.#currentState = state; | ||
this._notify('clickStateChanged', updateType, state); | ||
setClickState(updateType, state) { | ||
this.#currentState = { | ||
...this.#currentState, | ||
isCreating: state === 'creating' | ||
}; | ||
this._notify('clickStateChanged', updateType, this.#currentState); | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import EditPointView from '../view/edit-point-view.js'; | ||
import { render,remove, RenderPosition } from '../framework/render.js'; | ||
import { UpdateType, UserAction, Mode, generateID } from '../utils/utiles.js'; | ||
|
||
export default class NewPointPresenter { | ||
#pointListContainer = null; | ||
#allOffers = null; | ||
#allDestinations = null; | ||
|
||
#handleDataChange = null; | ||
#handleDestroy = null; | ||
|
||
#pointEditComponent = null; | ||
|
||
constructor({pointListContainer, allOffers, allDestinations, onDataChange, onDestroy}) { | ||
this.#pointListContainer = pointListContainer; | ||
this.#allOffers = allOffers; | ||
this.#allDestinations = allDestinations; | ||
this.#handleDataChange = onDataChange; | ||
this.#handleDestroy = onDestroy; | ||
} | ||
|
||
init() { | ||
|
||
if (this.#pointEditComponent !== null) { | ||
return; | ||
} | ||
|
||
this.#pointEditComponent = new EditPointView({ | ||
allOffers: this.#allOffers, | ||
allDestinations: this.#allDestinations, | ||
onFormSubmit: this.#handleFormSubmit, | ||
onDeleteEditFormButton: this.#handleDeleteEditFormButton, | ||
type: Mode.CREATING | ||
}); | ||
|
||
render(this.#pointEditComponent, this.#pointListContainer, RenderPosition.AFTERBEGIN); | ||
|
||
document.addEventListener('keydown', this.#escKeyDownHandler); | ||
} | ||
|
||
destroy(){ | ||
if(this.#pointEditComponent === null){ | ||
return; | ||
} | ||
|
||
this.#handleDestroy(); | ||
|
||
remove(this.#pointEditComponent); | ||
this.#pointEditComponent = null; | ||
|
||
document.removeEventListener('keydown', this.#escKeyDownHandler); | ||
} | ||
|
||
#handleFormSubmit = (event) => { | ||
this.#handleDataChange( | ||
UserAction.ADD_EVENT, | ||
UpdateType.MINOR, | ||
{id: generateID(), ...event} | ||
); | ||
|
||
this.destroy(); | ||
}; | ||
|
||
#handleDeleteEditFormButton = () => { | ||
this.destroy(); | ||
}; | ||
|
||
#escKeyDownHandler = (evt) => { | ||
if (evt.key === 'Escape' || evt.key === 'Esc') { | ||
evt.preventDefault(); | ||
this.destroy(); | ||
} | ||
}; | ||
} |
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