-
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.
- Loading branch information
Showing
37 changed files
with
737 additions
and
9 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,72 @@ | ||
import { Component } from '../../modules/Components/Component.js'; | ||
import { EmployerProfileFormView } from './EmployerProfileFormView.js'; | ||
import { EmployerProfileFormModel } from './EmployerProfileFormModel.js'; | ||
import { EmployerProfileFormController } from './EmployerProfileFormController.js'; | ||
import { LiteralInput } from '/src/Components/FormInputs/LiteralInput/LiteralInput.js'; | ||
import { CityInput } from '/src/Components/FormInputs/CityInput/CityInput.js'; | ||
import { ValidatedTextArea } from '../FormInputs/ValidatedTextArea/ValidatedTextArea.js'; | ||
|
||
export class EmployerProfileForm extends Component { | ||
constructor({ userId, elementClass, existingElement }) { | ||
super({ | ||
modelClass: EmployerProfileFormModel, | ||
viewClass: EmployerProfileFormView, | ||
controllerClass: EmployerProfileFormController, | ||
modelParams: { userId }, | ||
existingElement, | ||
viewParams: { elementClass }, | ||
}); | ||
this._firstNameField = new LiteralInput({ | ||
existingElement: this._view.firstNameField, | ||
selfValidate: true, | ||
}); | ||
this._secondNameField = new LiteralInput({ | ||
existingElement: this._view.secondNameField, | ||
selfValidate: true, | ||
}); | ||
this._cityField = new CityInput({ | ||
existingElement: this._view.cityField, | ||
selfValidate: true, | ||
}); | ||
this._contactsField = new ValidatedTextArea({ | ||
existingElement: this._view.contactsField, | ||
selfValidate: true, | ||
}); | ||
this._children.push( | ||
this._firstNameField, | ||
this._secondNameField, | ||
this._cityField, | ||
this._contactsField, | ||
); | ||
|
||
this.reset(); | ||
} | ||
|
||
get view() { | ||
return this._view; | ||
} | ||
|
||
enable() { | ||
[this._firstNameField, this._secondNameField, this._cityField, this._contactsField].forEach( | ||
(field) => { | ||
field.controller.enable(); | ||
}, | ||
); | ||
} | ||
|
||
disable() { | ||
[this._firstNameField, this._secondNameField, this._cityField, this._contactsField].forEach( | ||
(field) => { | ||
field.controller.disable(); | ||
}, | ||
); | ||
} | ||
|
||
reset() { | ||
return this._controller.reset(); | ||
} | ||
|
||
submit() { | ||
return this._controller.submit(); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/Components/EmployerCompanyForm/EmployerProfileFormController.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,43 @@ | ||
import { ComponentController } from '../../modules/Components/Component.js'; | ||
import eventBus from '../../modules/Events/EventBus.js'; | ||
import { USER_UPDATED } from '../../modules/Events/Events.js'; | ||
|
||
export class EmployerProfileFormController extends ComponentController { | ||
constructor(model, view, controller) { | ||
super(model, view, controller); | ||
} | ||
|
||
_validate() { | ||
return [ | ||
this._component._firstNameField.controller.validateInput({ | ||
callerView: this._component._firstNameField._view, | ||
}), | ||
|
||
this._component._secondNameField.controller.validateInput({ | ||
callerView: this._component._secondNameField._view, | ||
}), | ||
|
||
this._component._cityField.controller.validateInput({ | ||
callerView: this._component._cityField._view, | ||
}), | ||
|
||
this._component._contactsField.controller.validateInput({ | ||
callerView: this._component._contactsField._view, | ||
}), | ||
].every((val) => val); | ||
} | ||
|
||
submit() { | ||
if (!this._validate() || !this._model.submit(this._view.getData())) { | ||
return false; | ||
} | ||
eventBus.emit(USER_UPDATED); | ||
return true; | ||
} | ||
|
||
async reset() { | ||
const oldData = await this._model.lastValidData; | ||
this._view.renderData(oldData); | ||
return true; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/Components/EmployerCompanyForm/EmployerProfileFormModel.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,23 @@ | ||
import { Api } from '../../modules/Api/Api.js'; | ||
import { ComponentModel } from '../../modules/Components/Component.js'; | ||
|
||
export class EmployerProfileFormModel extends ComponentModel { | ||
#lastValidData; | ||
|
||
constructor({ userId }) { | ||
super(); | ||
this.#lastValidData = Api.getApplicantById({ id: userId }); | ||
} | ||
|
||
get lastValidData() { | ||
return this.#lastValidData; | ||
} | ||
|
||
async submit(formData) { | ||
if (Api.updateEmployerProfile(formData)) { | ||
this.#lastValidData = formData; | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/Components/EmployerCompanyForm/EmployerProfileFormView.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,31 @@ | ||
import { ComponentView } from '../../modules/Components/Component.js'; | ||
import { getFormData } from '../../modules/FormUtils/FormUtils.js'; | ||
|
||
export class EmployerProfileFormView extends ComponentView { | ||
constructor({ elementClass }, existingElement) { | ||
super({ | ||
renderParams: { elementClass }, | ||
existingElement, | ||
templateName: 'employer-profile-form.hbs', | ||
}); | ||
this.firstNameField = this._html.querySelector('.employer-profile-form__first-name'); | ||
this.secondNameField = this._html.querySelector('.employer-profile-form__second-name'); | ||
this.cityField = this._html.querySelector('.employer-profile-form__city'); | ||
this.contactsField = this._html.querySelector('.employer-profile-form__contacts'); | ||
} | ||
|
||
getData() { | ||
return getFormData(this._html); | ||
} | ||
|
||
getId() { | ||
return 'employer-profile-form'; | ||
} | ||
|
||
renderData({ firstName, secondName, city, contacts }) { | ||
this.firstNameField.querySelector('.validated-input__input').value = firstName; | ||
this.secondNameField.querySelector('.validated-input__input').value = secondName; | ||
this.cityField.querySelector('.validated-input__input').value = city; | ||
this.contactsField.querySelector('.validated-textarea__textarea').value = contacts; | ||
} | ||
} |
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,5 @@ | ||
<form class="{{elementClass}} employer-company-form" id="employer-company-form" method="POST" novalidate> | ||
{{> validated-input formName="employer-company-form" elementName="first-name" inputName="firstName" inputCaption="Имя" inputType="text"}} | ||
{{> validated-input formName="employer-company-form" elementName="city" inputName="city" inputCaption="Город" inputType="text"}} | ||
{{> validated-textarea formName="employer-company-form" elementName="contacts" inputName="contacts" inputCaption="Контакты"}} | ||
</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
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 { ApplicantCvListModel } from './ApplicantCvListModel.js'; | ||
import { ApplicantCvListController } from './ApplicantCvListController.js'; | ||
import { ApplicantCvListView } from './ApplicantCvListView.js'; | ||
import { ListMixin } from '../List/ListMixin.js'; | ||
|
||
export class ApplicantCvList extends Component { | ||
constructor({ userId, isListOwner, elementClass, existingElement }) { | ||
super({ | ||
modelClass: ApplicantCvListModel, | ||
controllerClass: ApplicantCvListController, | ||
viewClass: ApplicantCvListView, | ||
viewParams: { elementClass }, | ||
modelParams: { userId, isListOwner }, | ||
existingElement, | ||
}); | ||
this._controller.loadList(); | ||
} | ||
} | ||
|
||
Object.assign(ApplicantCvList.prototype, ListMixin); |
3 changes: 3 additions & 0 deletions
3
src/Components/Lists/ApplicantCvList/ApplicantCvListController.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,3 @@ | ||
import { ListController } from '../List/ListController.js'; | ||
|
||
export const ApplicantCvListController = ListController; |
33 changes: 33 additions & 0 deletions
33
src/Components/Lists/ApplicantCvList/ApplicantCvListModel.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,33 @@ | ||
import { ComponentModel } from '../../../modules/Components/Component.js'; | ||
import { Api } from '../../../modules/Api/Api.js'; | ||
import { Minicard } from '../../Minicard/Minicard.js'; | ||
import { resolveUrl } from '../../../modules/UrlUtils/UrlUtils.js'; | ||
|
||
export class ApplicantCvListModel extends ComponentModel { | ||
#userId; | ||
#isOwner; | ||
constructor({ userId, isListOwner }) { | ||
super(); | ||
this.#userId = userId; | ||
this.#isOwner = isListOwner; | ||
} | ||
|
||
getItems() { | ||
const cvsJson = Api.getApplicantCvs({ id: this.#userId }); | ||
const cvsObjects = cvsJson.reduce((cvsObjects, cvJsonItem) => { | ||
const { id, positionRus } = cvJsonItem; | ||
cvsObjects.push( | ||
new Minicard({ | ||
renderParams: { | ||
elementClass: 'applicant-cv-list__minicard', | ||
title: positionRus, | ||
isCardOwner: this.#isOwner, | ||
editButtonUrl: resolveUrl(`/cv/edit/${id}`), | ||
}, | ||
}), | ||
); | ||
return cvsObjects; | ||
}, []); | ||
return cvsObjects; | ||
} | ||
} |
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,3 @@ | ||
import { ListView } from '../List/ListView.js'; | ||
|
||
export const ApplicantCvListView = ListView; |
21 changes: 21 additions & 0 deletions
21
src/Components/Lists/ApplicantPortfolioList/ApplicantPortfolioList.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,21 @@ | ||
import { Component } from '../../../modules/Components/Component.js'; | ||
import { ApplicantPortfolioListModel } from './ApplicantPortfolioListModel.js'; | ||
import { ApplicantPortfolioListController } from './ApplicantPortfolioListController.js'; | ||
import { ApplicantPortfolioListView } from './ApplicantPortfolioListView.js'; | ||
import { ListMixin } from '../List/ListMixin.js'; | ||
|
||
export class ApplicantPortfolioList extends Component { | ||
constructor({ userId, isListOwner, elementClass, existingElement }) { | ||
super({ | ||
modelClass: ApplicantPortfolioListModel, | ||
controllerClass: ApplicantPortfolioListController, | ||
viewClass: ApplicantPortfolioListView, | ||
viewParams: { elementClass }, | ||
modelParams: { userId, isListOwner }, | ||
existingElement, | ||
}); | ||
this._controller.loadList(); | ||
} | ||
} | ||
|
||
Object.assign(ApplicantPortfolioList.prototype, ListMixin); |
3 changes: 3 additions & 0 deletions
3
src/Components/Lists/ApplicantPortfolioList/ApplicantPortfolioListController.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,3 @@ | ||
import { ListController } from '../List/ListController.js'; | ||
|
||
export const ApplicantPortfolioListController = ListController; |
33 changes: 33 additions & 0 deletions
33
src/Components/Lists/ApplicantPortfolioList/ApplicantPortfolioListModel.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,33 @@ | ||
import { ComponentModel } from '../../../modules/Components/Component.js'; | ||
import { Api } from '../../../modules/Api/Api.js'; | ||
import { Minicard } from '../../Minicard/Minicard.js'; | ||
import { resolveUrl } from '../../../modules/UrlUtils/UrlUtils.js'; | ||
|
||
export class ApplicantPortfolioListModel extends ComponentModel { | ||
#userId; | ||
#isOwner; | ||
constructor({ userId, isListOwner }) { | ||
super(); | ||
this.#userId = userId; | ||
this.#isOwner = isListOwner; | ||
} | ||
|
||
getItems() { | ||
const portfolioJson = Api.getApplicantPortfolios({ id: this.#userId }); | ||
const portfolioObjects = portfolioJson.reduce((portfolioObjects, portfolioJsonItem) => { | ||
const { id, name } = portfolioJsonItem; | ||
portfolioObjects.push( | ||
new Minicard({ | ||
renderParams: { | ||
elementClass: 'applicant-portfolio-list__minicard', | ||
title: name, | ||
isCardOwner: this.#isOwner, | ||
editButtonUrl: resolveUrl(`/portfolio/edit/${id}`), | ||
}, | ||
}), | ||
); | ||
return portfolioObjects; | ||
}, []); | ||
return portfolioObjects; | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
src/Components/Lists/ApplicantPortfolioList/ApplicantPortfolioListView.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,3 @@ | ||
import { ListView } from '../List/ListView.js'; | ||
|
||
export const ApplicantPortfolioListView = ListView; |
21 changes: 21 additions & 0 deletions
21
src/Components/Lists/EmployerVacancyList/EmployerVacancyList.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,21 @@ | ||
import { Component } from '../../../modules/Components/Component.js'; | ||
import { EmployerVacancyListModel } from './EmployerVacancyListModel.js'; | ||
import { EmployerVacancyListController } from './EmployerVacancyListController.js'; | ||
import { EmployerVacancyListView } from './EmployerVacancyListView.js'; | ||
import { ListMixin } from '../List/ListMixin.js'; | ||
|
||
export class EmployerVacancyList extends Component { | ||
constructor({ userId, isListOwner, elementClass, existingElement }) { | ||
super({ | ||
modelClass: EmployerVacancyListModel, | ||
controllerClass: EmployerVacancyListController, | ||
viewClass: EmployerVacancyListView, | ||
viewParams: { elementClass }, | ||
modelParams: { userId, isListOwner }, | ||
existingElement, | ||
}); | ||
this._controller.loadList(); | ||
} | ||
} | ||
|
||
Object.assign(EmployerVacancyList.prototype, ListMixin); |
3 changes: 3 additions & 0 deletions
3
src/Components/Lists/EmployerVacancyList/EmployerVacancyListController.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,3 @@ | ||
import { ListController } from '../List/ListController.js'; | ||
|
||
export const EmployerVacancyListController = ListController; |
Oops, something went wrong.