Show room as attribute

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
Kristina Fefelova 2024-11-14 17:34:40 +04:00
parent e6cbd5ce31
commit 6a21296d2b
No known key found for this signature in database
GPG Key ID: 750D35EF042F0690
6 changed files with 95 additions and 3 deletions

View File

@ -20,7 +20,8 @@ import {
DOMAIN_TRANSIENT,
IndexKind,
type Ref,
type CollaborativeDoc
type CollaborativeDoc,
Doc
} from '@hcengineering/core'
import {
type DevicesPreference,
@ -186,6 +187,11 @@ export class TMeeting extends TEvent implements Meeting {
@Model(love.class.MeetingMinutes, core.class.Doc, DOMAIN_MEETING_MINUTES)
@UX(love.string.MeetingMinutes, love.icon.Cam, undefined, undefined, love.string.MeetingsMinutes)
export class TMeetingMinutes extends TAttachedDoc implements MeetingMinutes {
@Prop(TypeRef(core.class.Doc), love.string.Room, {editor: love.component.MeetingMinutesDocEditor })
@Index(IndexKind.Indexed)
@ReadOnly()
declare attachedTo: Ref<Doc>
@Hidden()
sid!: string
@ -439,6 +445,10 @@ export function createModel (builder: Builder): void {
presenter: love.component.MeetingMinutesPresenter
})
builder.mixin(love.class.Room, core.class.Class, view.mixin.ObjectPresenter, {
presenter: love.component.RoomPresenter
})
builder.mixin(love.class.MeetingMinutes, core.class.Class, view.mixin.CollectionEditor, {
editor: love.component.MeetingMinutesSection
})

View File

@ -626,7 +626,7 @@ export async function getAttributeEditor (
function filterKeys (hierarchy: Hierarchy, keys: KeyedAttribute[], ignoreKeys: string[]): KeyedAttribute[] {
const docKeys: Set<string> = new Set<string>(hierarchy.getAllAttributes(core.class.AttachedDoc).keys())
keys = keys.filter((k) => !docKeys.has(k.key))
keys = keys.filter((k) => !docKeys.has(k.key) || k.attr.editor !== undefined)
keys = keys.filter((k) => !ignoreKeys.includes(k.key))
return keys
}

View File

@ -0,0 +1,23 @@
<!--
// Copyright © 2024 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 { MeetingMinutes } from '@hcengineering/love'
import { ObjectPresenter } from '@hcengineering/view-resources'
export let object: MeetingMinutes
</script>
<ObjectPresenter objectId={object.attachedTo} _class={object.attachedToClass} shouldShowAvatar={false} disabled props={{ type: 'text' }}/>

View File

@ -0,0 +1,53 @@
<!--
// Copyright © 2024 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 love, { Room } from '@hcengineering/love'
import { WithLookup } from '@hcengineering/core'
import { ObjectPresenterType } from '@hcengineering/view'
import { getEmbeddedLabel } from '@hcengineering/platform'
import { DocNavLink, ObjectMention } from '@hcengineering/view-resources'
import { tooltip, Icon } from '@hcengineering/ui'
export let value: WithLookup<Room>
export let inline: boolean = false
export let disabled: boolean = false
export let accent: boolean = false
export let noUnderline: boolean = false
export let shouldShowAvatar = true
export let type: ObjectPresenterType = 'link'
</script>
{#if value}
{#if inline}
<ObjectMention object={value} {disabled} {accent} {noUnderline} />
{:else if type === 'link'}
<DocNavLink object={value} {disabled} {accent} {noUnderline}>
<div class="flex-presenter" use:tooltip={{ label: getEmbeddedLabel(value.name) }}>
{#if shouldShowAvatar}
<div class="icon">
<Icon icon={love.icon.Love} size={'small'} />
</div>
{/if}
<div class="label nowrap flex flex-gap-2" class:no-underline={noUnderline || disabled} class:fs-bold={accent}>
<span>{value.name}</span>
</div>
</div>
</DocNavLink>
{:else if type === 'text'}
<span class="overflow-label" use:tooltip={{ label: getEmbeddedLabel(value.name) }}>
{value.name}
</span>
{/if}
{/if}

View File

@ -19,6 +19,8 @@ import FloorAttributePresenter from './components/FloorAttributePresenter.svelte
import FloorView from './components/FloorView.svelte'
import MeetingMinutesTable from './components/MeetingMinutesTable.svelte'
import PanelControlBar from './components/PanelControlBar.svelte'
import RoomPresenter from './components/RoomPresenter.svelte'
import MeetingMinutesDocEditor from './components/MeetingMinutesDocEditor.svelte'
import {
copyGuestLink,
@ -51,7 +53,9 @@ export default async (): Promise<Resources> => ({
FloorAttributePresenter,
FloorView,
MeetingMinutesTable,
PanelControlBar
PanelControlBar,
RoomPresenter,
MeetingMinutesDocEditor
},
function: {
CreateMeeting: createMeeting,

View File

@ -25,6 +25,7 @@ export default mergeIds(loveId, love, {
MeetingData: '' as AnyComponent,
EditMeetingData: '' as AnyComponent,
MeetingMinutesPresenter: '' as AnyComponent,
RoomPresenter: '' as AnyComponent,
MeetingMinutesSection: '' as AnyComponent,
EditMeetingMinutes: '' as AnyComponent,
EditRoom: '' as AnyComponent,
@ -32,6 +33,7 @@ export default mergeIds(loveId, love, {
MeetingMinutesTable: '' as AnyComponent,
FloorView: '' as AnyComponent,
PanelControlBar: '' as AnyComponent,
MeetingMinutesDocEditor: '' as AnyComponent
},
function: {
CreateMeeting: '' as Resource<DocCreateFunction>,