Fix filtered view visibility (#10969)

Signed-off-by: Artyom Savchenko <armisav@gmail.com>
This commit is contained in:
Artyom Savchenko
2026-07-10 17:32:33 +07:00
committed by GitHub
parent abe0cb9625
commit 8ba43d54eb
3 changed files with 17 additions and 6 deletions
@@ -13,7 +13,7 @@
// limitations under the License.
-->
<script lang="ts">
import { Class, Doc, DocumentQuery, Ref, Space, getCurrentAccount } from '@hcengineering/core'
import { AccountRole, Class, Doc, DocumentQuery, Ref, Space, getCurrentAccount } from '@hcengineering/core'
import { getResource } from '@hcengineering/platform'
import { getClient, reduceCalls } from '@hcengineering/presentation'
import { Button, IconAdd, eventToHTMLElement, getCurrentLocation, showPopup } from '@hcengineering/ui'
@@ -37,6 +37,9 @@
const hierarchy = client.getHierarchy()
const dispatch = createEventDispatcher()
const account = getCurrentAccount()
const canSaveFilteredView = account.role !== AccountRole.ReadOnlyGuest && account.role !== AccountRole.DocGuest
function onChange (e: Filter | undefined) {
if (e === undefined) return
updateFilter(e)
@@ -189,7 +192,7 @@
</div>
</div>
{#if !hideSaveButtons}
{#if !hideSaveButtons && canSaveFilteredView}
<div class="flex gap-1-5">
<Button
icon={view.icon.Views}
@@ -1,5 +1,5 @@
<script lang="ts">
import core, { Class, Doc, Ref, getCurrentAccount } from '@hcengineering/core'
import core, { Class, Doc, Ref, Space, getCurrentAccount } from '@hcengineering/core'
import { Card, getClient } from '@hcengineering/presentation'
import { Button, EditBox, ToggleWithLabel, getCurrentResolvedLocation } from '@hcengineering/ui'
import { ViewOptions } from '@hcengineering/view'
@@ -16,11 +16,18 @@
let filterName = ''
const client = getClient()
async function getTargetSpace (spaceRef: string | undefined): Promise<Ref<Space>> {
// Store the filtered view in the space it is built on
if (spaceRef === undefined) return core.space.Workspace
const space = await client.findOne(core.class.Space, { _id: spaceRef as Ref<Space> })
return space?._id ?? core.space.Workspace
}
async function saveFilter () {
const loc = getCurrentResolvedLocation()
loc.fragment = undefined
const filters = JSON.stringify($filterStore)
await client.createDoc(view.class.FilteredView, core.space.Workspace, {
await client.createDoc(view.class.FilteredView, await getTargetSpace(loc.path[3]), {
name: filterName,
location: loc,
filterClass: _class,
@@ -1,6 +1,6 @@
<script lang="ts">
import contact from '@hcengineering/contact'
import { Ref, getCurrentAccount, toIdMap } from '@hcengineering/core'
import { AccountRole, Ref, getCurrentAccount, toIdMap } from '@hcengineering/core'
import { copyTextToClipboard, createQuery, getClient } from '@hcengineering/presentation'
import setting from '@hcengineering/setting'
import {
@@ -42,11 +42,12 @@
const dispatch = createEventDispatcher()
const client = getClient()
const myAcc = getCurrentAccount()
const canUseFilteredViews = myAcc.role !== AccountRole.ReadOnlyGuest && myAcc.role !== AccountRole.DocGuest
const filteredViewsQuery = createQuery()
let availableFilteredViews: FilteredView[] = []
let myFilteredViews: FilteredView[] = []
$: if (alias !== undefined) {
$: if (alias !== undefined && canUseFilteredViews) {
filteredViewsQuery.query<FilteredView>(view.class.FilteredView, { attachedTo: alias }, (result) => {
myFilteredViews = result.filter((p) => p.users.includes(myAcc.uuid))
availableFilteredViews = result.filter((p) => p.sharable && !p.users.includes(myAcc.uuid))