mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-14 12:25:17 +00:00
Add Bitrix required mixins (#2713)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
c6dd5a6619
commit
7997d34d17
@ -14,12 +14,12 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import { Builder, Collection, Mixin, Model, Prop, TypeRef, TypeString } from '@hcengineering/model'
|
||||
import { ArrOf, Builder, Collection, Mixin, Model, Prop, TypeRef, TypeString } from '@hcengineering/model'
|
||||
import core, { TAttachedDoc, TDoc } from '@hcengineering/model-core'
|
||||
import bitrix from './plugin'
|
||||
|
||||
import { BitrixEntityMapping, BitrixFieldMapping, BitrixSyncDoc, Fields } from '@hcengineering/bitrix'
|
||||
import { AnyAttribute, Class, Doc, Domain, Ref } from '@hcengineering/core'
|
||||
import { AnyAttribute, Class, Doc, Domain, Mixin as CoreMixin, Ref } from '@hcengineering/core'
|
||||
|
||||
import view, { createAction } from '@hcengineering/model-view'
|
||||
|
||||
@ -47,6 +47,10 @@ export class TBitrixEntityMapping extends TDoc implements BitrixEntityMapping {
|
||||
comments!: boolean
|
||||
activity!: boolean
|
||||
attachments!: boolean
|
||||
|
||||
@Prop(ArrOf(TypeRef(core.class.Mixin)), core.string.Class)
|
||||
// If specified, will include this mixins in any case.
|
||||
mixins!: Ref<CoreMixin<Doc>>[]
|
||||
}
|
||||
|
||||
@Model(bitrix.class.FieldMapping, core.class.Doc, DOMAIN_BITRIX)
|
||||
|
@ -12,13 +12,14 @@
|
||||
import { getEmbeddedLabel } from '@hcengineering/platform'
|
||||
import { createQuery, getClient } from '@hcengineering/presentation'
|
||||
import { ClassSetting } from '@hcengineering/setting-resources'
|
||||
import { Button, Expandable, Icon, IconDelete, IconEdit, Label, showPopup } from '@hcengineering/ui'
|
||||
import { Button, Expandable, Icon, IconAdd, IconDelete, IconEdit, Label, showPopup } from '@hcengineering/ui'
|
||||
import bitrix from '../plugin'
|
||||
|
||||
import AttributeMapper from './AttributeMapper.svelte'
|
||||
import FieldMappingPresenter from './FieldMappingPresenter.svelte'
|
||||
|
||||
import CheckBox from '@hcengineering/ui/src/components/CheckBox.svelte'
|
||||
import DropdownLabelsPopup from '@hcengineering/ui/src/components/DropdownLabelsPopup.svelte'
|
||||
import { deepEqual } from 'fast-equals'
|
||||
import BitrixFieldLookup from './BitrixFieldLookup.svelte'
|
||||
import CreateMappingAttribute from './CreateMappingAttribute.svelte'
|
||||
@ -112,6 +113,51 @@
|
||||
<Label label={getEmbeddedLabel('Activity')} />
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex-row-center">
|
||||
<div class="ml-2">
|
||||
<Label label={getEmbeddedLabel('Mixins to include')} />
|
||||
</div>
|
||||
{#each mapping.mixins ?? [] as mixin}
|
||||
<div class="flex-row-center p-1 focused-button">
|
||||
{mixin}
|
||||
<Button
|
||||
icon={IconDelete}
|
||||
on:click={() => {
|
||||
client.update(mapping, { $pull: { mixins: mixin } })
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
{/each}
|
||||
<Button
|
||||
icon={IconAdd}
|
||||
label={getEmbeddedLabel('Add mixin')}
|
||||
on:click={async () => {
|
||||
const h = client.getHierarchy()
|
||||
const mixins = []
|
||||
for (const o of h.getAncestors(mapping.ofClass)) {
|
||||
const ms = await h.getDescendants(h.getBaseClass(o)).filter((it) => h.isMixin(it))
|
||||
for (const m of ms) {
|
||||
if (mixins.indexOf(m) === -1) {
|
||||
mixins.push(m)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
showPopup(
|
||||
DropdownLabelsPopup,
|
||||
{
|
||||
items: mixins.map((it) => ({ id: it, label: h.getClass(it).label ?? it }))
|
||||
},
|
||||
'top',
|
||||
(res) => {
|
||||
if (res != null) {
|
||||
client.update(mapping, { $push: { mixins: res } })
|
||||
}
|
||||
}
|
||||
)
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</Expandable>
|
||||
<Expandable label={getEmbeddedLabel('Mappings')} expanded>
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hcengineering/bitrix",
|
||||
"version": "0.6.23",
|
||||
"version": "0.6.24",
|
||||
"main": "lib/index.js",
|
||||
"author": "Anticrm Platform Contributors",
|
||||
"license": "EPL-2.0",
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { ChannelProvider } from '@hcengineering/contact'
|
||||
import { AttachedDoc, Class, Doc, Ref } from '@hcengineering/core'
|
||||
import { AttachedDoc, Class, Doc, Mixin, Ref } from '@hcengineering/core'
|
||||
import { ExpertKnowledge, InitialKnowledge, MeaningfullKnowledge } from '@hcengineering/tags'
|
||||
|
||||
/**
|
||||
@ -164,6 +164,9 @@ export interface BitrixEntityMapping extends Doc {
|
||||
comments: boolean
|
||||
activity: boolean
|
||||
attachments: boolean
|
||||
|
||||
// If specified, will include this mixins in any case.
|
||||
mixins?: Ref<Mixin<Doc>>[]
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
|
@ -114,6 +114,11 @@ export async function convert (
|
||||
][] = []
|
||||
const mixins: Record<Ref<Mixin<Doc>>, Data<Doc>> = {}
|
||||
|
||||
// Fill required mixins.
|
||||
for (const m of entity.mixins ?? []) {
|
||||
mixins[m] = {}
|
||||
}
|
||||
|
||||
const syncRequests: BitrixSyncRequest[] = []
|
||||
|
||||
const extractValue = (field?: string, alternatives?: string[]): any | undefined => {
|
||||
|
Loading…
Reference in New Issue
Block a user