Skip to content

Commit

Permalink
HR: Issue fixes (#1891)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
  • Loading branch information
haiodo authored May 28, 2022
1 parent 9f9003e commit a2858c8
Show file tree
Hide file tree
Showing 23 changed files with 285 additions and 48 deletions.
3 changes: 2 additions & 1 deletion models/attachment/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@anticrm/model-core": "~0.6.0",
"@anticrm/model-view": "~0.6.0",
"@anticrm/activity": "~0.6.0",
"@anticrm/model-preference": "~0.6.0"
"@anticrm/model-preference": "~0.6.0",
"@anticrm/view": "~0.6.0"
}
}
68 changes: 66 additions & 2 deletions models/attachment/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
import activity from '@anticrm/activity'
import type { Attachment, Photo, SavedAttachments } from '@anticrm/attachment'
import { Domain, IndexKind, Ref } from '@anticrm/core'
import { Builder, Index, Model, Prop, TypeRef, TypeString, TypeTimestamp, UX } from '@anticrm/model'
import { Builder, Index, Model, Prop, TypeBoolean, TypeRef, TypeString, TypeTimestamp, UX } from '@anticrm/model'
import core, { TAttachedDoc } from '@anticrm/model-core'
import view from '@anticrm/model-view'
import preference, { TPreference } from '@anticrm/model-preference'
import view, { createAction } from '@anticrm/model-view'
import attachment from './plugin'

export { attachmentOperation } from './migration'
Expand All @@ -45,6 +45,12 @@ export class TAttachment extends TAttachedDoc implements Attachment {

@Prop(TypeTimestamp(), attachment.string.Date)
lastModified!: number

@Prop(TypeString(), attachment.string.Description)
description!: string

@Prop(TypeBoolean(), attachment.string.Pinned)
pinned!: boolean
}

@Model(attachment.class.Photo, attachment.class.Attachment)
Expand Down Expand Up @@ -89,6 +95,64 @@ export function createModel (builder: Builder): void {
},
attachment.ids.TxAttachmentCreate
)

builder.createDoc(
view.class.ActionCategory,
core.space.Model,
{ label: attachment.string.Attachments, visible: true },
attachment.category.Attachments
)

createAction(builder, {
action: view.actionImpl.ShowEditor,
actionProps: {
attribute: 'description'
},
label: attachment.string.Description,
icon: view.icon.Open,
input: 'focus',
category: attachment.category.Attachments,
target: attachment.class.Attachment,
context: {
mode: ['context', 'browser']
}
})

createAction(builder, {
action: view.actionImpl.UpdateDocument,
actionProps: {
key: 'pinned',
value: true
},
query: {
pinned: { $in: [false, undefined, null] }
},
label: attachment.string.PinAttachment,
input: 'focus',
category: attachment.category.Attachments,
target: attachment.class.Attachment,
context: {
mode: ['context', 'browser']
}
})

createAction(builder, {
action: view.actionImpl.UpdateDocument,
actionProps: {
key: 'pinned',
value: false
},
query: {
pinned: true
},
label: attachment.string.UnPinAttachment,
input: 'focus',
category: attachment.category.Attachments,
target: attachment.class.Attachment,
context: {
mode: ['context', 'browser']
}
})
}

export default attachment
13 changes: 10 additions & 3 deletions models/attachment/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
// limitations under the License.
//

import type { TxViewlet } from '@anticrm/activity'
import { attachmentId } from '@anticrm/attachment'
import attachment from '@anticrm/attachment-resources/src/plugin'
import type { Ref } from '@anticrm/core'
import type { IntlString } from '@anticrm/platform'
import { mergeIds } from '@anticrm/platform'
import type { Ref } from '@anticrm/core'
import type { AnyComponent } from '@anticrm/ui'
import type { TxViewlet } from '@anticrm/activity'
import type { ActionCategory } from '@anticrm/view'

export default mergeIds(attachmentId, attachment, {
component: {
Expand All @@ -34,12 +35,18 @@ export default mergeIds(attachmentId, attachment, {
Type: '' as IntlString,
Photo: '' as IntlString,
Date: '' as IntlString,
SavedAttachments: '' as IntlString
SavedAttachments: '' as IntlString,
Description: '' as IntlString,
PinAttachment: '' as IntlString,
UnPinAttachment: '' as IntlString
},
ids: {
TxAttachmentCreate: '' as Ref<TxViewlet>
},
activity: {
TxAttachmentCreate: '' as AnyComponent
},
category: {
Attachments: '' as Ref<ActionCategory>
}
})
14 changes: 14 additions & 0 deletions models/recruit/src/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,20 @@ async function createDefaults (tx: TxOperations): Promise<void> {
await createSequence(tx, recruit.class.Opinion)
await createSequence(tx, recruit.class.Applicant)
await createDefaultKanbanTemplate(tx)

await createOrUpdate(
tx,
tags.class.TagCategory,
tags.space.Tags,
{
icon: tags.icon.Tags,
label: 'Text Label',
targetClass: recruit.class.Applicant,
tags: [],
default: true
},
recruit.category.OtherLabel
)
}

async function createDefaultKanbanTemplate (tx: TxOperations): Promise<Ref<KanbanTemplate>> {
Expand Down
14 changes: 11 additions & 3 deletions models/view/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,16 @@ export function classPresenter (
builder: Builder,
_class: Ref<Class<Doc>>,
presenter: AnyComponent,
editor?: AnyComponent
editor?: AnyComponent,
popup?: AnyComponent
): void {
builder.mixin(_class, core.class.Class, view.mixin.AttributePresenter, {
presenter
})
if (editor !== undefined) {
builder.mixin(_class, core.class.Class, view.mixin.AttributeEditor, {
editor
editor,
popup
})
}
}
Expand Down Expand Up @@ -267,7 +269,13 @@ export function createModel (builder: Builder): void {
TLinkPresenter
)

classPresenter(builder, core.class.TypeString, view.component.StringPresenter, view.component.StringEditor)
classPresenter(
builder,
core.class.TypeString,
view.component.StringPresenter,
view.component.StringEditor,
view.component.StringEditorPopup
)
classPresenter(builder, core.class.TypeIntlString, view.component.IntlStringPresenter)
classPresenter(builder, core.class.TypeNumber, view.component.NumberPresenter, view.component.NumberEditor)
classPresenter(builder, core.class.TypeMarkup, view.component.HTMLPresenter)
Expand Down
1 change: 1 addition & 0 deletions models/view/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export default mergeIds(viewId, view, {
ValueFilter: '' as AnyComponent,
TimestampFilter: '' as AnyComponent,
StringEditor: '' as AnyComponent,
StringEditorPopup: '' as AnyComponent,
StringPresenter: '' as AnyComponent,
IntlStringPresenter: '' as AnyComponent,
NumberEditor: '' as AnyComponent,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/predicate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const predicates: Record<string, PredicateFactory> = {
$lte: (o, propertyKey) => {
return (docs) => execPredicate(docs, propertyKey, (value) => value <= o)
},
$exist: (o, propertyKey) => {
$exists: (o, propertyKey) => {
return (docs) => execPredicate(docs, propertyKey, (value) => (value !== undefined) === o)
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export type QuerySelector<T> = {
$gte?: T extends number ? number : never
$lt?: T extends number ? number : never
$lte?: T extends number ? number : never
$exist?: boolean
$exists?: boolean
$like?: string
$regex?: string
$options?: string
Expand Down
6 changes: 5 additions & 1 deletion plugins/attachment-assets/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
"FileBrowserTypeFilterPDFs": "PDFs",
"AddAttachmentToSaved": "Add attachment to saved",
"RemoveAttachmentFromSaved": "Remove attachment from saved",
"DeleteFile": "Delete file"
"DeleteFile": "Delete file",
"Description": "Description",
"Pinned": "Important",
"PinAttachment": "Mark important",
"UnPinAttachment": "Mark less important"
}
}
6 changes: 5 additions & 1 deletion plugins/attachment-assets/lang/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
"FileBrowserTypeFilterPDFs": "PDF-файлы",
"AddAttachmentToSaved": "Добавить вложение в сохраненные",
"RemoveAttachmentFromSaved": "Удалить вложение из сохраненных",
"DeleteFile": "Удалить файл"
"DeleteFile": "Удалить файл",
"Description": "Описание",
"Pinned": "Важное",
"PinAttachment": "Пометить как важное",
"UnPinAttachment": "Убрать пометку важное"
}
}
17 changes: 13 additions & 4 deletions plugins/attachment-resources/src/components/Attachments.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@
-->
<script lang="ts">
import { Class, Doc, Ref, Space } from '@anticrm/core'
import { Label, Spinner } from '@anticrm/ui'
import view from '@anticrm/view'
import { Table } from '@anticrm/view-resources'
import attachment from '../plugin'
import AddAttachment from './AddAttachment.svelte'
import AttachmentDroppable from './AttachmentDroppable.svelte'
import UploadDuo from './icons/UploadDuo.svelte'
export let objectId: Ref<Doc>
Expand Down Expand Up @@ -62,8 +61,18 @@
{:else}
<Table
_class={attachment.class.Attachment}
config={['', 'lastModified']}
options={{}}
config={[
'',
'description',
{
key: 'pinned',
presenter: view.component.BooleanTruePresenter,
label: attachment.string.Pinned,
sortingKey: 'pinned'
},
'lastModified'
]}
options={{ sort: { pinned: -1 } }}
query={{ attachedTo: objectId }}
loadingProps={{ length: attachments ?? 0 }}
/>
Expand Down
22 changes: 11 additions & 11 deletions plugins/attachment-resources/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@
// limitations under the License.
//

import attachment, { Attachment } from '@anticrm/attachment'
import { ObjQueryType, SortingOrder, SortingQuery } from '@anticrm/core'
import { IntlString, Resources } from '@anticrm/platform'
import preference from '@anticrm/preference'
import { getClient } from '@anticrm/presentation'
import TxAttachmentCreate from './components/activity/TxAttachmentCreate.svelte'
import AddAttachment from './components/AddAttachment.svelte'
import AttachmentDocList from './components/AttachmentDocList.svelte'
import AttachmentDroppable from './components/AttachmentDroppable.svelte'
import AttachmentsPresenter from './components/AttachmentsPresenter.svelte'
import AttachmentPresenter from './components/AttachmentPresenter.svelte'
import AttachmentGalleryPresenter from './components/AttachmentGalleryPresenter.svelte'
import AttachmentDocList from './components/AttachmentDocList.svelte'
import AttachmentList from './components/AttachmentList.svelte'
import AttachmentPresenter from './components/AttachmentPresenter.svelte'
import AttachmentRefInput from './components/AttachmentRefInput.svelte'
import TxAttachmentCreate from './components/activity/TxAttachmentCreate.svelte'
import Attachments from './components/Attachments.svelte'
import AttachmentsPresenter from './components/AttachmentsPresenter.svelte'
import FileBrowser from './components/FileBrowser.svelte'
import Photos from './components/Photos.svelte'
import FileDownload from './components/icons/FileDownload.svelte'
import { uploadFile, deleteFile } from './utils'
import attachment, { Attachment } from '@anticrm/attachment'
import { ObjQueryType, SortingOrder, SortingQuery } from '@anticrm/core'
import { IntlString, Resources } from '@anticrm/platform'
import preference from '@anticrm/preference'
import { getClient } from '@anticrm/presentation'
import Photos from './components/Photos.svelte'
import { deleteFile, uploadFile } from './utils'

export {
AddAttachment,
Expand Down
8 changes: 4 additions & 4 deletions plugins/attachment-resources/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
// limitations under the License.
//

import { mergeIds } from '@anticrm/platform'
import type { IntlString } from '@anticrm/platform'

import attachment, { attachmentId } from '@anticrm/attachment'
import type { IntlString } from '@anticrm/platform'
import { mergeIds } from '@anticrm/platform'
import { ViewAction } from '@anticrm/view'

export default mergeIds(attachmentId, attachment, {
Expand All @@ -42,7 +41,8 @@ export default mergeIds(attachmentId, attachment, {
FileBrowserSortSmallest: '' as IntlString,
FileBrowserSortBiggest: '' as IntlString,
AddAttachmentToSaved: '' as IntlString,
RemoveAttachmentFromSaved: '' as IntlString
RemoveAttachmentFromSaved: '' as IntlString,
Pinned: '' as IntlString
},
actionImpl: {
AddAttachmentToSaved: '' as ViewAction,
Expand Down
2 changes: 2 additions & 0 deletions plugins/attachment/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export interface Attachment extends AttachedDoc {
size: number
type: string
lastModified: number
description?: string
pinned?: boolean // If defined and true, will be shown in top of attachments collection
}

/**
Expand Down
3 changes: 2 additions & 1 deletion plugins/recruit-resources/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ export default mergeIds(recruitId, recruit, {
},
category: {
Other: '' as Ref<TagCategory>,
Category: '' as Ref<TagCategory>
Category: '' as Ref<TagCategory>,
OtherLabel: '' as Ref<TagCategory>
},
component: {
VacancyItemPresenter: '' as AnyComponent,
Expand Down
Loading

0 comments on commit a2858c8

Please sign in to comment.