2021-12-06 10:07:08 +00:00
|
|
|
<!--
|
|
|
|
// Copyright © 2020, 2021 Anticrm Platform Contributors.
|
|
|
|
// Copyright © 2021 Hardcore Engineering Inc.
|
2021-12-07 09:05:52 +00:00
|
|
|
//
|
2021-12-06 10:07:08 +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-12-07 09:05:52 +00:00
|
|
|
//
|
2021-12-06 10:07:08 +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-12-07 09:05:52 +00:00
|
|
|
//
|
2021-12-06 10:07:08 +00:00
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
-->
|
|
|
|
<script lang="ts">
|
|
|
|
import { createEventDispatcher } from 'svelte'
|
|
|
|
import type { Ref, Space } from '@anticrm/core'
|
|
|
|
|
2021-12-07 09:05:52 +00:00
|
|
|
import { getClient, Card, Channels } from '@anticrm/presentation'
|
2021-12-06 10:07:08 +00:00
|
|
|
|
|
|
|
import { EditBox, showPopup, CircleButton, IconEdit, IconAdd, Label } from '@anticrm/ui'
|
|
|
|
import SocialEditor from './SocialEditor.svelte'
|
|
|
|
|
|
|
|
import { Organization } from '@anticrm/contact'
|
|
|
|
import contact from '../plugin'
|
|
|
|
import Company from './icons/Company.svelte'
|
|
|
|
|
2021-12-07 09:05:52 +00:00
|
|
|
export function canClose (): boolean {
|
2021-12-06 10:07:08 +00:00
|
|
|
return object.name === ''
|
|
|
|
}
|
|
|
|
|
|
|
|
const object: Organization = {
|
|
|
|
name: ''
|
|
|
|
} as Organization
|
|
|
|
|
|
|
|
const dispatch = createEventDispatcher()
|
|
|
|
const client = getClient()
|
|
|
|
|
2021-12-07 09:05:52 +00:00
|
|
|
async function createOrganization () {
|
2022-01-11 09:05:53 +00:00
|
|
|
await client.createDoc(contact.class.Organization, contact.space.Contacts, object)
|
2021-12-06 10:07:08 +00:00
|
|
|
|
|
|
|
dispatch('close')
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2021-12-07 09:05:52 +00:00
|
|
|
<Card
|
|
|
|
label={'Create organization'}
|
|
|
|
okAction={createOrganization}
|
|
|
|
canSave={object.name.length > 0}
|
2022-01-11 09:05:53 +00:00
|
|
|
space={contact.space.Contacts}
|
2021-12-07 09:05:52 +00:00
|
|
|
on:close={() => {
|
|
|
|
dispatch('close')
|
|
|
|
}}
|
|
|
|
>
|
2021-12-06 10:07:08 +00:00
|
|
|
<div class="flex-row-center">
|
|
|
|
<div class="mr-4 flex-center logo">
|
|
|
|
<Company size={'large'} />
|
|
|
|
</div>
|
|
|
|
<div class="flex-col">
|
2021-12-07 09:05:52 +00:00
|
|
|
<div class="fs-title"><EditBox placeholder="Apple" maxWidth="10rem" bind:value={object.name} /></div>
|
2021-12-06 10:07:08 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="flex-row-center channels">
|
|
|
|
{#if !object.channels || object.channels.length === 0}
|
2021-12-07 09:05:52 +00:00
|
|
|
<CircleButton
|
|
|
|
icon={IconAdd}
|
|
|
|
size={'small'}
|
|
|
|
transparent
|
|
|
|
on:click={(ev) =>
|
|
|
|
showPopup(SocialEditor, { values: object.channels ?? [] }, ev.target, (result) => {
|
|
|
|
object.channels = result
|
|
|
|
})}
|
|
|
|
/>
|
2021-12-06 10:07:08 +00:00
|
|
|
<span><Label label={contact.string.AddSocialLinks} /></span>
|
|
|
|
{:else}
|
|
|
|
<Channels value={object.channels} size={'small'} />
|
|
|
|
<div class="ml-1">
|
2021-12-07 09:05:52 +00:00
|
|
|
<CircleButton
|
|
|
|
icon={IconEdit}
|
|
|
|
size={'small'}
|
|
|
|
transparent
|
|
|
|
on:click={(ev) =>
|
|
|
|
showPopup(SocialEditor, { values: object.channels ?? [] }, ev.target, (result) => {
|
|
|
|
object.channels = result
|
|
|
|
})}
|
|
|
|
/>
|
2021-12-06 10:07:08 +00:00
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
</Card>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
.logo {
|
|
|
|
width: 5rem;
|
|
|
|
height: 5rem;
|
|
|
|
color: var(--primary-button-color);
|
|
|
|
background-color: var(--primary-button-enabled);
|
|
|
|
border-radius: 50%;
|
|
|
|
}
|
|
|
|
.channels {
|
|
|
|
margin-top: 1.25rem;
|
2021-12-07 09:05:52 +00:00
|
|
|
span {
|
|
|
|
margin-left: 0.5rem;
|
|
|
|
}
|
2021-12-06 10:07:08 +00:00
|
|
|
}
|
|
|
|
</style>
|