Skip to content
Merged
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
2 changes: 1 addition & 1 deletion common/scripts/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"0.7.410"
"0.7.422"
39 changes: 34 additions & 5 deletions models/card/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ import { type Asset, getEmbeddedLabel, type IntlString, type Resource } from '@h
import time, { type ToDo } from '@hcengineering/time'
import { PaletteColorIndexes } from '@hcengineering/ui/src/colors'
import { type AnyComponent } from '@hcengineering/ui/src/types'
import { type BuildModelKey } from '@hcengineering/view'
import { type BuildModelKey, type ViewOptionModel } from '@hcengineering/view'
import { createActions } from './actions'
import { defineActionPermissions, definePermissions } from './permissions'
import card from './plugin'
Expand Down Expand Up @@ -225,6 +225,15 @@ export class TExportExtension extends TDoc implements ExportExtension {

export * from './migration'

const showAllVersionsOption: ViewOptionModel = {
key: 'showAllVersions',
type: 'toggle',
defaultValue: false,
actionTarget: 'query',
action: card.function.ShowAllVersions,
label: card.string.ShowAllVersions
}

const listConfig: (BuildModelKey | string)[] = [
{ key: '' },
{ key: '_class' },
Expand Down Expand Up @@ -350,6 +359,11 @@ export function createSystemType (
hiddenKeys: ['content', 'title'],
sortable: true
},
viewOptions: {
groupBy: [],
orderBy: [],
other: [showAllVersionsOption]
},
baseQuery: {
isLatest: true
},
Expand Down Expand Up @@ -383,7 +397,7 @@ export function createSystemType (
['modifiedOn', SortingOrder.Descending],
['rank', SortingOrder.Ascending]
],
other: []
other: [showAllVersionsOption]
},
baseQuery: {
isLatest: true
Expand All @@ -397,6 +411,11 @@ export function createSystemType (
builder.createDoc(view.class.Viewlet, core.space.Model, {
attachTo: type,
descriptor: card.viewlet.CardGridDescriptor,
viewOptions: {
groupBy: [],
orderBy: [],
other: [showAllVersionsOption]
},
baseQuery: {
isLatest: true
},
Expand Down Expand Up @@ -681,6 +700,11 @@ export function createModel (builder: Builder): void {
hiddenKeys: ['content', 'title'],
sortable: true
},
viewOptions: {
groupBy: [],
orderBy: [],
other: [showAllVersionsOption]
},
baseQuery: {
isLatest: true
},
Expand Down Expand Up @@ -713,7 +737,7 @@ export function createModel (builder: Builder): void {
['modifiedOn', SortingOrder.Descending],
['rank', SortingOrder.Ascending]
],
other: []
other: [showAllVersionsOption]
},
configOptions: {
hiddenKeys: ['content', 'title']
Expand All @@ -739,7 +763,7 @@ export function createModel (builder: Builder): void {
['modifiedOn', SortingOrder.Descending],
['rank', SortingOrder.Ascending]
],
other: []
other: [showAllVersionsOption]
},
configOptions: {
strict: true,
Expand Down Expand Up @@ -782,6 +806,11 @@ export function createModel (builder: Builder): void {
hiddenKeys: ['content', 'title'],
sortable: true
},
viewOptions: {
groupBy: [],
orderBy: [],
other: [showAllVersionsOption]
},
baseQuery: {
isLatest: true
},
Expand Down Expand Up @@ -821,7 +850,7 @@ export function createModel (builder: Builder): void {
['rank', SortingOrder.Ascending],
['title', SortingOrder.Descending]
],
other: []
other: [showAllVersionsOption]
}
},
card.viewlet.CardGrid
Expand Down
43 changes: 42 additions & 1 deletion models/card/src/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
type MigrationUpgradeClient
} from '@hcengineering/model'
import tags from '@hcengineering/tags'
import view, { type Viewlet } from '@hcengineering/view'
import view, { type ViewOptionModel, type Viewlet } from '@hcengineering/view'
import card from '.'

export const cardOperation: MigrateOperation = {
Expand Down Expand Up @@ -134,6 +134,11 @@ export const cardOperation: MigrateOperation = {
state: 'add-grid-viewlet',
mode: 'upgrade',
func: addGridViewlet
},
{
state: 'add-show-all-versions-view-option',
mode: 'upgrade',
func: addShowAllVersionsViewOption
}
])
}
Expand Down Expand Up @@ -668,3 +673,39 @@ async function fillVersioning (client: MigrationClient): Promise<void> {
await iterator.close()
}
}

async function addShowAllVersionsViewOption (client: MigrationUpgradeClient): Promise<void> {
const txOp = new TxOperations(client, core.account.System)
const masterTags = await client.findAll(card.class.MasterTag, {})
const cardDescendants = client.getHierarchy().getDescendants(card.class.Card)
const allViewletTargets = [...masterTags.map((p) => p._id), ...cardDescendants, card.class.Card]

const viewlets = await client.findAll(view.class.Viewlet, {
attachTo: { $in: allViewletTargets }
})

const showAllVersionsOption: ViewOptionModel = {
key: 'showAllVersions',
type: 'toggle',
defaultValue: false,
actionTarget: 'query',
action: card.function.ShowAllVersions,
label: card.string.ShowAllVersions
}

for (const v of viewlets) {
// Skip CardSpace viewlets if any (though they shouldn't be in allViewletTargets)
if (v.attachTo === card.class.CardSpace) continue

const viewOptions = v.viewOptions ?? { groupBy: [], orderBy: [], other: [] }
const other = viewOptions.other ?? []
if (other.find((o: any) => o.key === 'showAllVersions') === undefined) {
await txOp.update(v, {
viewOptions: {
...viewOptions,
other: [...other, showAllVersionsOption]
}
})
}
}
}
5 changes: 3 additions & 2 deletions models/card/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import type { ViewletViewAction, Action, ActionCategory, ViewAction } from '@hcengineering/view'
import { type Card, cardId } from '@hcengineering/card'
import card from '@hcengineering/card-resources/src/plugin'
import type { Client, Doc, Ref } from '@hcengineering/core'
import type { Client, Doc, DocumentQuery, Ref } from '@hcengineering/core'
import {} from '@hcengineering/core'
import { mergeIds, type Resource } from '@hcengineering/platform'
import { type TagCategory } from '@hcengineering/tags'
Expand Down Expand Up @@ -72,6 +72,7 @@ export default mergeIds(cardId, card, {
CardCustomLinkEncode: '' as Resource<(doc: Doc) => Location>,
CheckRelationsSectionVisibility: '' as Resource<(doc: Card) => Promise<boolean>>,
CheckOldMessagesSectionVisibility: '' as Resource<(doc: Card) => Promise<boolean>>,
CheckCommunicationMessagesSectionVisibility: '' as Resource<(doc: Card) => Promise<boolean>>
CheckCommunicationMessagesSectionVisibility: '' as Resource<(doc: Card) => Promise<boolean>>,
ShowAllVersions: '' as Resource<(value: any, query: DocumentQuery<Doc>) => DocumentQuery<Doc>>
}
})
3 changes: 2 additions & 1 deletion plugins/card-assets/lang/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"SingleColumn": "Jeden sloupec",
"TwoColumns": "Dva sloupce",
"Grid": "Mřížka",
"RichtextProperties": "Textová pole"
"RichtextProperties": "Textová pole",
"ShowAllVersions": "Ukázat všechny verze"
}
}
3 changes: 2 additions & 1 deletion plugins/card-assets/lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"SingleColumn": "Einspaltig",
"TwoColumns": "Zwei spaltig",
"Grid": "Gitter",
"RichtextProperties": "Textfelder"
"RichtextProperties": "Textfelder",
"ShowAllVersions": "Alle Versionen anzeigen"
}
}
3 changes: 2 additions & 1 deletion plugins/card-assets/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"SingleColumn": "Single column",
"TwoColumns": "Two columns",
"Grid": "Grid",
"RichtextProperties": "Richtext Properties"
"RichtextProperties": "Richtext Properties",
"ShowAllVersions": "Show all versions"
}
}
3 changes: 2 additions & 1 deletion plugins/card-assets/lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"SingleColumn": "Una columna",
"TwoColumns": "Dos columnas",
"Grid": "Cuadrícula",
"RichtextProperties": "Campos de texto"
"RichtextProperties": "Campos de texto",
"ShowAllVersions": "Mostrar todas las versiones"
}
}
3 changes: 2 additions & 1 deletion plugins/card-assets/lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"SingleColumn": "Une colonne",
"TwoColumns": "Deux colonnes",
"Grid": "Grille",
"RichtextProperties": "Champs de texte"
"RichtextProperties": "Champs de texte",
"ShowAllVersions": "Toutes les versions"
}
}
3 changes: 2 additions & 1 deletion plugins/card-assets/lang/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"SingleColumn": "Una colonna",
"TwoColumns": "Due colonne",
"Grid": "Griglia",
"RichtextProperties": "Campo di testo"
"RichtextProperties": "Campo di testo",
"ShowAllVersions": "Tutte le versioni"
}
}
3 changes: 2 additions & 1 deletion plugins/card-assets/lang/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"SingleColumn": "1列",
"TwoColumns": "2列",
"Grid": "グリッド",
"RichtextProperties": "リッチテキストフィールド"
"RichtextProperties": "リッチテキストフィールド",
"ShowAllVersions": "すべてのバージョンを表示"
}
}
3 changes: 2 additions & 1 deletion plugins/card-assets/lang/pt-br.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"SingleColumn": "Uma coluna",
"TwoColumns": "Duas colunas",
"Grid": "Grade",
"RichtextProperties": "Campos de texto"
"RichtextProperties": "Campos de texto",
"ShowAllVersions": "Todas as versões"
}
}
3 changes: 2 additions & 1 deletion plugins/card-assets/lang/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"SingleColumn": "Uma coluna",
"TwoColumns": "Duas colunas",
"Grid": "Grade",
"RichtextProperties": "Campo de texto"
"RichtextProperties": "Campo de texto",
"ShowAllVersions": "Todas as versões"
}
}
3 changes: 2 additions & 1 deletion plugins/card-assets/lang/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"SingleColumn": "Один столбец",
"TwoColumns": "Два столбца",
"Grid": "Сетка",
"RichtextProperties": "Текстовые поля"
"RichtextProperties": "Текстовые поля",
"ShowAllVersions": "Показывать все версии"
}
}
3 changes: 2 additions & 1 deletion plugins/card-assets/lang/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"SingleColumn": "Tek sütun",
"TwoColumns": "İki sütun",
"Grid": "Izgara",
"RichtextProperties": "Zengin metin alanları"
"RichtextProperties": "Zengin metin alanları",
"ShowAllVersions": "Tüm sürümleri göster"
}
}
3 changes: 2 additions & 1 deletion plugins/card-assets/lang/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"SingleColumn": "单列",
"TwoColumns": "两列",
"Grid": "网格",
"RichtextProperties": "富文本字段"
"RichtextProperties": "富文本字段",
"ShowAllVersions": "显示所有版本"
}
}
6 changes: 4 additions & 2 deletions plugins/card-resources/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ import {
cardFactory,
duplicateCard,
checkChildrenSectionVisibility,
createChildAction
createChildAction,
showAllVersions
} from './utils'
import { formatCardValue } from './cardTableFormatter'
import CardGridView from './components/CardGridView.svelte'
Expand Down Expand Up @@ -179,6 +180,7 @@ export default async (): Promise<Resources> => ({
GetSpaceAccessPublicLink: getSpaceAccessPublicLink,
CanGetSpaceAccessPublicLink: canGetSpaceAccessPublicLink,
CardFactory: cardFactory,
FormatCardMarkdownValue: formatCardValue
FormatCardMarkdownValue: formatCardValue,
ShowAllVersions: showAllVersions
}
})
7 changes: 7 additions & 0 deletions plugins/card-resources/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,13 @@ export function canUnlockSection (space: Ref<Space>, store: PermissionsStore): b
return !store.restrictedSpaces.has(space)
}

export function showAllVersions (value: any, query: DocumentQuery<Doc>): DocumentQuery<Doc> {
if (value === true) {
return { ...query, isLatest: { $in: [true, false] } }
}
return query
}

export const viewStore = writable<Record<Ref<MasterTag>, string>>(
JSON.parse(localStorage.getItem('card.layout') ?? '{}')
)
Expand Down
3 changes: 2 additions & 1 deletion plugins/card/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ const cardPlugin = plugin(cardId, {
LockSection: '' as IntlString,
UnLockSection: '' as IntlString,
SectionLocked: '' as IntlString,
SectionUnlocked: '' as IntlString
SectionUnlocked: '' as IntlString,
ShowAllVersions: '' as IntlString
},
section: {
Attachments: '' as Ref<CardSection>,
Expand Down
Loading