Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cards fixes #8186

Merged
merged 1 commit into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions models/card/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ import {
CardEvents,
cardId,
DOMAIN_CARD,
type ParentInfo,
type Card,
type MasterTag,
type ParentInfo,
type Tag
} from '@hcengineering/card'
import chunter from '@hcengineering/chunter'
import contact from '@hcengineering/contact'
import core, {
AccountRole,
DOMAIN_MODEL,
Expand Down Expand Up @@ -368,8 +367,7 @@ export function createModel (builder: Builder): void {
name: 'tagrelation',
label: card.string.TagRelations,
icon: setting.icon.Relations,
props: { _classes: [card.class.Card, contact.class.Contact], exclude: [] },
component: setting.component.RelationSetting,
component: card.component.RelationSetting,
group: 'settings-editor',
role: AccountRole.Maintainer,
order: 4501
Expand All @@ -381,7 +379,7 @@ export function createModel (builder: Builder): void {
setting.class.SettingsCategory,
core.space.Model,
{
name: 'masterTags',
name: 'types',
label: card.string.MasterTags,
icon: card.icon.Card,
component: card.component.ManageMasterTagsContent,
Expand Down
5 changes: 2 additions & 3 deletions models/server-card/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,11 @@ export function createModel (builder: Builder): void {
})

builder.createDoc(serverCore.class.Trigger, core.space.Model, {
trigger: serverCard.trigger.OnCardParentChange,
trigger: serverCard.trigger.OnCardUpdate,
isAsync: true,
txMatch: {
_class: core.class.TxUpdateDoc,
objectClass: card.class.Card,
operations: { parent: { $exists: true } }
objectClass: card.class.Card
}
})

Expand Down
12 changes: 6 additions & 6 deletions plugins/card-assets/lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"Cards": "Karten",
"Content": "Inhalt",
"CreateCard": "Karte erstellen",
"CreateMasterTag": "Master-Tag erstellen",
"CreateMasterTag": "Typ erstellen",
"CreateTag": "Tag erstellen",
"MasterTag": "Master-Tag",
"MasterTags": "Master-Tags",
"MasterTag": "Typ",
"MasterTags": "Typen",
"Parent": "Eltern",
"Tags": "Tags",
"Tag": "Tag",
Expand All @@ -18,11 +18,11 @@
"TagRelations": "Tag-Beziehungen",
"DeleteTag": "Tag löschen",
"DeleteTagConfirm": "Möchten Sie diesen Tag wirklich löschen? Alle zugehörigen Eigenschaften werden gelöscht",
"DeleteMasterTag": "Master-Tag löschen",
"DeleteMasterTagConfirm": "Möchten Sie diesen Master-Tag wirklich löschen? Alle mit diesem Master-Tag verbundenen Objekte werden gelöscht",
"DeleteMasterTag": "Typ löschen",
"DeleteMasterTagConfirm": "Möchten Sie diesen Typ wirklich löschen? Alle mit diesem Typ verbundenen Objekte werden gelöscht",
"UnsetParent": "Elternteil entfernen",
"SetParent": "Elternteil setzen",
"CreateChild": "Kind erstellen",
"Children": "Kinder"
}
}
}
6 changes: 3 additions & 3 deletions plugins/card-resources/src/components/CardPresenter.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
{:else if value}
{#if type === 'link'}
<div class="flex-row-center">
{#if showParent}
<ParentNamesPresenter {value} />
{/if}
<DocNavLink
object={value}
{onClick}
Expand All @@ -58,9 +61,6 @@
{/if}
<span class="overflow-label" class:select-text={!noSelect} title={value?.title}>
{value.title}
{#if showParent}
<ParentNamesPresenter {value} />
{/if}
<slot name="details" />
</span>
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
ev.stopPropagation()
const loc = getCurrentResolvedLocation()
loc.path[2] = settingId
loc.path[3] = 'masterTags'
loc.path[3] = 'types'
loc.path[4] = value._class
loc.path.length = 5
loc.fragment = undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
&:active {
color: var(--theme-content-color);
}
&::before {
&::after {
content: '';
padding: 0 0.25rem;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
-->
<script lang="ts">
import { Card } from '@hcengineering/card'
import { FindOptions, SortingOrder } from '@hcengineering/core'
import { Doc, FindOptions, SortingOrder } from '@hcengineering/core'
import { ObjectPopup, getClient } from '@hcengineering/presentation'
import { createEventDispatcher } from 'svelte'
import card from '../plugin'
Expand Down Expand Up @@ -48,6 +48,13 @@

$: selected = !Array.isArray(value) ? value.parent ?? undefined : undefined
$: ignoreObjects = !Array.isArray(value) ? [value._id] : undefined

$: cards = new Set(Array.isArray(value) ? value.map((p) => p._id) : [value._id])

const filter = (it: Doc): boolean => {
const card = it as Card
return !card.parentInfo.some((p) => cards.has(p._id))
}
</script>

<ObjectPopup
Expand All @@ -59,6 +66,7 @@
allowDeselect={true}
placeholder={card.string.SetParent}
create={undefined}
{filter}
{ignoreObjects}
shadows={true}
{width}
Expand Down
2 changes: 1 addition & 1 deletion plugins/card-resources/src/components/TagAttributes.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
ev.stopPropagation()
const loc = getCurrentResolvedLocation()
loc.path[2] = settingId
loc.path[3] = 'masterTags'
loc.path[3] = 'types'
loc.path[4] = tag._id
loc.path.length = 5
loc.fragment = undefined
Expand Down
5 changes: 1 addition & 4 deletions plugins/card-resources/src/components/TagHierarchy.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { Class, Doc, Ref } from '@hcengineering/core'
import { getClient } from '@hcengineering/presentation'
import { NavItem } from '@hcengineering/ui'
import { NavLink, showMenu } from '@hcengineering/view-resources'
import { NavLink } from '@hcengineering/view-resources'
import { createEventDispatcher } from 'svelte'
import card from '../plugin'

Expand Down Expand Up @@ -67,9 +67,6 @@
on:click={() => {
dispatch('select', clazz._id)
}}
on:contextmenu={(evt) => {
showMenu(evt, { object: clazz })
}}
/>
</NavLink>
{#if (descendants.get(clazz._id)?.length ?? 0) > 0}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<script lang="ts">
import contact from '@hcengineering/contact'
import { Class, Doc, Ref } from '@hcengineering/core'
import { getClient } from '@hcengineering/presentation'
import { CreateRelation } from '@hcengineering/setting-resources'
import card from '../../plugin'
export let aClass: Ref<Class<Doc>> | undefined = undefined
const client = getClient()
const hierarchy = client.getHierarchy()
const _classes = [...hierarchy.getDescendants(card.class.Card), contact.class.Contact].filter(
(c) => c !== card.class.Card
)
</script>

<CreateRelation {aClass} {_classes} exclude={[]} on:close />
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
onDestroy(resolvedLocationStore.subscribe(handleLocationChanged))

function handleLocationChanged ({ path }: Location): void {
if (path[3] !== 'masterTags' || path[4] === undefined) {
if (path[3] !== 'types' || path[4] === undefined) {
selectedTagId = undefined
} else {
selectedTagId = path[4] as Ref<MasterTag>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<script lang="ts">
import { getClient } from '@hcengineering/presentation'
import { RelationSetting } from '@hcengineering/setting-resources'
import contact from '@hcengineering/contact'
import card from '../../plugin'

const client = getClient()
const hierarchy = client.getHierarchy()
const _classes = [...hierarchy.getDescendants(card.class.Card), contact.class.Contact].filter(
(c) => c !== card.class.Card
)
</script>

<RelationSetting {_classes} exclude={[]} />
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
// limitations under the License.
-->
<script lang="ts">
import card, { MasterTag } from '@hcengineering/card'
import contact from '@hcengineering/contact'
import { MasterTag } from '@hcengineering/card'
import core, { Association, Class, Doc, Ref } from '@hcengineering/core'
import { IntlString } from '@hcengineering/platform'
import { createQuery, getClient } from '@hcengineering/presentation'
import setting from '@hcengineering/setting'
import { clearSettingsStore, settingsStore } from '@hcengineering/setting-resources'
import { ButtonIcon, Icon, IconAdd, Label, showPopup } from '@hcengineering/ui'
import { onDestroy } from 'svelte'
import CreateRelation from './CreateRelation.svelte'

export let masterTag: MasterTag

Expand Down Expand Up @@ -49,10 +49,8 @@
}

function addRelation (): void {
showPopup(setting.component.CreateRelation, {
aClass: masterTag._id,
exclude: [],
_classes: [card.class.Card, contact.class.Contact]
showPopup(CreateRelation, {
aClass: masterTag._id
})
}

Expand Down
4 changes: 3 additions & 1 deletion plugins/card-resources/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import TagsSection from './components/settings/TagsSection.svelte'
import RelationsSection from './components/settings/RelationsSection.svelte'
import ChildsSection from './components/settings/ChildsSection.svelte'
import SetParentActionPopup from './components/SetParentActionPopup.svelte'
import RelationSetting from './components/settings/RelationSetting.svelte'

export default async (): Promise<Resources> => ({
component: {
Expand All @@ -51,7 +52,8 @@ export default async (): Promise<Resources> => ({
TagsSection,
RelationsSection,
ChildsSection,
SetParentActionPopup
SetParentActionPopup,
RelationSetting
},
completion: {
CardQuery: queryCard
Expand Down
3 changes: 2 additions & 1 deletion plugins/card-resources/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export default mergeIds(cardId, card, {
TagsSection: '' as AnyComponent,
ChildsSection: '' as AnyComponent,
RelationsSection: '' as AnyComponent,
SetParentActionPopup: '' as AnyComponent
SetParentActionPopup: '' as AnyComponent,
RelationSetting: '' as AnyComponent
},
completion: {
CardQuery: '' as Resource<ObjectSearchFactory>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@
const clazz = hierarchy.getClass(key)
result.push([
{ id: key, label: clazz.label, icon: clazz.icon },
value.map((it) => ({ id: it._id, label: it.label, icon: it.icon }))
value
.map((it) => ({ id: it._id, label: it.label, icon: it.icon }))
.sort((a, b) => a.label.localeCompare(b.label))
])
} catch {}
}
Expand Down
4 changes: 3 additions & 1 deletion plugins/setting-resources/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ export {
ClassSetting,
filterDescendants,
SpaceTypeGeneralSectionEditor,
ClassHierarchy
ClassHierarchy,
RelationSetting,
CreateRelation
}

async function DeleteMixin (object: Mixin<Class<Doc>>): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
$: query.query(
view.class.Viewlet,
{
attachTo: _class
attachTo: client.getHierarchy().getBaseClass(_class)
},
(res) => {
viewlet = res[0]
Expand Down
Loading