Skip to content
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
1 change: 1 addition & 0 deletions foundations/core/packages/core/src/memdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ export abstract class MemDb extends TxProcessor implements Storage {
// We need to filter instances without mixin was set
result = result.filter((r) => (r as any)[_class] !== undefined)
}
if (options?.sort !== undefined) resultSort(result, options?.sort, _class, this.hierarchy, this)
const total = result.length
result = result.slice(0, options?.limit)

Expand Down
21 changes: 20 additions & 1 deletion models/process/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import presentation from '@hcengineering/model-presentation'
import { TToDo } from '@hcengineering/model-time'
import view, { createAction } from '@hcengineering/model-view'
import workbench from '@hcengineering/model-workbench'
import notification from '@hcengineering/notification'
import notification, { type NotificationGroup } from '@hcengineering/notification'
import { type Asset, type IntlString, type Resource } from '@hcengineering/platform'
import {
type ApproveRequest,
Expand Down Expand Up @@ -727,6 +727,25 @@ export function createModel (builder: Builder): void {
component: process.component.ProcessesSettingSection
})

builder.createDoc(notification.class.NotificationType, core.space.Model, {
hidden: false,
generated: false,
allowedForAuthor: true,
label: process.string.NewProcessToDo,
group: time.ids.TimeNotificationGroup as Ref<NotificationGroup>,
txClasses: [core.class.TxCreateDoc],
objectClass: process.class.ProcessToDo,
txMatch: {
objectClass: process.class.ProcessToDo
},
defaultEnabled: true,
templates: {
textTemplate: '{body}',
htmlTemplate: '<p>{body}</p>',
subjectTemplate: '{title}'
}
})

// builder.createDoc(presentation.class.ComponentPointExtension, core.space.Model, {
// extension: workbench.extensions.WorkbenchExtensions,
// component: process.component.NotifierExtension
Expand Down
4 changes: 3 additions & 1 deletion plugins/process-assets/lang/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@
"Approvers": "Schvalovatelé",
"UnlockCard": "Odemknout kartu",
"UnlockSection": "Odemknout sekci",
"CancelToDo": "Zrušit akční položku"
"CancelToDo": "Zrušit akční položku",
"Export": "Exportovat",
"Import": "Importovat"
},
"error": {
"MethodNotFound": "Metoda nenalezena: {methodId}",
Expand Down
4 changes: 3 additions & 1 deletion plugins/process-assets/lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@
"Approvers": "Genehmiger",
"UnlockCard": "Karte entsperren",
"UnlockSection": "Abschnitt entsperren",
"CancelToDo": "Action Item abbrechen"
"CancelToDo": "Action Item abbrechen",
"Export": "Exportieren",
"Import": "Importieren"
},
"error": {
"MethodNotFound": "Methode nicht gefunden: {methodId}",
Expand Down
4 changes: 3 additions & 1 deletion plugins/process-assets/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@
"Approvers": "Approvers",
"UnlockCard": "Unlock card",
"UnlockSection": "Unlock section",
"CancelToDo": "Cancel Action item"
"CancelToDo": "Cancel Action item",
"Export": "Export",
"Import": "Import"
},
"error": {
"MethodNotFound": "Method not found: {methodId}",
Expand Down
4 changes: 3 additions & 1 deletion plugins/process-assets/lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@
"Approvers": "Aprobadores",
"UnlockCard": "Desbloquear tarjeta",
"UnlockSection": "Desbloquear sección",
"CancelToDo": "Cancelar acción"
"CancelToDo": "Cancelar acción",
"Export": "Exportar",
"Import": "Importar"
},
"error": {
"MethodNotFound": "Método no encontrado: {methodId}",
Expand Down
4 changes: 3 additions & 1 deletion plugins/process-assets/lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@
"Approvers": "Approbateurs",
"UnlockCard": "Déverrouiller la carte",
"UnlockSection": "Déverrouiller la section",
"CancelToDo": "Annuler l'action"
"CancelToDo": "Annuler l'action",
"Export": "Exporter",
"Import": "Importer"
},
"error": {
"MethodNotFound": "Méthode introuvable : {methodId}",
Expand Down
4 changes: 3 additions & 1 deletion plugins/process-assets/lang/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@
"Approvers": "Approvatori",
"UnlockCard": "Sblocca scheda",
"UnlockSection": "Sblocca sezione",
"CancelToDo": "Annulla azione"
"CancelToDo": "Annulla azione",
"Export": "Esporta",
"Import": "Importa"
},
"error": {
"MethodNotFound": "Metodo non trovato: {methodId}",
Expand Down
4 changes: 3 additions & 1 deletion plugins/process-assets/lang/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@
"Approvers": "承認者",
"UnlockCard": "カードのロックを解除",
"UnlockSection": "セクションのロックを解除",
"CancelToDo": "アクションをキャンセル"
"CancelToDo": "アクションをキャンセル",
"Export": "エクスポート",
"Import": "インポート"
},
"error": {
"MethodNotFound": "メソッドが見つかりません: {methodId}",
Expand Down
4 changes: 3 additions & 1 deletion plugins/process-assets/lang/pt-br.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@
"FieldIsEmpty": "Campo vazio",
"UnlockCard": "Desbloquear cartão",
"UnlockSection": "Desbloquear seção",
"CancelToDo": "Cancelar ação"
"CancelToDo": "Cancelar ação",
"Export": "Exportar",
"Import": "Importar"
},
"error": {
"MethodNotFound": "Método não encontrado: {methodId}",
Expand Down
4 changes: 3 additions & 1 deletion plugins/process-assets/lang/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@
"Approvers": "Aprovadores",
"UnlockCard": "Desbloquear cartão",
"UnlockSection": "Desbloquear seção",
"CancelToDo": "Cancelar ação"
"CancelToDo": "Cancelar ação",
"Export": "Exportar",
"Import": "Importar"
},
"error": {
"MethodNotFound": "Método não encontrado: {methodId}",
Expand Down
4 changes: 3 additions & 1 deletion plugins/process-assets/lang/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@
"Approvers": "Утверждающие",
"UnlockCard": "Разблокировать карточку",
"UnlockSection": "Разблокировать секцию",
"CancelToDo": "Отменить задачу"
"CancelToDo": "Отменить задачу",
"Export": "Экспорт",
"Import": "Импорт"
},
"error": {
"MethodNotFound": "Метод не найден: {methodId}",
Expand Down
4 changes: 3 additions & 1 deletion plugins/process-assets/lang/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@
"Approvers": "Onaylayanlar",
"UnlockCard": "Kartın kilidini aç",
"UnlockSection": "Bölümün kilidini aç",
"CancelToDo": "Eylem öğesini iptal et"
"CancelToDo": "Eylem öğesini iptal et",
"Export": "Dışa aktar",
"Import": "İçe aktar"
},
"error": {
"MethodNotFound": "Metod bulunamadı: {methodId}",
Expand Down
4 changes: 3 additions & 1 deletion plugins/process-assets/lang/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@
"Approvers": "批准人",
"UnlockCard": "解锁卡片",
"UnlockSection": "解锁部分",
"CancelToDo": "取消任务"
"CancelToDo": "取消任务",
"Export": "导出",
"Import": "导入"
},
"error": {
"MethodNotFound": "找不到方法:{methodId}",
Expand Down
28 changes: 26 additions & 2 deletions plugins/process-resources/src/components/ProcessesSection.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
import { translate } from '@hcengineering/platform'
import { createQuery, getClient } from '@hcengineering/presentation'
import { Process, State } from '@hcengineering/process'
import { ButtonIcon, getCurrentLocation, Icon, IconAdd, Label, navigate } from '@hcengineering/ui'
import { ButtonIcon, getCurrentLocation, Icon, IconAdd, IconFile, IconOpen, Label, navigate } from '@hcengineering/ui'
import process from '../plugin'
import { makeRank } from '@hcengineering/rank'
import { importProcess } from '../exporter'

export let masterTag: MasterTag

Expand Down Expand Up @@ -76,12 +77,35 @@
loc.path[6] = id
navigate(loc, true)
}

function handleImport (): void {
const input = document.createElement('input')
input.type = 'file'
input.accept = '.json'
input.onchange = async (evt) => {
const file = (evt.target as HTMLInputElement).files?.[0]
if (file != null) {
const text = await file.text()
await importProcess(masterTag._id, text)
}
}
input.click()
}
</script>

<div class="hulyTableAttr-header font-medium-12">
<Icon icon={process.icon.Process} size="small" />
<span><Label label={process.string.Processes} /></span>
<ButtonIcon kind="primary" icon={IconAdd} size="small" dataId={'btnAdd'} on:click={add} />
<div class="flex-row-center flex-gap-1">
<ButtonIcon
kind="primary"
icon={IconFile}
size="small"
tooltip={{ label: process.string.Import, direction: 'bottom' }}
on:click={handleImport}
/>
<ButtonIcon kind="primary" icon={IconAdd} size="small" dataId={'btnAdd'} on:click={add} />
</div>
</div>
{#if processes.length}
<div class="hulyTableAttr-content task">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
-->
<script lang="ts">
import { Ref, SortingOrder } from '@hcengineering/core'
import { createQuery, getClient, MessageBox } from '@hcengineering/presentation'
import { createQuery, getClient, MessageBox, IconDownload } from '@hcengineering/presentation'
import { Process, State, Transition } from '@hcengineering/process'
import { clearSettingsStore, settingsStore } from '@hcengineering/setting-resources'
import {
Expand All @@ -30,6 +30,7 @@
secondNavSeparators,
showPopup
} from '@hcengineering/ui'
import { exportProcess } from '../../exporter'
import view from '@hcengineering/view'
import { createEventDispatcher } from 'svelte'
import process from '../../plugin'
Expand Down Expand Up @@ -135,6 +136,24 @@
function handleSettings (): void {
showPopup(ProcesssSetting, { value })
}

function handleExport (): void {
if (value === undefined) return
const str = JSON.stringify(
exportProcess(value).docs.map((doc) => {
const { modifiedBy, modifiedOn, createdBy, createdOn, ...rest } = doc
return rest
})
)
const blob = new Blob([str], { type: 'application/json' })
const url = URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = `${value.name}.json`
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
}
</script>

<div class="hulyComponent-content__container columns">
Expand All @@ -153,6 +172,13 @@
/>
<div class="flex-row-center flex-gap-2">
<ButtonIcon icon={IconSettings} size="small" kind="secondary" on:click={handleSettings} />
<ButtonIcon
icon={IconDownload}
tooltip={{ label: process.string.Export, direction: 'bottom' }}
size="small"
kind="secondary"
on:click={handleExport}
/>
<ButtonIcon
icon={IconDetails}
tooltip={{ label: process.string.Data, direction: 'bottom' }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@
<script lang="ts">
import { Ref } from '@hcengineering/core'
import { getClient } from '@hcengineering/presentation'
import { Process, State } from '@hcengineering/process'
import { Process } from '@hcengineering/process'
import { DropdownLabels, Label } from '@hcengineering/ui'
import { createEventDispatcher } from 'svelte'
import plugin from '../../plugin'
import { ModeId, Modes } from '../../query'
import { getContext } from '../../utils'
import BaseCriteria from '../criterias/BaseCriteria.svelte'
import { ModeId } from '../../query'
import SubProcessStateCriteria from '../criterias/SubProcessStateCriteria.svelte'

export let readonly: boolean
Expand Down
49 changes: 43 additions & 6 deletions plugins/process-resources/src/exporter.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { type MasterTag } from '@hcengineering/card'
import { type Class, type Doc, type Ref } from '@hcengineering/core'
import core, { type Doc, type Ref, type Class, generateId } from '@hcengineering/core'
import { getClient } from '@hcengineering/presentation'
import process from './plugin'

export function exportProcess (_id: Ref<MasterTag>): {
export function exportProcesses (_id: Ref<MasterTag>): {
docs: Doc[]
required: Array<Ref<Class<Doc>>>
} {
Expand All @@ -12,11 +12,48 @@ export function exportProcess (_id: Ref<MasterTag>): {
const m = client.getModel()
const processes = m.findAllSync(process.class.Process, { masterTag: _id })
for (const proc of processes) {
docs.push(proc)
const res = exportProcess(proc)
docs.push(...res.docs)
}
return { docs, required: [] }
}

docs.push(...m.findAllSync(process.class.State, { process: proc._id }))
export function exportProcess (proc: Doc): {
docs: Doc[]
required: Array<Ref<Class<Doc>>>
} {
const docs: Doc[] = [proc]
const client = getClient()
const m = client.getModel()

docs.push(...m.findAllSync(process.class.State, { process: proc._id as any }))
docs.push(...m.findAllSync(process.class.Transition, { process: proc._id as any }))

docs.push(...m.findAllSync(process.class.Transition, { process: proc._id }))
}
return { docs, required: [] }
}

export async function importProcess (masterTag: Ref<MasterTag>, json: string): Promise<void> {
try {
const data = JSON.parse(json) as Doc[]
if (data[0] === undefined) return
const client = getClient()
const m = client.getModel()
const apply = client.apply('Import process')
;(data[0] as any).masterTag = masterTag
;(data[0] as any)._id = generateId()
for (const elem of data) {
if (m.findObject(elem._id) !== undefined) continue
await apply.createDoc(elem._class, core.space.Model, stripData(elem), elem._id)
}
await apply.commit(true)
} catch (e) {
console.error('Failed to import process:', e)
}
}

function stripData<T extends Doc> (
doc: T
): Omit<T, '_id' | '_class' | 'space' | 'modifiedBy' | 'modifiedOn' | 'createdBy' | 'createdOn'> {
const { _id, _class, space, modifiedBy, modifiedOn, createdBy, createdOn, ...rest } = doc
return rest
}
Loading
Loading