Fix removed attachment presenter ()

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2023-04-20 13:27:15 +06:00 committed by GitHub
parent 8407c89709
commit a80125c466
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 65 additions and 16 deletions
models/attachment/src
plugins
activity-resources/src/components
attachment-assets/lang
attachment-resources/src/components
tracker-resources/src/components/issues

View File

@ -107,6 +107,20 @@ export function createModel (builder: Builder): void {
attachment.ids.TxAttachmentCreate
)
builder.createDoc(
activity.class.TxViewlet,
core.space.Model,
{
objectClass: attachment.class.Attachment,
icon: attachment.icon.Attachment,
txClass: core.class.TxRemoveDoc,
component: attachment.activity.TxAttachmentCreate,
label: attachment.string.RemovedAttachment,
display: 'inline'
},
attachment.ids.TxAttachmentRemove
)
builder.createDoc(activity.class.ActivityFilter, core.space.Model, {
label: attachment.string.FilterAttachments,
filter: attachment.filter.AttachmentsFilter

View File

@ -40,10 +40,12 @@ export default mergeIds(attachmentId, attachment, {
Description: '' as IntlString,
PinAttachment: '' as IntlString,
UnPinAttachment: '' as IntlString,
FilterAttachments: '' as IntlString
FilterAttachments: '' as IntlString,
RemovedAttachment: '' as IntlString
},
ids: {
TxAttachmentCreate: '' as Ref<TxViewlet>
TxAttachmentCreate: '' as Ref<TxViewlet>,
TxAttachmentRemove: '' as Ref<TxViewlet>
},
activity: {
TxAttachmentCreate: '' as AnyComponent

View File

@ -16,7 +16,7 @@
<script lang="ts">
import type { DisplayTx, TxViewlet } from '@hcengineering/activity'
import contact, { Employee, EmployeeAccount, getName } from '@hcengineering/contact'
import core, { AnyAttribute, Doc, getCurrentAccount, Ref, Class } from '@hcengineering/core'
import core, { AnyAttribute, Doc, getCurrentAccount, Ref, Class, TxCUD } from '@hcengineering/core'
import { Asset } from '@hcengineering/platform'
import { createQuery, getClient } from '@hcengineering/presentation'
import {
@ -135,8 +135,8 @@
function isMessageType (attr?: AnyAttribute): boolean {
return attr?.type._class === core.class.TypeMarkup
}
function isAttachment (_class?: Ref<Class<Doc>>): boolean {
return _class === attachment.class.Attachment
function isAttachment (tx: TxCUD<Doc>): boolean {
return tx.objectClass === attachment.class.Attachment && tx._class === core.class.TxCreateDoc
}
function isMention (_class?: Ref<Class<Doc>>): boolean {
return _class === chunter.class.Backlink
@ -159,7 +159,7 @@
hasMessageType = res
})
$: isComment = viewlet && viewlet?.editable
$: isAttached = isAttachment(tx.tx.objectClass)
$: isAttached = isAttachment(tx.tx)
$: isMentioned = isMention(tx.tx.objectClass)
$: withAvatar = isComment || isMentioned || isAttached
$: isEmphasized = viewlet?.display === 'emphasized' || model.every((m) => isMessageType(m.attribute))

View File

@ -50,6 +50,7 @@
"Pinned": "Important",
"PinAttachment": "Mark important",
"UnPinAttachment": "Mark less important",
"FilterAttachments": "Attachments"
"FilterAttachments": "Attachments",
"RemovedAttachment": "Removed attachment"
}
}

View File

@ -50,6 +50,7 @@
"Pinned": "Важное",
"PinAttachment": "Пометить как важное",
"UnPinAttachment": "Убрать пометку важное",
"FilterAttachments": "Вложения"
"FilterAttachments": "Вложения",
"RemovedAttachment": "Удалил(а) вложение"
}
}

View File

@ -0,0 +1,23 @@
<!--
// Copyright © 2023 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 type { Attachment } from '@hcengineering/attachment'
export let value: Attachment
</script>
<div class="flex-row-center">
{value.name}
</div>

View File

@ -14,11 +14,18 @@
-->
<script lang="ts">
import type { Attachment } from '@hcengineering/attachment'
import type { TxCreateDoc } from '@hcengineering/core'
import { TxProcessor } from '@hcengineering/core'
import core, { TxCUD, TxCreateDoc, TxProcessor } from '@hcengineering/core'
import AttachmentPresenter from '../AttachmentPresenter.svelte'
import RemovedAttachmentPresenter from '../RemovedAttachmentPresenter.svelte'
export let tx: TxCreateDoc<Attachment>
export let tx: TxCUD<Attachment>
export let value: any
const doc = tx._class === core.class.TxCreateDoc ? TxProcessor.createDoc2Doc(tx as TxCreateDoc<Attachment>) : value
</script>
<AttachmentPresenter value={TxProcessor.createDoc2Doc(tx)} />
{#if tx._class === core.class.TxRemoveDoc}
<RemovedAttachmentPresenter value={doc} />
{:else}
<AttachmentPresenter value={doc} />
{/if}

View File

@ -1,12 +1,12 @@
<script lang="ts">
import chunter from '@hcengineering/chunter'
import { Class, Doc, Ref, RelatedDocument, WithLookup } from '@hcengineering/core'
import { getResource, IntlString } from '@hcengineering/platform'
import { IntlString, getResource } from '@hcengineering/platform'
import { createQuery, getClient } from '@hcengineering/presentation'
import { Issue } from '@hcengineering/tracker'
import { Component, Icon, IconClose, showPanel } from '@hcengineering/ui'
import { Component, Icon, IconClose, navigate } from '@hcengineering/ui'
import view from '@hcengineering/view'
import { getIssueId, updateIssueRelation } from '../../issues'
import { getIssueId, issueLinkFragmentProvider, updateIssueRelation } from '../../issues'
import tracker from '../../plugin'
export let value: Issue
@ -72,7 +72,8 @@
}
async function handleRedirect (issue: Issue) {
showPanel(tracker.component.EditIssue, issue._id, issue._class, 'content')
const loc = await issueLinkFragmentProvider(issue)
navigate(loc)
}
const asIssue = (x: Doc) => x as WithLookup<Issue>