mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-23 03:22:19 +03:00
Remove accounts with same employee in settings (#5876)
This commit is contained in:
parent
ddd38648da
commit
182d108b87
@ -13,8 +13,8 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
-->
|
-->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import contact, { PersonAccount } from '@hcengineering/contact'
|
import contact, { PersonAccount, formatName } from '@hcengineering/contact'
|
||||||
import { EmployeePresenter, personByIdStore } from '@hcengineering/contact-resources'
|
import { EmployeePresenter, employeesStore } from '@hcengineering/contact-resources'
|
||||||
import { AccountRole, getCurrentAccount, hasAccountRole } from '@hcengineering/core'
|
import { AccountRole, getCurrentAccount, hasAccountRole } from '@hcengineering/core'
|
||||||
import presentation, { createQuery, getClient } from '@hcengineering/presentation'
|
import presentation, { createQuery, getClient } from '@hcengineering/presentation'
|
||||||
import { Breadcrumb, DropdownIntlItem, DropdownLabelsIntl, EditBox, Header, Scroller } from '@hcengineering/ui'
|
import { Breadcrumb, DropdownIntlItem, DropdownLabelsIntl, EditBox, Header, Scroller } from '@hcengineering/ui'
|
||||||
@ -31,9 +31,11 @@
|
|||||||
]
|
]
|
||||||
|
|
||||||
let accounts: PersonAccount[] = []
|
let accounts: PersonAccount[] = []
|
||||||
|
let owners: PersonAccount[] = []
|
||||||
$: owners = accounts.filter((p) => p.role === AccountRole.Owner)
|
$: owners = accounts.filter((p) => p.role === AccountRole.Owner)
|
||||||
|
|
||||||
query.query(contact.class.PersonAccount, {}, (res) => {
|
query.query(contact.class.PersonAccount, {}, (res) => {
|
||||||
|
owners = res.filter((p) => p.role === AccountRole.Owner)
|
||||||
accounts = res
|
accounts = res
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -43,6 +45,10 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
let search = ''
|
let search = ''
|
||||||
|
|
||||||
|
$: employees = $employeesStore
|
||||||
|
.filter((p) => p.active)
|
||||||
|
.sort((a, b) => formatName(a.name).localeCompare(formatName(b.name)))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="hulyComponent">
|
<div class="hulyComponent">
|
||||||
@ -53,27 +59,23 @@
|
|||||||
<div class="hulyComponent-content__column content">
|
<div class="hulyComponent-content__column content">
|
||||||
<Scroller align={'center'} padding={'var(--spacing-3)'} bottomPadding={'var(--spacing-3)'}>
|
<Scroller align={'center'} padding={'var(--spacing-3)'} bottomPadding={'var(--spacing-3)'}>
|
||||||
<div class="hulyComponent-content">
|
<div class="hulyComponent-content">
|
||||||
{#each accounts as account (account._id)}
|
{#each employees as employee (employee._id)}
|
||||||
{@const employee = $personByIdStore.get(account.person)}
|
{@const acc = accounts.find((p) => p.person === employee._id)}
|
||||||
{#if employee?.name?.includes(search)}
|
{#if acc && employee.name?.includes(search)}
|
||||||
<div class="flex-row-center p-2 flex-no-shrink">
|
<div class="flex-row-center p-2 flex-no-shrink">
|
||||||
<div class="p-1 min-w-80">
|
<div class="p-1 min-w-80">
|
||||||
{#if employee}
|
<EmployeePresenter value={employee} disabled={false} />
|
||||||
<EmployeePresenter value={employee} disabled={false} />
|
|
||||||
{:else}
|
|
||||||
{account.email}
|
|
||||||
{/if}
|
|
||||||
</div>
|
</div>
|
||||||
<DropdownLabelsIntl
|
<DropdownLabelsIntl
|
||||||
label={setting.string.Role}
|
label={setting.string.Role}
|
||||||
disabled={!hasAccountRole(currentAccount, account.role) ||
|
disabled={!hasAccountRole(currentAccount, acc.role) ||
|
||||||
(account.role === AccountRole.Owner && owners.length === 1)}
|
(acc.role === AccountRole.Owner && owners.length === 1)}
|
||||||
kind={'primary'}
|
kind={'primary'}
|
||||||
size={'medium'}
|
size={'medium'}
|
||||||
{items}
|
{items}
|
||||||
selected={account.role}
|
selected={acc.role}
|
||||||
on:selected={(e) => {
|
on:selected={(e) => {
|
||||||
void change(account, e.detail)
|
void change(acc, e.detail)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user