-
Notifications
You must be signed in to change notification settings - Fork 0
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 #18 from frontend-park-mail-ru/feature-cv-page
Релиз приложения к рк2
- Loading branch information
Showing
121 changed files
with
2,931 additions
and
388 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
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
1 change: 0 additions & 1 deletion
1
src/Components/ApplicantRegistrationForm/applicant-registration-form.hbs
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,21 @@ | ||
import { Component } from '../../modules/Components/Component.js'; | ||
import { AppliersListModel } from './AppliersListModel.js'; | ||
import { AppliersListController } from './AppliersListController.js'; | ||
import { AppliersListView } from './AppliersListView.js'; | ||
import { ListMixin } from '../Lists/List/ListMixin.js'; | ||
|
||
export class AppliersList extends Component { | ||
constructor({ vacancyId, elementClass, existingElement }) { | ||
super({ | ||
modelClass: AppliersListModel, | ||
controllerClass: AppliersListController, | ||
viewClass: AppliersListView, | ||
viewParams: { elementClass }, | ||
modelParams: { vacancyId }, | ||
existingElement, | ||
}); | ||
this._controller.fillList(); | ||
} | ||
} | ||
|
||
Object.assign(AppliersList.prototype, ListMixin); |
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,12 @@ | ||
import { ComponentController } from '../../modules/Components/Component.js'; | ||
|
||
export class AppliersListController extends ComponentController { | ||
constructor(model, view, component) { | ||
super(model, view, component); | ||
} | ||
|
||
async fillList() { | ||
const appliers = await this._model.getItems(); | ||
appliers.forEach((applier) => this._view.addListItem(applier)); | ||
} | ||
} |
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 @@ | ||
import { ComponentModel } from '../../modules/Components/Component.js'; | ||
import { Api } from '../../modules/Api/Api.js'; | ||
import { Applicant } from '../../modules/models/Applicant.js'; | ||
import { catchStandardResponseError } from '../../modules/Api/Errors.js'; | ||
|
||
export class AppliersListModel extends ComponentModel { | ||
#vacancyId; | ||
constructor({ vacancyId }) { | ||
super(); | ||
this.#vacancyId = vacancyId; | ||
} | ||
|
||
async getItems() { | ||
try { | ||
const peopleJson = (await Api.getAppliersByVacancyId({ id: this.#vacancyId })).subscribers; | ||
const applicantObjects = peopleJson.reduce((applicantObjects, applicantJsonItem) => { | ||
try { | ||
const applicant = new Applicant(applicantJsonItem); | ||
applicant.name = `${applicant.firstName} ${applicant.secondName}`; | ||
applicantObjects.push(applicant); | ||
return applicantObjects; | ||
} catch { | ||
return applicantObjects; | ||
} | ||
}, []); | ||
return applicantObjects; | ||
} catch (err) { | ||
catchStandardResponseError(err); | ||
} | ||
} | ||
} |
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,34 @@ | ||
import { ComponentView } from '../../modules/Components/Component.js'; | ||
import { resolveUrl } from '../../modules/UrlUtils/UrlUtils.js'; | ||
import USER_TYPE from '../../modules/UserSession/UserType.js'; | ||
|
||
export class AppliersListView extends ComponentView { | ||
#listItems; | ||
#isEmpty; | ||
constructor(renderParams, existingElement) { | ||
super({ | ||
renderParams, | ||
existingElement, | ||
templateName: 'appliers-list.hbs', | ||
}); | ||
this.list = this._html.querySelector('.appliers-list__list'); | ||
this.#listItems = []; | ||
this.#isEmpty = true; | ||
this.list.innerText = 'Пока никто не откликнулся'; | ||
} | ||
|
||
addListItem({ id, name }) { | ||
if (this.#isEmpty) { | ||
this.#isEmpty = false; | ||
this.list.innerHTML = ''; | ||
} | ||
const listItem = document.createElement('li'); | ||
const anchorElement = document.createElement('a'); | ||
anchorElement.href = `${resolveUrl('profile')}?id=${id}&userType=${USER_TYPE.APPLICANT}`; | ||
anchorElement.innerText = name; | ||
anchorElement.classList.add('appliers-list__list-item'); | ||
listItem.appendChild(anchorElement); | ||
this.list.appendChild(listItem); | ||
this.#listItems.push(listItem); | ||
} | ||
} |
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,6 @@ | ||
<div class="{{elementClass}} appliers-list"> | ||
<h1 class="appliers-list__header">Откликнулись</h1> | ||
<div class="appliers-list__divider"></div> | ||
<ol class="appliers-list__list"> | ||
</ol> | ||
</div> |
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
18 changes: 18 additions & 0 deletions
18
src/Components/CvArticle/ButtonContainer/ButtonContainer.js
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,18 @@ | ||
import { | ||
Component, | ||
ComponentController, | ||
ComponentModel, | ||
} from '../../../modules/Components/Component.js'; | ||
import { ButtonContainerView } from './ButtonContainerView.js'; | ||
|
||
export class ButtonContainer extends Component { | ||
constructor({ isOwner, isEmployer, ownerId, cvId, existingElement }) { | ||
super({ | ||
modelClass: ComponentModel, | ||
viewClass: ButtonContainerView, | ||
controllerClass: ComponentController, | ||
viewParams: { isOwner, isEmployer, ownerId, cvId }, | ||
existingElement, | ||
}); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/Components/CvArticle/ButtonContainer/ButtonContainerView.js
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,41 @@ | ||
import { CV_DELETE, CV_EDIT } from '../../../modules/Events/Events.js'; | ||
import { addEventListeners } from '../../../modules/Events/EventUtils.js'; | ||
import { ComponentView } from '/src/modules/Components/Component.js'; | ||
import eventBus from '/src/modules/Events/EventBus.js'; | ||
|
||
export class ButtonContainerView extends ComponentView { | ||
#editButton; | ||
#deleteButton; | ||
#cvId; | ||
constructor({ isOwner, isEmployer, ownerId, cvId }, existingElement) { | ||
super({ | ||
renderParams: { isOwner, isEmployer, ownerId }, | ||
existingElement, | ||
templateName: 'cv-article__button-container.hbs', | ||
}); | ||
this.#cvId = cvId; | ||
if (isOwner) { | ||
this.#editButton = this._html.querySelector('.cv-article__edit-button'); | ||
this.#deleteButton = this._html.querySelector('.cv-article__delete-button'); | ||
this._eventListeners.push( | ||
{ | ||
event: 'click', | ||
object: this.#editButton, | ||
listener: function (ev) { | ||
ev.preventDefault(); | ||
eventBus.emit(CV_EDIT, { vacancyId: this.#cvId }); | ||
}.bind(this), | ||
}, | ||
{ | ||
event: 'click', | ||
object: this.#deleteButton, | ||
listener: function (ev) { | ||
ev.preventDefault(); | ||
eventBus.emit(CV_DELETE, { vacancyId: this.#cvId }); | ||
}.bind(this), | ||
}, | ||
); | ||
} | ||
addEventListeners(this._eventListeners); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/Components/CvArticle/ButtonContainer/cv-article__button-container.hbs
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,12 @@ | ||
<div class="cv-article__button-container"> | ||
{{#if isEmployer}} | ||
<a class="cv-article__another-button button button_main-secondary" href="{{url "profile" ""}}?id={{ownerId}}&userType=applicant&from=cvList">Все резюме</a> | ||
{{else}} | ||
{{#if isOwner}} | ||
<button type="button" class="cv-article__edit-button button button_main-primary">Изменить</button> | ||
<button type="button" class="cv-article__delete-button button button_danger-secondary { | ||
">Удалить</button> | ||
{{/if}} | ||
{{/if}} | ||
<div class='cv-article__created-at'></div> | ||
</div> |
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,38 @@ | ||
import { Component } from '../../modules/Components/Component.js'; | ||
import { CvArticleController } from './CvArticleController.js'; | ||
import { CvArticleModel } from './CvArticleModel.js'; | ||
import { CvArticleView } from './CvArticleView.js'; | ||
import { ButtonContainer } from './ButtonContainer/ButtonContainer.js'; | ||
import USER_TYPE from '../../modules/UserSession/UserType.js'; | ||
|
||
export class CvArticle extends Component { | ||
constructor({ elementClass, cvId, userId, userType }) { | ||
super({ | ||
modelClass: CvArticleModel, | ||
modelParams: { cvId }, | ||
viewClass: CvArticleView, | ||
controllerClass: CvArticleController, | ||
viewParams: { elementClass }, | ||
}); | ||
this._userId = userId; | ||
this._userType = userType; | ||
this._cvId = cvId; | ||
} | ||
|
||
async makeButtons() { | ||
const modelData = await this._controller.fetchData(); | ||
this._buttonContainer = new ButtonContainer({ | ||
isOwner: modelData.applicantId === this._userId && this._userType === USER_TYPE.APPLICANT, | ||
isEmployer: this._userType === USER_TYPE.EMPLOYER, | ||
ownerId: modelData.applicantId, | ||
cvId: this._cvId, | ||
}); | ||
this._children.push(this._buttonContainer); | ||
this._controller.addButtonContainer(this._buttonContainer); | ||
this._controller.renderData(); | ||
} | ||
|
||
async getApplicantId() { | ||
return this._model.getApplicantId(); | ||
} | ||
} |
Oops, something went wrong.