Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UBERF-5395: Have loading option for menu and show only intersecting statuses there #6185

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions plugins/task-resources/src/components/StatusSelector.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@
function updateStatuses (taskTypes: IdMap<TaskType>, store: IdMap<Status>, kind: Ref<TaskType> | undefined): void {
if (kind === undefined) {
statuses = []
if (Array.isArray(value)) {
const statusIds = value
.map((k) => taskTypes.get(k.kind))
.filter((p) => p !== undefined)
.map((t) => t?.statuses ?? [])
const intersectingStatuses = statusIds[0].filter((p) => statusIds.every((sArray) => sArray.includes(p)))
statuses = intersectingStatuses.map((s) => store.get(s)).filter((p) => p !== undefined) as Status[]
}
} else {
const type = taskTypes.get(kind)
if (type !== undefined) {
Expand Down
76 changes: 47 additions & 29 deletions plugins/view-resources/src/components/Menu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import { Class, Doc, Ref } from '@hcengineering/core'
import { Asset } from '@hcengineering/platform'
import { getClient } from '@hcengineering/presentation'
import { Action, Menu } from '@hcengineering/ui'
import { Action, Menu, Loading } from '@hcengineering/ui'
import { ActionGroup, ViewContextType } from '@hcengineering/view'
import { getActions, invokeAction } from '../actions'

Expand All @@ -42,39 +42,57 @@
remove: 7
}

void getActions(client, object, baseMenuClass, mode).then((result) => {
const filtered = result.filter((a) => {
if (excludedActions.includes(a._id)) {
return false
}
if (includedActions.length > 0 && !includedActions.includes(a._id)) {
return false
}
if (a.override && a.override.filter((o) => excludedActions.includes(o)).length > 0) {
return false
const findAllObjects = async (object: Doc | Doc[]) => {
const objArray = Array.isArray(object) ? object : [object]
const objClass = objArray.map((obj) => obj._class).filter((it, idx, arr) => arr.indexOf(it) === idx)
if (objClass.length === 1) {
const obj = (await client.findAll(objClass[0], { _id: { $in: objArray.map((it) => it._id) } })) as Array<Doc>
return obj.length === 1 ? obj[0] : obj
}
return object
}

void findAllObjects(object).then((res) => {
void getActions(client, res, baseMenuClass, mode).then((result) => {
const filtered = result.filter((a) => {
if (excludedActions.includes(a._id)) {
return false
}
if (includedActions.length > 0 && !includedActions.includes(a._id)) {
return false
}
if (a.override && a.override.filter((o) => excludedActions.includes(o)).length > 0) {
return false
}
return true
})
const newActions: Action[] = filtered.map((a) => ({
label: a.label,
icon: a.icon as Asset,
inline: a.inline,
group: a.context.group ?? 'other',
action: async (_: any, evt: Event) => {
invokeAction(object, evt, a)
},
component: a.actionPopup,
props: { ...a.actionProps, value: object }
}))
resActions = [...newActions, ...actions].sort(
(a, b) => (order as any)[a.group ?? 'other'] - (order as any)[b.group ?? 'other']
)
if (resActions.length > 0) {
loaded = true
}
return true
})
const newActions: Action[] = filtered.map((a) => ({
label: a.label,
icon: a.icon as Asset,
inline: a.inline,
group: a.context.group ?? 'other',
action: async (_: any, evt: Event) => {
invokeAction(object, evt, a)
},
component: a.actionPopup,
props: { ...a.actionProps, value: object }
}))
resActions = [...newActions, ...actions].sort(
(a, b) => (order as any)[a.group ?? 'other'] - (order as any)[b.group ?? 'other']
)
if (resActions.length > 0) {
loaded = true
}
})
</script>

{#if loaded}
<Menu actions={resActions} on:close on:changeContent />
{:else}
<div class="antiPopup">
<div class="min-w-28 min-h-12 flex-center">
<Loading />
</div>
</div>
{/if}
Loading