Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com>
This commit is contained in:
Denis Bykhov
2022-07-01 22:22:58 +07:00
committed by GitHub
parent 25afe12cc2
commit efc3583376
41 changed files with 502 additions and 229 deletions
@@ -20,6 +20,7 @@
export let icon: Asset | undefined = undefined
export let label: IntlString | undefined = undefined
export let selected: boolean = false
export let expandable = false
const dispatch = createEventDispatcher()
</script>
@@ -28,6 +29,7 @@
<div
class="antiNav-element"
class:selected
class:expandable
on:click|stopPropagation={() => {
dispatch('click')
}}
@@ -38,6 +40,21 @@
{/if}
</div>
<span class="an-element__label title">
{#if label}<Label {label} />{:else}{label}{/if}
{#if label}<Label {label} />{/if}
</span>
</div>
<style lang="scss">
.expandable {
position: relative;
&::after {
content: '▶';
position: absolute;
top: 50%;
right: 0.5rem;
font-size: 0.375rem;
color: var(--dark-color);
transform: translateY(-50%);
}
}
</style>
@@ -77,7 +77,7 @@
{/each}
</div>
</div>
<div class="ac-column">
<div class="ac-column max">
{#if selected !== undefined}
<EnumValues value={selected} />
{/if}
@@ -0,0 +1,91 @@
<!--
// Copyright © 2022 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 contact, { Employee, EmployeeAccount } from '@anticrm/contact'
import { PersonPresenter } from '@anticrm/contact-resources'
import { AccountRole, getCurrentAccount, Ref, SortingOrder } from '@anticrm/core'
import { createQuery, getClient } from '@anticrm/presentation'
import { DropdownIntlItem, DropdownLabelsIntl, Icon, Label } from '@anticrm/ui'
import setting from '../plugin'
const client = getClient()
const query = createQuery()
const employeeQuery = createQuery()
const currentRole = getCurrentAccount().role
const items: DropdownIntlItem[] = [
{ id: AccountRole.User.toString(), label: setting.string.User },
{ id: AccountRole.Maintainer.toString(), label: setting.string.Maintainer },
{ id: AccountRole.Owner.toString(), label: setting.string.Owner }
]
let accounts: EmployeeAccount[] = []
$: owners = accounts.filter((p) => p.role === AccountRole.Owner)
let employees: Map<Ref<Employee>, Employee> = new Map<Ref<Employee>, Employee>()
query.query(
contact.class.EmployeeAccount,
{},
(res) => {
accounts = res
},
{
sort: { name: SortingOrder.Descending }
}
)
employeeQuery.query(contact.class.Employee, {}, (res) => {
employees = new Map(
res.map((p) => {
return [p._id, p]
})
)
})
async function change (account: EmployeeAccount, value: AccountRole): Promise<void> {
await client.update(account, {
role: value
})
}
</script>
<div class="antiComponent">
<div class="ac-header short divide">
<div class="ac-header__icon"><Icon icon={setting.icon.Password} size={'medium'} /></div>
<div class="ac-header__title"><Label label={setting.string.Owners} /></div>
</div>
<div class="ac-body columns">
<div class="ac-column max">
{#each accounts as account (account._id)}
<div class="flex-between">
<PersonPresenter value={employees.get(account.employee)} isInteractive={false} />
<DropdownLabelsIntl
label={setting.string.Role}
disabled={account.role > currentRole || (account.role === AccountRole.Owner && owners.length === 1)}
kind={'transparent'}
size={'medium'}
{items}
selected={account.role.toString()}
on:selected={(e) => {
change(account, Number(e.detail))
}}
/>
</div>
{/each}
</div>
</div>
</div>
@@ -1,25 +0,0 @@
<!--
// Copyright © 2020, 2021 Anticrm Platform Contributors.
//
// 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 setting from '@anticrm/setting'
import { Icon, Label } from '@anticrm/ui'
</script>
<div class="antiComponent">
<div class="ac-header short divide">
<div class="ac-header__icon"><Icon icon={setting.icon.Setting} size={'medium'} /></div>
<div class="ac-header__title"><Label label={setting.string.Setting} /></div>
</div>
</div>
@@ -1,5 +1,19 @@
<!--
// Copyright © 2022 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 { getClient } from '@anticrm/presentation'
import { createQuery } from '@anticrm/presentation'
import setting, { SettingsCategory } from '@anticrm/setting'
import {
Component,
@@ -13,17 +27,25 @@
import { onDestroy } from 'svelte'
import CategoryElement from './CategoryElement.svelte'
import login from '@anticrm/login'
const client = getClient()
import { AccountRole, getCurrentAccount } from '@anticrm/core'
import { EmployeeAccount } from '@anticrm/contact'
let category: SettingsCategory | undefined
let categoryId: string = ''
let categories: SettingsCategory[] = []
client.findAll(setting.class.SettingsCategory, {}, { sort: { order: 1 } }).then((s) => {
categories = s
category = findCategory(categoryId)
})
const account = getCurrentAccount() as EmployeeAccount
const settingsQuery = createQuery()
settingsQuery.query(
setting.class.SettingsCategory,
{},
(res) => {
categories = account.role > AccountRole.User ? res : res.filter((p) => p.secured === false)
category = findCategory(categoryId)
},
{ sort: { order: 1 } }
)
onDestroy(
location.subscribe(async (loc) => {
@@ -68,6 +90,7 @@
icon={category.icon}
label={category.label}
selected={category.name === categoryId}
expandable={category._id === setting.ids.Setting}
on:click={() => {
selectCategory(category.name)
}}
@@ -0,0 +1,74 @@
<!--
// Copyright © 2022 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 { EmployeeAccount } from '@anticrm/contact'
import { AccountRole, getCurrentAccount } from '@anticrm/core'
import { createQuery } from '@anticrm/presentation'
import setting, { SettingsCategory } from '@anticrm/setting'
import { Component, Label } from '@anticrm/ui'
import CategoryElement from './CategoryElement.svelte'
let category: SettingsCategory | undefined
let categoryId: string = ''
let categories: SettingsCategory[] = []
const account = getCurrentAccount() as EmployeeAccount
const settingsQuery = createQuery()
settingsQuery.query(
setting.class.WorkspaceSettingCategory,
{},
(res) => {
categories = account.role > AccountRole.User ? res : res.filter((p) => p.secured === false)
category = findCategory(categoryId)
},
{ sort: { order: 1 } }
)
function findCategory (name: string): SettingsCategory | undefined {
return categories.find((x) => x.name === name)
}
function selectCategory (value: SettingsCategory) {
categoryId = value.name
category = value
}
</script>
<div class="flex h-full">
<div class="antiPanel-navigator filled indent">
<div class="antiNav-header">
<span class="fs-title overflow-label">
<Label label={setting.string.WorkspaceSetting} />
</span>
</div>
{#each categories as category}
<CategoryElement
icon={category.icon}
label={category.label}
selected={category.name === categoryId}
on:click={() => {
selectCategory(category)
}}
/>
{/each}
</div>
<div class="antiPanel-component border-left filled">
{#if category}
<Component is={category.component} />
{/if}
</div>
</div>