platform/plugins/recruit-resources/src/components/EditVacancy.svelte

165 lines
5.0 KiB
Svelte
Raw Normal View History

<!--
// Copyright © 2020, 2021 Anticrm Platform Contributors.
// Copyright © 2021 Hardcore Engineering Inc.
//
// 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
//
// 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.
//
// See the License for the specific language governing permissions and
// limitations under the License.
-->
<script lang="ts">
import activity from '@anticrm/activity'
import { Attachments } from '@anticrm/attachment-resources'
import type { Ref } from '@anticrm/core'
import type { IntlString } from '@anticrm/platform'
import { AttributesBar, createQuery, getClient, Members } from '@anticrm/presentation'
import { Vacancy } from '@anticrm/recruit'
import { StyledTextBox } from '@anticrm/text-editor'
2022-04-29 05:27:17 +00:00
import { ActionIcon, Component, EditBox, Grid, Icon, IconClose, Label, Scroller } from '@anticrm/ui'
import { createEventDispatcher } from 'svelte'
import recruit from '../plugin'
export let _id: Ref<Vacancy>
let object: Required<Vacancy>
const dispatch = createEventDispatcher()
const client = getClient()
const query = createQuery()
const clazz = client.getHierarchy().getClass(recruit.class.Vacancy)
function updateObject (_id: Ref<Vacancy>): void {
2022-04-29 05:27:17 +00:00
query.query(recruit.class.Vacancy, { _id }, (result) => {
object = result[0] as Required<Vacancy>
})
}
$: updateObject(_id)
const tabs: IntlString[] = [recruit.string.General, recruit.string.Members, activity.string.Activity]
let selected = 0
2022-04-29 05:27:17 +00:00
function onChange (key: string, value: any): void {
client.updateDoc(object._class, object.space, object._id, { [key]: value })
}
</script>
2022-04-29 05:27:17 +00:00
<div
class="antiOverlay"
on:click={() => {
dispatch('close')
}}
/>
<div class="antiDialogs antiComponent">
{#if object}
<div class="ac-header short mirror divide">
<div class="ac-header__wrap-description">
<div class="ac-header__wrap-title">
2022-04-29 05:27:17 +00:00
<div class="ac-header__icon">
{#if clazz.icon}<Icon icon={clazz.icon} size={'medium'} />{/if}
</div>
<div class="ac-header__title">{object.name}</div>
</div>
<div class="ac-header__description">{object.description}</div>
</div>
2022-04-29 05:27:17 +00:00
<div class="tool">
<ActionIcon
icon={IconClose}
size={'small'}
action={() => {
dispatch('close')
}}
/>
</div>
</div>
<div class="ac-subtitle">
<div class="ac-subtitle-content">
<AttributesBar {object} keys={['dueTo', 'location', 'company']} />
</div>
</div>
<div class="ac-tabs">
{#each tabs as tab, i}
2022-04-29 05:27:17 +00:00
<div
class="ac-tabs__tab"
class:selected={i === selected}
on:click={() => {
selected = i
}}
>
<Label label={tab} />
</div>
{/each}
<div class="ac-tabs__empty" />
</div>
{#if selected === 0}
<Scroller padding>
<Grid column={1} rowGap={1.5}>
2022-04-29 05:27:17 +00:00
<EditBox
label={recruit.string.VacancyName}
bind:value={object.name}
placeholder={recruit.string.VacancyPlaceholder}
maxWidth="39rem"
focus
on:change={() => {
if (object.name.trim().length > 0) {
onChange('name', object.name)
2022-04-29 05:27:17 +00:00
} else {
// Revert previos object.name
updateObject(_id)
}
}}
/>
<EditBox
label={recruit.string.Description}
bind:value={object.description}
placeholder={recruit.string.VacancyDescription}
maxWidth="39rem"
focus
on:change={() => {
onChange('description', object.description)
}}
/>
</Grid>
<div class="mt-10">
<span class="title">Details</span>
<div class="description-container">
2022-04-29 05:27:17 +00:00
<StyledTextBox
bind:content={object.fullDescription}
on:value={(evt) => {
onChange('fullDescription', evt.detail)
}}
/>
</div>
</div>
<div class="mt-14">
<Attachments objectId={object._id} _class={object._class} space={object.space} />
</div>
</Scroller>
{:else if selected === 1}
<Members space={object} />
{:else if selected === 2}
<Component is={activity.component.Activity} props={{ object, transparent: true }} />
{/if}
{/if}
</div>
<style lang="scss">
.description-container {
display: flex;
2022-04-29 05:27:17 +00:00
margin-top: 0.5rem;
padding: 1rem;
height: 12rem;
background-color: var(--theme-bg-accent-color);
border: 1px solid var(--theme-bg-accent-color);
2022-04-29 05:27:17 +00:00
border-radius: 0.25rem;
}
</style>