-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LDBR-4.4: Работа с командой в
/boards
(#44)
* LDBR-3.8: Добавить поддержку типа команды в шаблоне * LDBR-3.23: Добавить actions на команды * LDBR-4.4: Добавить всплывающие окна и экшоны для команды и удаления * LDBR-4.4: Callback'и на boards, шаблон для тим * LDBR-4.4: Добавить Callback'и методы в сторе * LDBR-4.4: Добавить реализацию методов CUD и сетевых запросов * LDBR-4.4: Внести правки в работу с тимами * LDBR-4.4: invited_members Co-authored-by: DPeshkoff <[email protected]>
- Loading branch information
Showing
15 changed files
with
803 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
'use strict'; | ||
|
||
// Modules | ||
import Dispatcher from '../modules/Dispatcher/Dispatcher.js'; | ||
|
||
/** | ||
* Константа, содержащая в себе типы действий для списка досок. | ||
*/ | ||
export const TeamsActionTypes = { | ||
POPUP_TEAM_HIDE: 'teams/popup/hide', | ||
POPUP_CREATE_TEAM_SHOW: 'teams/popup/create/show', | ||
POPUP_CREATE_TEAM_SUBMIT: 'teams/popup/create/submit', | ||
POPUP_EDIT_TEAM_SHOW: 'teams/popup/edit/show', | ||
POPUP_EDIT_TEAM_SUBMIT: 'teams/popup/edit/submit', | ||
|
||
POPUP_DELETE_TEAM_CHOOSE: 'teams/delete/choose', | ||
POPUP_DELETE_TEAM_SHOW: 'teams/delete/show', | ||
POPUP_DELETE_TEAM_CLOSE: 'teams/delete/close', | ||
}; | ||
|
||
/** | ||
* Класс, содержащий в себе действия, связанные с управлением командами. | ||
*/ | ||
export const teamsActions = { | ||
|
||
/** | ||
* Отобразить popup создания команды | ||
*/ | ||
showAddTeamPopUp() { | ||
Dispatcher.dispatch({ | ||
actionName: TeamsActionTypes.POPUP_CREATE_TEAM_SHOW, | ||
}); | ||
}, | ||
|
||
/** | ||
* Отобразить popup редактирования команды | ||
* @param {Number} tid id команды | ||
*/ | ||
showEditTeamPopUp(tid) { | ||
Dispatcher.dispatch({ | ||
actionName: TeamsActionTypes.POPUP_EDIT_TEAM_SHOW, | ||
data: {tid}, | ||
}); | ||
}, | ||
|
||
/** | ||
* Скрыть popup команды | ||
*/ | ||
hideTeamPopUp() { | ||
Dispatcher.dispatch({ | ||
actionName: TeamsActionTypes.POPUP_TEAM_HIDE, | ||
}); | ||
}, | ||
|
||
/** | ||
* Создать команду | ||
* @param {String} teamName - название команды | ||
*/ | ||
submitAddTeamPopUp(teamName) { | ||
Dispatcher.dispatch({ | ||
actionName: TeamsActionTypes.POPUP_CREATE_TEAM_SUBMIT, | ||
data: { | ||
team_name: teamName, | ||
}, | ||
}); | ||
}, | ||
|
||
/** | ||
* Переименовать команду | ||
* @param {String} teamName - новое название команды | ||
*/ | ||
submitEditTeamPopUp(teamName) { | ||
Dispatcher.dispatch({ | ||
actionName: TeamsActionTypes.POPUP_EDIT_TEAM_SUBMIT, | ||
data: { | ||
team_name: teamName, | ||
}, | ||
}); | ||
}, | ||
|
||
/** | ||
* Отобразить popup удаления команды | ||
* @param {Number} tid id команды | ||
*/ | ||
showDeleteTeamPopUp(tid) { | ||
Dispatcher.dispatch({ | ||
actionName: TeamsActionTypes.POPUP_DELETE_TEAM_SHOW, | ||
data: {tid}, | ||
}); | ||
}, | ||
|
||
/** | ||
* Скрыть pop удаления команды с выбором "удалять" или "не удалять" | ||
* @param {Boolean} confirm подтверждено ли удаление | ||
*/ | ||
deleteTeam(confirm) { | ||
Dispatcher.dispatch({ | ||
actionName: TeamsActionTypes.POPUP_DELETE_TEAM_CHOOSE, | ||
data: {confirm}, | ||
}); | ||
}, | ||
|
||
/** | ||
* Скрыть pop удаления команды | ||
*/ | ||
hideDeleteTeamPopUp() { | ||
Dispatcher.dispatch({ | ||
actionName: TeamsActionTypes.POPUP_DELETE_TEAM_CLOSE, | ||
}); | ||
}, | ||
}; |
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
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,31 @@ | ||
{{#with team-popup}} | ||
{{# if visible }} | ||
<div class="popup-wrapper" id="createTeamPopUpWrapperId"> | ||
<div class="popup-content popup-content_create-board"> | ||
<form class="popup-form"> | ||
<div class="popup-form__header"> | ||
Создать команду | ||
</div> | ||
<div class="horizontal-line"></div> | ||
<div class="popup-form__elements-wrapper"> | ||
<div> | ||
<label for="team-name" class>Название команды:</label> | ||
<input class="simple-form-element" type="text" id="createTeamPopUpNameId" name="team-name" autofocus | ||
pattern="^[a-zA-Z\d]{1,40}$" autocomplete="off" | ||
{{#if edit}} value="{{team_name}}" {{/if}} required> | ||
</div> | ||
{{#if errors}} | ||
<div class="error">{{errors}}</div> | ||
{{/if}} | ||
{{# if edit }} | ||
<button class="button" id="editTeamPopUpSubmitId">Сохранить</button> | ||
{{ else }} | ||
<button class="button" id="createTeamPopUpSubmitId">Создать</button> | ||
{{/if}} | ||
</div> | ||
</form> | ||
<div class="close-button" id="createTeamPopUpCloseId"></div> | ||
</div> | ||
</div> | ||
{{/if}} | ||
{{/with}} |
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,105 @@ | ||
// BaseComponent | ||
import BaseComponent from '../../components/BaseComponent.js'; | ||
|
||
// Шаблон | ||
import template from './CreateTeamPopUp.hbs'; | ||
|
||
// Actions | ||
import {teamsActions} from '../../actions/teams.js'; | ||
|
||
/** | ||
* Класс popup окна создания команды | ||
*/ | ||
export default class CreateTeamPopUp extends BaseComponent { | ||
/** | ||
* Конструирует объект CreateTeamPopUp | ||
*/ | ||
constructor() { | ||
super(null, template); | ||
this._bindCallBacks(); | ||
this._elements = {}; | ||
} | ||
|
||
/** | ||
* Метод сохраняет ссылки на элементы popup'a | ||
* @private | ||
*/ | ||
_registerPopUpElements() { | ||
this._elements = { | ||
closeBtn: document.getElementById('createTeamPopUpCloseId'), | ||
wrapper: document.getElementById('createTeamPopUpWrapperId'), | ||
name: document.getElementById('createTeamPopUpNameId'), | ||
createBtn: document.getElementById('createTeamPopUpSubmitId'), | ||
saveBtn: document.getElementById('editTeamPopUpSubmitId'), | ||
|
||
}; | ||
} | ||
|
||
/** | ||
* Метод регестрирует callback | ||
* @private | ||
*/ | ||
addEventListeners() { | ||
this._registerPopUpElements(); | ||
super.addEventListeners(); | ||
this._elements.wrapper?.addEventListener('click', this._onPopUpClose); | ||
this._elements.closeBtn?.addEventListener('click', this._onPopUpClose); | ||
this._elements.createBtn?.addEventListener('click', this._onCreateBtnClick); | ||
this._elements.saveBtn?.addEventListener('click', this._onSaveBtnClick); | ||
this._elements.name?.focus(); | ||
}; | ||
|
||
/** | ||
* Метод удаляет все ранее зарегестрированные callback | ||
* @private | ||
*/ | ||
removeEventListeners() { | ||
super.removeEventListeners(); | ||
this._elements.wrapper?.removeEventListener('click', this._onPopUpClose); | ||
this._elements.closeBtn?.removeEventListener('click', this._onPopUpClose); | ||
this._elements.createBtn?.removeEventListener('click', this._onCreateBtnClick); | ||
this._elements.saveBtn?.removeEventListener('click', this._onSaveBtnClick); | ||
} | ||
|
||
/** | ||
* Метод биндит this контекст к callback методам | ||
* @private | ||
*/ | ||
_bindCallBacks() { | ||
this._onPopUpClose = this._onPopUpClose.bind(this); | ||
this._onSaveBtnClick = this._onSaveBtnClick.bind(this); | ||
this._onCreateBtnClick = this._onCreateBtnClick.bind(this); | ||
} | ||
|
||
/** | ||
* Скрывает модальное окно создания команды | ||
* @param {Event} event объект события | ||
* @private | ||
*/ | ||
_onPopUpClose(event) { | ||
if (event.target === this._elements.closeBtn || | ||
event.target === this._elements.wrapper) { | ||
teamsActions.hideTeamPopUp(); | ||
} | ||
} | ||
|
||
/** | ||
* Обработчик события отправки формы сохранения названия команды | ||
* @param {Object} event объект события | ||
* @private | ||
*/ | ||
_onSaveBtnClick(event) { | ||
event.preventDefault(); | ||
teamsActions.submitEditTeamPopUp(this._elements.name.value); | ||
} | ||
|
||
/** | ||
* Обработчик события отправки формы создания команды | ||
* @param {Object} event объект события | ||
* @private | ||
*/ | ||
_onCreateBtnClick(event) { | ||
event.preventDefault(); | ||
teamsActions.submitAddTeamPopUp(this._elements.name.value); | ||
} | ||
} |
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,24 @@ | ||
{{#with delete-dialog}} | ||
{{# if visible }} | ||
<div class="popup-wrapper" id="deletePopUpWrapperId"> | ||
<div class="popup-content popup-content_delete"> | ||
<form class="popup-form"> | ||
<div class="popup-form__header"> | ||
Удалить "{{name}}"? | ||
</div> | ||
<div class="horizontal-line"></div> | ||
{{#if errors}} | ||
<div class="error"> {{errors}}</div> | ||
{{/if}} | ||
<div class="popup-form__elements-wrapper"> | ||
<div class="confirm-delete-wrapper"> | ||
<button class="button button_red button_full-space button_no-overflow-hiding" id="deletePopUpConfirmBtnId">Да, удалить</button> | ||
<button class="button button_full-space button_no-overflow-hiding" id="deletePopUpRejectBtnId">Нет, отменить</button> | ||
</div> | ||
</div> | ||
</form> | ||
<div class="close-button" id="deletePopUpCloseId"></div> | ||
</div> | ||
</div> | ||
{{/if}} | ||
{{/with}} |
Oops, something went wrong.