2021-08-07 17:03:06 +00:00
|
|
|
//
|
|
|
|
// Copyright © 2020 Anticrm Platform Contributors.
|
2021-11-18 12:48:05 +00:00
|
|
|
//
|
2021-08-07 17:03:06 +00:00
|
|
|
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License. You may
|
|
|
|
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
2021-11-18 12:48:05 +00:00
|
|
|
//
|
2021-08-07 17:03:06 +00:00
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
2021-11-18 12:48:05 +00:00
|
|
|
//
|
2021-08-07 17:03:06 +00:00
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
//
|
|
|
|
|
2021-12-20 09:37:15 +00:00
|
|
|
import type { Client, Doc } from '@anticrm/core'
|
2021-09-25 18:33:36 +00:00
|
|
|
|
2021-08-07 17:03:06 +00:00
|
|
|
import CreateVacancy from './components/CreateVacancy.svelte'
|
|
|
|
import CreateApplication from './components/CreateApplication.svelte'
|
|
|
|
import EditCandidate from './components/EditCandidate.svelte'
|
2021-09-07 08:36:50 +00:00
|
|
|
import KanbanCard from './components/KanbanCard.svelte'
|
2021-12-02 09:09:37 +00:00
|
|
|
import EditVacancy from './components/EditVacancy.svelte'
|
2021-09-11 09:32:01 +00:00
|
|
|
import ApplicationPresenter from './components/ApplicationPresenter.svelte'
|
2021-09-26 11:18:19 +00:00
|
|
|
import ApplicationsPresenter from './components/ApplicationsPresenter.svelte'
|
2021-12-14 09:24:14 +00:00
|
|
|
import TemplatesIcon from './components/TemplatesIcon.svelte'
|
2021-12-15 09:15:43 +00:00
|
|
|
import Applications from './components/Applications.svelte'
|
2021-12-17 09:04:49 +00:00
|
|
|
import EditApplication from './components/EditApplication.svelte'
|
2022-01-06 11:38:40 +00:00
|
|
|
import Candidates from './components/Candidates.svelte'
|
2021-11-18 12:48:05 +00:00
|
|
|
|
2021-09-25 18:33:36 +00:00
|
|
|
import { showPopup } from '@anticrm/ui'
|
2021-12-20 09:37:15 +00:00
|
|
|
import { OK, Resources, Severity, Status } from '@anticrm/platform'
|
|
|
|
import { Applicant } from '@anticrm/recruit'
|
|
|
|
import recruit from './plugin'
|
2021-09-25 18:33:36 +00:00
|
|
|
|
2021-11-18 12:48:05 +00:00
|
|
|
async function createApplication (object: Doc): Promise<void> {
|
2021-09-25 18:33:36 +00:00
|
|
|
showPopup(CreateApplication, { candidate: object._id, preserveCandidate: true })
|
|
|
|
}
|
|
|
|
|
2021-12-20 09:37:15 +00:00
|
|
|
export async function applicantValidator (applicant: Applicant, client: Client): Promise<Status> {
|
|
|
|
if (applicant.attachedTo === undefined) {
|
|
|
|
return new Status(Severity.INFO, recruit.status.CandidateRequired, {})
|
|
|
|
}
|
|
|
|
if (applicant.space === undefined) {
|
|
|
|
return new Status(Severity.INFO, recruit.status.VacancyRequired, {})
|
|
|
|
}
|
|
|
|
const applicants = await client.findAll(recruit.class.Applicant, {
|
|
|
|
space: applicant.space,
|
|
|
|
attachedTo: applicant.attachedTo
|
|
|
|
})
|
|
|
|
if (applicants.filter((p) => p._id !== applicant._id).length > 0) {
|
|
|
|
return new Status(Severity.ERROR, recruit.status.ApplicationExists, {})
|
|
|
|
}
|
|
|
|
return OK
|
|
|
|
}
|
|
|
|
|
2021-11-18 12:48:05 +00:00
|
|
|
export default async (): Promise<Resources> => ({
|
2021-09-25 18:33:36 +00:00
|
|
|
actionImpl: {
|
|
|
|
CreateApplication: createApplication
|
|
|
|
},
|
2021-12-20 09:37:15 +00:00
|
|
|
validator: {
|
|
|
|
ApplicantValidator: applicantValidator
|
|
|
|
},
|
2021-08-07 17:03:06 +00:00
|
|
|
component: {
|
|
|
|
CreateVacancy,
|
|
|
|
CreateApplication,
|
2021-08-18 10:10:54 +00:00
|
|
|
EditCandidate,
|
2021-12-17 09:04:49 +00:00
|
|
|
EditApplication,
|
2021-09-08 11:24:49 +00:00
|
|
|
KanbanCard,
|
2021-09-26 11:18:19 +00:00
|
|
|
ApplicationPresenter,
|
2021-12-02 09:09:37 +00:00
|
|
|
ApplicationsPresenter,
|
2021-12-14 09:24:14 +00:00
|
|
|
EditVacancy,
|
2021-12-15 09:15:43 +00:00
|
|
|
TemplatesIcon,
|
2022-01-06 11:38:40 +00:00
|
|
|
Applications,
|
|
|
|
Candidates
|
2021-11-18 12:48:05 +00:00
|
|
|
}
|
2021-08-07 17:03:06 +00:00
|
|
|
})
|