Fix recruit activity labels (#962)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2022-02-08 16:05:12 +07:00 committed by GitHub
parent 1ccccf5162
commit 16686010b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 13 deletions

View File

@ -3,6 +3,8 @@
"Delete": "Delete",
"Edit": "Edit",
"Options": "Options",
"Edited": "edited"
"Edited": "edited",
"DocCreated": "created {_class}",
"DocDeleted": "deleted {_class}"
}
}

View File

@ -141,7 +141,7 @@
{#if viewlet && viewlet?.editable}
<div class="edited">
{#if viewlet.label}
<Label label={viewlet.label} />
<Label label={viewlet.label} params={viewlet.labelParams ?? {}} />
{/if}
{#if tx.updated}
<Label label={activity.string.Edited} />
@ -152,7 +152,7 @@
</div>
{:else if viewlet && viewlet.label}
<div class='flex-center'>
<Label label={viewlet.label} />
<Label label={viewlet.label} params={viewlet.labelParams ?? {}} />
{#if viewlet.labelComponent}
<Component is={viewlet.labelComponent} {props} />
{/if}

View File

@ -1,14 +1,14 @@
import type { TxViewlet } from '@anticrm/activity'
import activity from '@anticrm/activity'
import activity from '../plugin'
import core, { Class, Doc, Ref, TxCUD, TxOperations } from '@anticrm/core'
import { Asset, IntlString } from '@anticrm/platform'
import { Asset, IntlString, translate } from '@anticrm/platform'
import { AnyComponent, AnySvelteComponent } from '@anticrm/ui'
import { AttributeModel } from '@anticrm/view'
import { buildModel, getObjectPresenter } from '@anticrm/view-resources'
import { ActivityKey, activityKey, DisplayTx } from '../activity'
export type TxDisplayViewlet =
| (Pick<TxViewlet, 'icon' | 'label' | 'display' | 'editable' | 'hideOnRemove' | 'labelComponent'> & {
| (Pick<TxViewlet, 'icon' | 'label' | 'display' | 'editable' | 'hideOnRemove' | 'labelComponent' | 'labelParams'> & {
component?: AnyComponent | AnySvelteComponent
})
| undefined
@ -16,7 +16,7 @@ export type TxDisplayViewlet =
async function createPseudoViewlet (
client: TxOperations,
dtx: DisplayTx,
label: string
label: IntlString
): Promise<TxDisplayViewlet> {
const doc = dtx.doc
if (doc === undefined) {
@ -24,12 +24,14 @@ async function createPseudoViewlet (
}
const docClass: Class<Doc> = client.getModel().getObject(doc._class)
const trLabel = await translate(docClass.label, {})
const presenter = await getObjectPresenter(client, doc._class, { key: 'doc-presenter' })
if (presenter !== undefined) {
return {
display: 'inline',
icon: docClass.icon ?? activity.icon.Activity,
label: (`${label} ` + docClass.label) as IntlString,
label: label,
labelParams: { _class: trLabel },
component: presenter.presenter
}
}
@ -76,10 +78,10 @@ async function checkInlineViewlets (
): Promise<{ viewlet: TxDisplayViewlet, model: AttributeModel[] }> {
if (dtx.tx._class === core.class.TxCreateDoc) {
// Check if we have a class presenter we could have a pseudo viewlet based on class presenter.
viewlet = await createPseudoViewlet(client, dtx, 'created')
viewlet = await createPseudoViewlet(client, dtx, activity.string.DocCreated)
}
if (dtx.tx._class === core.class.TxRemoveDoc) {
viewlet = await createPseudoViewlet(client, dtx, 'deleted')
viewlet = await createPseudoViewlet(client, dtx, activity.string.DocDeleted)
}
if (dtx.tx._class === core.class.TxUpdateDoc) {
model = await createUpdateModel(dtx, client, model)

View File

@ -13,12 +13,14 @@
// limitations under the License.
//
import chunter, { chunterId } from '@anticrm/chunter'
import activity, { activityId } from '@anticrm/activity'
import type { IntlString } from '@anticrm/platform'
import { mergeIds } from '@anticrm/platform'
export default mergeIds(chunterId, chunter, {
export default mergeIds(activityId, activity, {
string: {
Activity: '' as IntlString
Activity: '' as IntlString,
DocCreated: '' as IntlString,
DocDeleted: '' as IntlString
}
})

View File

@ -37,6 +37,7 @@ export interface TxViewlet extends Doc {
// Label will be displayed right after author
label?: IntlString
labelParams?: any
// Do component need to be emphasized or not.
display: 'inline' | 'content' | 'emphasized'