mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-29 13:05:08 +02:00
context value dsl (#10023)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
<script lang="ts">
|
||||
import { MasterTag, Tag } from '@hcengineering/card'
|
||||
import { AnyAttribute, Class, Doc, Ref } from '@hcengineering/core'
|
||||
import { Context, parseContext, Process, SelectedContext } from '@hcengineering/process'
|
||||
import { Context, createDSLContext, parseContext, Process, SelectedContext } from '@hcengineering/process'
|
||||
import {
|
||||
AnySvelteComponent,
|
||||
Button,
|
||||
@@ -69,7 +69,15 @@
|
||||
}
|
||||
|
||||
function onSelect (res: SelectedContext | null): void {
|
||||
value = res === null ? undefined : '$' + JSON.stringify(res)
|
||||
if (res === null) {
|
||||
value = undefined
|
||||
} else {
|
||||
try {
|
||||
value = createDSLContext(res)
|
||||
} catch {
|
||||
value = '$' + JSON.stringify(res)
|
||||
}
|
||||
}
|
||||
dispatch('change', value)
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { AnyAttribute, Class, Doc, DocumentQuery, Ref } from '@hcengineering/core'
|
||||
import core, { AnyAttribute, Class, Doc, DocumentQuery, Ref } from '@hcengineering/core'
|
||||
import { getClient } from '@hcengineering/presentation'
|
||||
import { Context, Func, Process, ProcessFunction, SelectedContext } from '@hcengineering/process'
|
||||
import {
|
||||
@@ -64,11 +64,22 @@
|
||||
}
|
||||
}
|
||||
|
||||
const reduceFuncs = client
|
||||
.getModel()
|
||||
.findAllSync(plugin.class.ProcessFunction, { type: 'reduce' })
|
||||
.filter((p) => p.category === undefined || (allowArray && p.category === 'array'))
|
||||
.map((it) => it._id)
|
||||
function getReduceFunctions (): Ref<ProcessFunction>[] {
|
||||
const model = client.getModel()
|
||||
const h = client.getHierarchy()
|
||||
const res: Ref<ProcessFunction>[] = []
|
||||
const all = model.findAllSync(plugin.class.ProcessFunction, { type: 'reduce' })
|
||||
for (const f of all) {
|
||||
if (f.category === undefined || (allowArray && f.category === 'array')) {
|
||||
if (f.of === core.class.ArrOf || h.isDerived(f.of, attrClass)) {
|
||||
res.push(f._id)
|
||||
}
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
const reduceFuncs = getReduceFunctions()
|
||||
|
||||
$: availableFunctions = getAvailableFunctions(contextValue.functions, attrClass, category)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user