General fixes to app list group filtering
This commit is contained in:
parent
e44dd44fad
commit
ff29e8e7af
|
@ -61,6 +61,7 @@
|
||||||
const onPickPrimary = newValue => {
|
const onPickPrimary = newValue => {
|
||||||
dispatch("pickprimary", newValue)
|
dispatch("pickprimary", newValue)
|
||||||
primaryOpen = false
|
primaryOpen = false
|
||||||
|
dispatch("closed")
|
||||||
}
|
}
|
||||||
|
|
||||||
const onClearPrimary = () => {
|
const onClearPrimary = () => {
|
||||||
|
@ -92,6 +93,7 @@
|
||||||
if (primaryOpen) {
|
if (primaryOpen) {
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
primaryOpen = false
|
primaryOpen = false
|
||||||
|
dispatch("closed")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,5 +128,6 @@
|
||||||
on:blur
|
on:blur
|
||||||
on:focus
|
on:focus
|
||||||
on:keyup
|
on:keyup
|
||||||
|
on:closed
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
|
@ -5,9 +5,16 @@
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
|
let filter = null
|
||||||
|
$: filteredGroups = !filter
|
||||||
|
? $groups
|
||||||
|
: $groups.filter(group =>
|
||||||
|
group.name?.toLowerCase().includes(filter.toLowerCase())
|
||||||
|
)
|
||||||
|
|
||||||
$: optionSections = {
|
$: optionSections = {
|
||||||
groups: {
|
groups: {
|
||||||
data: $groups,
|
data: filteredGroups,
|
||||||
getLabel: group => group.name,
|
getLabel: group => group.name,
|
||||||
getValue: group => group._id,
|
getValue: group => group._id,
|
||||||
getIcon: group => group.icon,
|
getIcon: group => group.icon,
|
||||||
|
@ -15,21 +22,28 @@
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
$: appData = [{ id: "", role: "" }]
|
|
||||||
|
|
||||||
$: onChange = selected => {
|
$: onChange = selected => {
|
||||||
const { detail } = selected
|
const { detail } = selected
|
||||||
if (!detail) return
|
if (!detail || Object.keys(detail).length == 0) {
|
||||||
|
dispatch("change", null)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const groupSelected = $groups.find(x => x._id === detail)
|
const groupSelected = $groups.find(x => x._id === detail)
|
||||||
const appIds = groupSelected?.apps || null
|
const appRoleIds = groupSelected?.roles
|
||||||
dispatch("change", appIds)
|
? Object.keys(groupSelected?.roles)
|
||||||
|
: []
|
||||||
|
dispatch("change", appRoleIds)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<PickerDropdown
|
<PickerDropdown
|
||||||
autocomplete
|
autocomplete
|
||||||
|
bind:searchTerm={filter}
|
||||||
primaryOptions={optionSections}
|
primaryOptions={optionSections}
|
||||||
placeholder={"Filter by access"}
|
placeholder={"Filter by access"}
|
||||||
on:pickprimary={onChange}
|
on:pickprimary={onChange}
|
||||||
|
on:closed={() => {
|
||||||
|
filter = null
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -20,7 +20,14 @@
|
||||||
import { store, automationStore } from "builderStore"
|
import { store, automationStore } from "builderStore"
|
||||||
import { API } from "api"
|
import { API } from "api"
|
||||||
import { onMount } from "svelte"
|
import { onMount } from "svelte"
|
||||||
import { apps, auth, admin, templates, licensing } from "stores/portal"
|
import {
|
||||||
|
apps,
|
||||||
|
auth,
|
||||||
|
admin,
|
||||||
|
templates,
|
||||||
|
licensing,
|
||||||
|
groups,
|
||||||
|
} from "stores/portal"
|
||||||
import { goto } from "@roxi/routify"
|
import { goto } from "@roxi/routify"
|
||||||
import AppRow from "components/start/AppRow.svelte"
|
import AppRow from "components/start/AppRow.svelte"
|
||||||
import { AppStatus } from "constants"
|
import { AppStatus } from "constants"
|
||||||
|
@ -59,10 +66,15 @@
|
||||||
$: enrichedApps = enrichApps($apps, $auth.user, sortBy)
|
$: enrichedApps = enrichApps($apps, $auth.user, sortBy)
|
||||||
$: filteredApps = enrichedApps.filter(
|
$: filteredApps = enrichedApps.filter(
|
||||||
app =>
|
app =>
|
||||||
app?.name?.toLowerCase().includes(searchTerm.toLowerCase()) &&
|
(searchTerm
|
||||||
(accessFilterList !== null ? accessFilterList.includes(app?.appId) : true)
|
? app?.name?.toLowerCase().includes(searchTerm.toLowerCase())
|
||||||
|
: true) &&
|
||||||
|
(accessFilterList !== null
|
||||||
|
? accessFilterList?.includes(
|
||||||
|
`${app?.type}_${app?.tenantId}_${app?.appId}`
|
||||||
|
)
|
||||||
|
: true)
|
||||||
)
|
)
|
||||||
|
|
||||||
$: lockedApps = filteredApps.filter(app => app?.lockedYou || app?.lockedOther)
|
$: lockedApps = filteredApps.filter(app => app?.lockedYou || app?.lockedOther)
|
||||||
$: unlocked = lockedApps?.length === 0
|
$: unlocked = lockedApps?.length === 0
|
||||||
$: automationErrors = getAutomationErrors(enrichedApps)
|
$: automationErrors = getAutomationErrors(enrichedApps)
|
||||||
|
@ -231,6 +243,10 @@
|
||||||
// always load latest
|
// always load latest
|
||||||
await licensing.init()
|
await licensing.init()
|
||||||
|
|
||||||
|
if ($licensing.groupsEnabled) {
|
||||||
|
await groups.actions.init()
|
||||||
|
}
|
||||||
|
|
||||||
if ($templates?.length === 0) {
|
if ($templates?.length === 0) {
|
||||||
notifications.error(
|
notifications.error(
|
||||||
"There was a problem loading quick start templates."
|
"There was a problem loading quick start templates."
|
||||||
|
|
Loading…
Reference in New Issue