mirror of
https://github.com/hcengineering/platform.git
synced 2026-08-17 18:05:42 +02:00
Process minor fixes (#10704)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
@@ -16,17 +16,18 @@
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
|
||||
import { MasterTag, Tag } from '@hcengineering/card'
|
||||
import core, { Association, Data, Ref, generateId } from '@hcengineering/core'
|
||||
import core, { Data, generateId, Ref } from '@hcengineering/core'
|
||||
import { Card, getClient } from '@hcengineering/presentation'
|
||||
import setting from '@hcengineering/setting'
|
||||
import { EditBox, Label } from '@hcengineering/ui'
|
||||
import view, { MasterDetailConfig, Viewlet, ViewletDescriptor, ViewOptionsModel } from '@hcengineering/view'
|
||||
import setting from '@hcengineering/setting'
|
||||
|
||||
import DescriptorBox from './DescriptorBox.svelte'
|
||||
import ViewSettingButton from './ViewSettingButton.svelte'
|
||||
import { AttributeConfig, Config } from '@hcengineering/view-resources'
|
||||
import card from '../../../plugin'
|
||||
import DescriptorBox from './DescriptorBox.svelte'
|
||||
import { updateViewletConfig } from './utils'
|
||||
import ViewConfigSection from './ViewConfigSection.svelte'
|
||||
import ViewSettingButton from './ViewSettingButton.svelte'
|
||||
|
||||
export let tag: MasterTag | Tag
|
||||
|
||||
@@ -89,7 +90,7 @@
|
||||
views: viewConfigs
|
||||
}
|
||||
}
|
||||
function onConfigUpdate (items: any[]): void {
|
||||
function onConfigUpdate (items: (Config | AttributeConfig)[]): void {
|
||||
if (viewletConfig === undefined) return
|
||||
updateViewletConfig(viewletConfig, items)
|
||||
}
|
||||
|
||||
@@ -14,15 +14,16 @@
|
||||
-->
|
||||
<script lang="ts">
|
||||
import presentation, { getClient, MessageBox } from '@hcengineering/presentation'
|
||||
import setting from '@hcengineering/setting'
|
||||
import { clearSettingsStore } from '@hcengineering/setting-resources'
|
||||
import { Button, IconDelete, Label, Modal, ModernEditbox, showPopup } from '@hcengineering/ui'
|
||||
import view, { Viewlet } from '@hcengineering/view'
|
||||
import { clearSettingsStore } from '@hcengineering/setting-resources'
|
||||
import setting from '@hcengineering/setting'
|
||||
|
||||
import DescriptorBox from './DescriptorBox.svelte'
|
||||
import ViewSettingButton from './ViewSettingButton.svelte'
|
||||
import { AttributeConfig, Config } from '@hcengineering/view-resources'
|
||||
import card from '../../../plugin'
|
||||
import DescriptorBox from './DescriptorBox.svelte'
|
||||
import { updateViewletConfig } from './utils'
|
||||
import ViewSettingButton from './ViewSettingButton.svelte'
|
||||
|
||||
export let viewlet: Viewlet
|
||||
|
||||
@@ -54,7 +55,7 @@
|
||||
}
|
||||
})
|
||||
}
|
||||
function onSave (items: any[]): void {
|
||||
function onSave (items: (Config | AttributeConfig)[]): void {
|
||||
updateViewletConfig(viewlet, items)
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -15,12 +15,13 @@
|
||||
<script lang="ts">
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
|
||||
import { ButtonIcon, showPopup, closeTooltip } from '@hcengineering/ui'
|
||||
import { ButtonIcon, closeTooltip, showPopup } from '@hcengineering/ui'
|
||||
import view, { Viewlet } from '@hcengineering/view'
|
||||
|
||||
import { Data } from '@hcengineering/core'
|
||||
import { AttributeConfig, Config } from '@hcengineering/view-resources'
|
||||
import ViewOptionsButton from './ViewOptionsButton.svelte'
|
||||
import ViewletSetting from './ViewSetting.svelte'
|
||||
import { Data } from '@hcengineering/core'
|
||||
|
||||
export let kind: 'primary' | 'secondary' | 'tertiary' | 'negative' = 'secondary'
|
||||
export let viewlet: Data<Viewlet> | undefined = undefined
|
||||
@@ -41,7 +42,7 @@
|
||||
() => {
|
||||
pressed = false
|
||||
},
|
||||
(result) => {
|
||||
(result: (Config | AttributeConfig)[]) => {
|
||||
dispatch('save', result)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { type Data } from '@hcengineering/core'
|
||||
import { type Viewlet } from '@hcengineering/view'
|
||||
import { type AttributeConfig, type Config, isAttribute } from '@hcengineering/view-resources'
|
||||
|
||||
export function updateViewletConfig (viewlet: Data<Viewlet> | Viewlet, items: any[]): void {
|
||||
const enabledAttributes = items.filter((it) => it.type === 'attribute' && it.enabled).map((it) => it.value)
|
||||
|
||||
export function updateViewletConfig (viewlet: Data<Viewlet> | Viewlet, items: Array<Config | AttributeConfig>): void {
|
||||
const getKey = (item: any): string | undefined => {
|
||||
return typeof item === 'string' ? item : item?.key
|
||||
}
|
||||
@@ -18,14 +17,11 @@ export function updateViewletConfig (viewlet: Data<Viewlet> | Viewlet, items: an
|
||||
return true
|
||||
}
|
||||
|
||||
viewlet.config = viewlet.config.filter((configItem) => {
|
||||
if (configItem === undefined) return false
|
||||
return enabledAttributes.some((attr) => isMatch(configItem, attr))
|
||||
})
|
||||
|
||||
const newAttributes = enabledAttributes.filter((attr) => {
|
||||
return !viewlet.config.some((configItem) => isMatch(configItem, attr))
|
||||
})
|
||||
|
||||
viewlet.config = viewlet.config.concat(newAttributes)
|
||||
viewlet.config = items
|
||||
.filter((it) => (isAttribute(it) && it.enabled) || it.type === 'divider')
|
||||
.map((it) => {
|
||||
const existing = viewlet.config.find((configItem) => isMatch(configItem, it.value))
|
||||
return existing ?? it.value
|
||||
})
|
||||
.filter((it) => it !== undefined)
|
||||
}
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
dispatch('close', { value: values })
|
||||
}
|
||||
|
||||
$: canSaveValue = inputs.every((input) => values[input.id] != null)
|
||||
|
||||
export function canClose (): boolean {
|
||||
return false
|
||||
}
|
||||
@@ -48,8 +50,9 @@
|
||||
on:close
|
||||
width={'small'}
|
||||
label={plugin.string.EnterValue}
|
||||
canSave
|
||||
canSave={canSaveValue}
|
||||
okAction={save}
|
||||
hideClose
|
||||
okLabel={presentation.string.Save}
|
||||
>
|
||||
{#if processVal !== undefined}
|
||||
@@ -67,8 +70,10 @@
|
||||
key={input.key}
|
||||
_class={input._class}
|
||||
{space}
|
||||
value={values[input.id]}
|
||||
on:change={(e) => {
|
||||
values[input.id] = e.detail
|
||||
values = values
|
||||
}}
|
||||
/>
|
||||
{/each}
|
||||
|
||||
@@ -547,7 +547,7 @@ export async function getTransitionUserInput (
|
||||
}
|
||||
}
|
||||
if (inputs.length > 0) {
|
||||
const promise = new Promise<void>((resolve) => {
|
||||
const promise = new Promise<void>((resolve, reject) => {
|
||||
showPopup(
|
||||
process.component.RequestUserInput,
|
||||
{
|
||||
@@ -559,13 +559,16 @@ export async function getTransitionUserInput (
|
||||
},
|
||||
undefined,
|
||||
(res) => {
|
||||
if (res?.value !== undefined) {
|
||||
const isComplete = res?.value !== undefined && inputs.every((input) => res.value[input.id] != null)
|
||||
if (isComplete) {
|
||||
changed = true
|
||||
for (const [key, value] of Object.entries(res.value)) {
|
||||
userContext[key as ContextId] = value
|
||||
}
|
||||
resolve()
|
||||
} else {
|
||||
reject(new PlatformError(new Status(Severity.ERROR, process.error.ResultNotProvided, {})))
|
||||
}
|
||||
resolve()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
@@ -13,36 +13,17 @@
|
||||
// limitations under the License.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { Class, Doc, Ref } from '@hcengineering/core'
|
||||
import { Asset, IntlString } from '@hcengineering/platform'
|
||||
import { Button, ToggleWithLabel } from '@hcengineering/ui'
|
||||
import { BuildModelKey, Viewlet } from '@hcengineering/view'
|
||||
import { Viewlet } from '@hcengineering/view'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import view from '../plugin'
|
||||
import { AttributeConfig, Config, isAttribute } from '../viewOptions'
|
||||
|
||||
export let viewlet: Viewlet
|
||||
export let items: Array<Config | AttributeConfig> = []
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
|
||||
interface Config {
|
||||
value: string | BuildModelKey | undefined
|
||||
type: 'divider' | 'attribute'
|
||||
}
|
||||
|
||||
interface AttributeConfig extends Config {
|
||||
type: 'attribute'
|
||||
enabled: boolean
|
||||
label: IntlString
|
||||
_class: Ref<Class<Doc>>
|
||||
icon: Asset | undefined
|
||||
order?: number
|
||||
}
|
||||
|
||||
function isAttribute (val: Config): val is AttributeConfig {
|
||||
return val.type === 'attribute'
|
||||
}
|
||||
|
||||
function dragEnd () {
|
||||
selected = undefined
|
||||
dispatch('save', items)
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
SortingOrder,
|
||||
type Space
|
||||
} from '@hcengineering/core'
|
||||
import { getResource } from '@hcengineering/platform'
|
||||
import { type Asset, getResource, type IntlString } from '@hcengineering/platform'
|
||||
import { type LiveQuery, createQuery, getAttributePresenterClass, getClient } from '@hcengineering/presentation'
|
||||
import { locationToUrl, getCurrentResolvedLocation } from '@hcengineering/ui'
|
||||
import {
|
||||
@@ -20,7 +20,8 @@ import {
|
||||
type ViewOptionModel,
|
||||
type ViewOptions,
|
||||
type Viewlet,
|
||||
type ViewletDescriptor
|
||||
type ViewletDescriptor,
|
||||
type BuildModelKey
|
||||
} from '@hcengineering/view'
|
||||
import { get, writable } from 'svelte/store'
|
||||
import view from './plugin'
|
||||
@@ -235,3 +236,21 @@ export async function getResultQuery (
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
export interface Config {
|
||||
value: string | BuildModelKey | undefined
|
||||
type: 'divider' | 'attribute'
|
||||
}
|
||||
|
||||
export interface AttributeConfig extends Config {
|
||||
type: 'attribute'
|
||||
enabled: boolean
|
||||
label: IntlString
|
||||
_class: Ref<Class<Doc>>
|
||||
icon: Asset | undefined
|
||||
order?: number
|
||||
}
|
||||
|
||||
export function isAttribute (val: Config): val is AttributeConfig {
|
||||
return val.type === 'attribute'
|
||||
}
|
||||
|
||||
@@ -738,7 +738,7 @@ export async function CancelToDo (
|
||||
if (params._id === undefined) throw processError(process.error.RequiredParamsNotProvided, { params: '_id' })
|
||||
const todo = await control.client.findOne(process.class.ProcessToDo, { _id: params._id as any })
|
||||
if (todo === undefined) return { txes: [], rollback: [], context: null }
|
||||
if (todo.doneOn !== null) throw processError(process.error.ToDoAlreadyCompleted, { _id: params._id })
|
||||
if (todo.doneOn !== null) return { txes: [], rollback: [], context: null }
|
||||
const res: Tx[] = [control.client.txFactory.createTxRemoveDoc(todo._class, todo.space, todo._id)]
|
||||
const rollback: Tx[] = [
|
||||
control.client.txFactory.createTxCreateDoc(
|
||||
|
||||
Reference in New Issue
Block a user