mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-21 07:46:24 +00:00
Add remember active viewlet (#2094)
Signed-off-by: Dvinyanin Alexandr <dvinyanin.alexandr@gmail.com>
This commit is contained in:
parent
05f558a5ff
commit
75d7167a16
@ -301,7 +301,7 @@ export function createModel (builder: Builder): void {
|
|||||||
view.class.ViewletDescriptor,
|
view.class.ViewletDescriptor,
|
||||||
core.space.Model,
|
core.space.Model,
|
||||||
{
|
{
|
||||||
label: view.string.Table,
|
label: tracker.string.List,
|
||||||
icon: view.icon.Table,
|
icon: view.icon.Table,
|
||||||
component: tracker.component.ListView
|
component: tracker.component.ListView
|
||||||
},
|
},
|
||||||
|
@ -50,6 +50,7 @@
|
|||||||
"Low": "Low",
|
"Low": "Low",
|
||||||
"Unassigned": "Unassigned",
|
"Unassigned": "Unassigned",
|
||||||
"Back": "Back",
|
"Back": "Back",
|
||||||
|
"List": "List",
|
||||||
|
|
||||||
"CategoryBacklog": "Backlog",
|
"CategoryBacklog": "Backlog",
|
||||||
"CategoryUnstarted": "Unstarted",
|
"CategoryUnstarted": "Unstarted",
|
||||||
|
@ -50,6 +50,7 @@
|
|||||||
"Low": "Низкий",
|
"Low": "Низкий",
|
||||||
"Unassigned": "Не назначен",
|
"Unassigned": "Не назначен",
|
||||||
"Back": "Назад",
|
"Back": "Назад",
|
||||||
|
"List": "Список",
|
||||||
|
|
||||||
"CategoryBacklog": "Пул",
|
"CategoryBacklog": "Пул",
|
||||||
"CategoryUnstarted": "Не запущенные",
|
"CategoryUnstarted": "Не запущенные",
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
import { Team, ViewOptions } from '@anticrm/tracker'
|
import { Team, ViewOptions } from '@anticrm/tracker'
|
||||||
import { Button, Icon, Tooltip, IconOptions, showPopup, eventToHTMLElement } from '@anticrm/ui'
|
import { Button, Icon, Tooltip, IconOptions, showPopup, eventToHTMLElement } from '@anticrm/ui'
|
||||||
import { Filter, Viewlet } from '@anticrm/view'
|
import { Filter, Viewlet } from '@anticrm/view'
|
||||||
import { FilterButton } from '@anticrm/view-resources'
|
import { FilterButton, setActiveViewletId } from '@anticrm/view-resources'
|
||||||
import tracker from '../../plugin'
|
import tracker from '../../plugin'
|
||||||
import ViewOptionsPopup from './ViewOptionsPopup.svelte'
|
import ViewOptionsPopup from './ViewOptionsPopup.svelte'
|
||||||
|
|
||||||
@ -39,6 +39,7 @@
|
|||||||
class="ac-header__icon-button"
|
class="ac-header__icon-button"
|
||||||
class:selected={viewlet?._id === v._id}
|
class:selected={viewlet?._id === v._id}
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
|
setActiveViewletId(v._id)
|
||||||
viewlet = v
|
viewlet = v
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
import { Button, IconDetails } from '@anticrm/ui'
|
import { Button, IconDetails } from '@anticrm/ui'
|
||||||
import view, { Filter, Viewlet } from '@anticrm/view'
|
import view, { Filter, Viewlet } from '@anticrm/view'
|
||||||
import { FilterBar } from '@anticrm/view-resources'
|
import { FilterBar } from '@anticrm/view-resources'
|
||||||
|
import { getActiveViewletId } from '@anticrm/view-resources/src/utils'
|
||||||
import tracker from '../../plugin'
|
import tracker from '../../plugin'
|
||||||
import IssuesContent from './IssuesContent.svelte'
|
import IssuesContent from './IssuesContent.svelte'
|
||||||
import IssuesHeader from './IssuesHeader.svelte'
|
import IssuesHeader from './IssuesHeader.svelte'
|
||||||
@ -53,7 +54,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
;[viewlet] = viewlets
|
const _id = getActiveViewletId()
|
||||||
|
viewlet = viewlets.find((viewlet) => viewlet._id === _id) || viewlets[0]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$: if (!label && title) {
|
$: if (!label && title) {
|
||||||
|
@ -135,6 +135,7 @@ export default mergeIds(trackerId, tracker, {
|
|||||||
ProjectMembersTitle: '' as IntlString,
|
ProjectMembersTitle: '' as IntlString,
|
||||||
ProjectLeadSearchPlaceholder: '' as IntlString,
|
ProjectLeadSearchPlaceholder: '' as IntlString,
|
||||||
ProjectMembersSearchPlaceholder: '' as IntlString,
|
ProjectMembersSearchPlaceholder: '' as IntlString,
|
||||||
|
List: '' as IntlString,
|
||||||
|
|
||||||
IssueTitlePlaceholder: '' as IntlString,
|
IssueTitlePlaceholder: '' as IntlString,
|
||||||
IssueDescriptionPlaceholder: '' as IntlString,
|
IssueDescriptionPlaceholder: '' as IntlString,
|
||||||
|
@ -65,7 +65,14 @@ export { default as ContextMenu } from './components/Menu.svelte'
|
|||||||
export { default as TableBrowser } from './components/TableBrowser.svelte'
|
export { default as TableBrowser } from './components/TableBrowser.svelte'
|
||||||
export * from './context'
|
export * from './context'
|
||||||
export * from './selection'
|
export * from './selection'
|
||||||
export { buildModel, getCollectionCounter, getObjectPresenter, LoadingProps } from './utils'
|
export {
|
||||||
|
buildModel,
|
||||||
|
getCollectionCounter,
|
||||||
|
getObjectPresenter,
|
||||||
|
LoadingProps,
|
||||||
|
setActiveViewletId,
|
||||||
|
getActiveViewletId
|
||||||
|
} from './utils'
|
||||||
export {
|
export {
|
||||||
HTMLPresenter,
|
HTMLPresenter,
|
||||||
Table,
|
Table,
|
||||||
|
@ -30,8 +30,8 @@ import core, {
|
|||||||
import type { IntlString } from '@anticrm/platform'
|
import type { IntlString } from '@anticrm/platform'
|
||||||
import { getResource } from '@anticrm/platform'
|
import { getResource } from '@anticrm/platform'
|
||||||
import { getAttributePresenterClass, KeyedAttribute } from '@anticrm/presentation'
|
import { getAttributePresenterClass, KeyedAttribute } from '@anticrm/presentation'
|
||||||
import { AnyComponent, ErrorPresenter, getPlatformColorForText } from '@anticrm/ui'
|
import { AnyComponent, ErrorPresenter, getCurrentLocation, getPlatformColorForText, locationToUrl } from '@anticrm/ui'
|
||||||
import type { BuildModelOptions } from '@anticrm/view'
|
import type { BuildModelOptions, Viewlet } from '@anticrm/view'
|
||||||
import view, { AttributeModel, BuildModelKey } from '@anticrm/view'
|
import view, { AttributeModel, BuildModelKey } from '@anticrm/view'
|
||||||
import plugin from './plugin'
|
import plugin from './plugin'
|
||||||
|
|
||||||
@ -392,3 +392,24 @@ export function collectionsFilter (hierarchy: Hierarchy, keys: KeyedAttribute[],
|
|||||||
export function isCollectionAttr (hierarchy: Hierarchy, key: KeyedAttribute): boolean {
|
export function isCollectionAttr (hierarchy: Hierarchy, key: KeyedAttribute): boolean {
|
||||||
return hierarchy.isDerived(key.attr.type._class, core.class.Collection)
|
return hierarchy.isDerived(key.attr.type._class, core.class.Collection)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function makeViewletKey (): string {
|
||||||
|
const loc = getCurrentLocation()
|
||||||
|
loc.fragment = undefined
|
||||||
|
loc.query = undefined
|
||||||
|
return 'viewlet' + locationToUrl(loc)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setActiveViewletId (viewletId: Ref<Viewlet> | null): void {
|
||||||
|
const key = makeViewletKey()
|
||||||
|
if (viewletId !== null) {
|
||||||
|
localStorage.setItem(key, viewletId)
|
||||||
|
} else {
|
||||||
|
localStorage.removeItem(key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getActiveViewletId (): Ref<Viewlet> | null {
|
||||||
|
const key = makeViewletKey()
|
||||||
|
return localStorage.getItem(key) as Ref<Viewlet> | null
|
||||||
|
}
|
||||||
|
@ -82,7 +82,7 @@ test.describe('issues-status-display', () => {
|
|||||||
test(`${panel}-panel`, async ({ page }) => {
|
test(`${panel}-panel`, async ({ page }) => {
|
||||||
const locator = page.locator('.antiPanel-component >> .antiPanel-component')
|
const locator = page.locator('.antiPanel-component >> .antiPanel-component')
|
||||||
await page.locator(`text="${panel}"`).click()
|
await page.locator(`text="${panel}"`).click()
|
||||||
await page.click('[name="tooltip-view:string:Table"]')
|
await page.click('[name="tooltip-tracker:string:List"]')
|
||||||
await expect(locator).toContainText(statuses)
|
await expect(locator).toContainText(statuses)
|
||||||
if (excluded.length > 0) await expect(locator).not.toContainText(excluded)
|
if (excluded.length > 0) await expect(locator).not.toContainText(excluded)
|
||||||
await page.click('[name="tooltip-tracker:string:Board"]')
|
await page.click('[name="tooltip-tracker:string:Board"]')
|
||||||
@ -93,3 +93,19 @@ test.describe('issues-status-display', () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('save-active-viewlet', async ({ page }) => {
|
||||||
|
const panels = ['Issues', 'Active', 'Backlog']
|
||||||
|
const viewletTooltips = ['Board', 'List']
|
||||||
|
await navigate(page)
|
||||||
|
for (const viewletTooltip of viewletTooltips) {
|
||||||
|
for (const panel of panels) {
|
||||||
|
await page.click(`text="${panel}"`)
|
||||||
|
await page.click(`[name="tooltip-tracker:string:${viewletTooltip}"]`)
|
||||||
|
}
|
||||||
|
for (const panel of panels) {
|
||||||
|
await page.click(`text="${panel}"`)
|
||||||
|
await expect(page.locator(`[name="tooltip-tracker:string:${viewletTooltip}"] >> button`)).toHaveClass(/selected/)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user