feat: Added per-tag preference to use table layout and removed "Files Table View" from Labs
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { ListableContentItem } from '@/Components/ContentListView/Types/ListableContentItem'
|
||||
import { destroyAllObjectProperties } from '@/Utils'
|
||||
import { destroyAllObjectProperties, isMobileScreen } from '@/Utils'
|
||||
import {
|
||||
ApplicationEvent,
|
||||
CollectionSort,
|
||||
@@ -71,6 +71,7 @@ export class ItemListController extends AbstractViewController implements Intern
|
||||
hideNotePreview: false,
|
||||
hideEditorIcon: false,
|
||||
}
|
||||
isTableViewEnabled = false
|
||||
private reloadItemsPromise?: Promise<unknown>
|
||||
|
||||
override deinit() {
|
||||
@@ -451,6 +452,10 @@ export class ItemListController extends AbstractViewController implements Intern
|
||||
this.selectionController.deselectItem(activeItem)
|
||||
|
||||
if (this.shouldSelectFirstItem(itemsReloadSource)) {
|
||||
if (this.isTableViewEnabled && !isMobileScreen()) {
|
||||
return
|
||||
}
|
||||
|
||||
log(LoggingDomain.Selection, 'Selecting next item after closing active one')
|
||||
this.selectionController.selectNextItem({ userTriggered: false })
|
||||
}
|
||||
@@ -513,6 +518,8 @@ export class ItemListController extends AbstractViewController implements Intern
|
||||
? this.application.getPreference(PrefKey.SystemViewPreferences)?.[selectedTag.uuid as SystemViewId]
|
||||
: selectedTag?.preferences
|
||||
|
||||
this.isTableViewEnabled = Boolean(selectedTagPreferences?.useTableView)
|
||||
|
||||
const currentSortBy = this.displayOptions.sortBy
|
||||
let sortBy =
|
||||
selectedTagPreferences?.sortBy ||
|
||||
@@ -729,6 +736,10 @@ export class ItemListController extends AbstractViewController implements Intern
|
||||
selectFirstItem = async () => {
|
||||
const item = this.getFirstNonProtectedItem()
|
||||
|
||||
if (this.isTableViewEnabled && !isMobileScreen()) {
|
||||
return
|
||||
}
|
||||
|
||||
if (item) {
|
||||
log(LoggingDomain.Selection, 'Selecting first item', item.uuid)
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
InternalEventPublishStrategy,
|
||||
VectorIconNameOrEmoji,
|
||||
isTag,
|
||||
PrefKey,
|
||||
} from '@standardnotes/snjs'
|
||||
import { action, computed, makeAutoObservable, makeObservable, observable, reaction, runInAction } from 'mobx'
|
||||
import { WebApplication } from '../../Application/Application'
|
||||
@@ -268,6 +269,14 @@ export class NavigationController
|
||||
return tag.uuid === SystemViewId.Files
|
||||
}
|
||||
|
||||
tagUsesTableView(tag: AnyTag): boolean {
|
||||
const isSystemView = tag instanceof SmartView && Object.values(SystemViewId).includes(tag.uuid as SystemViewId)
|
||||
const useTableView = isSystemView
|
||||
? this.application.getPreference(PrefKey.SystemViewPreferences)?.[tag.uuid as SystemViewId]
|
||||
: tag?.preferences
|
||||
return Boolean(useTableView)
|
||||
}
|
||||
|
||||
public isInAnySystemView(): boolean {
|
||||
return (
|
||||
this.selected instanceof SmartView && Object.values(SystemViewId).includes(this.selected.uuid as SystemViewId)
|
||||
@@ -466,8 +475,8 @@ export class NavigationController
|
||||
.catch(console.error)
|
||||
}
|
||||
|
||||
if (tag && this.isTagFilesView(tag)) {
|
||||
this.application.paneController.setPaneLayout(PaneLayout.FilesView)
|
||||
if (tag && (this.isTagFilesView(tag) || this.tagUsesTableView(tag))) {
|
||||
this.application.paneController.setPaneLayout(PaneLayout.TableView)
|
||||
} else if (userTriggered) {
|
||||
this.application.paneController.setPaneLayout(PaneLayout.ItemSelection)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export enum PaneLayout {
|
||||
TagSelection = 'tag-selection',
|
||||
ItemSelection = 'item-selection',
|
||||
FilesView = 'files-view',
|
||||
TableView = 'files-view',
|
||||
Editing = 'editing',
|
||||
}
|
||||
|
||||
@@ -11,20 +11,20 @@ export function panesForLayout(layout: PaneLayout, application: WebApplication):
|
||||
} else if (
|
||||
layout === PaneLayout.ItemSelection ||
|
||||
layout === PaneLayout.Editing ||
|
||||
layout === PaneLayout.FilesView
|
||||
layout === PaneLayout.TableView
|
||||
) {
|
||||
return [AppPaneId.Items, AppPaneId.Editor]
|
||||
}
|
||||
} else if (screen.isMobile) {
|
||||
if (layout === PaneLayout.TagSelection) {
|
||||
return [AppPaneId.Navigation]
|
||||
} else if (layout === PaneLayout.ItemSelection || layout === PaneLayout.FilesView) {
|
||||
} else if (layout === PaneLayout.ItemSelection || layout === PaneLayout.TableView) {
|
||||
return [AppPaneId.Navigation, AppPaneId.Items]
|
||||
} else if (layout === PaneLayout.Editing) {
|
||||
return [AppPaneId.Navigation, AppPaneId.Items, AppPaneId.Editor]
|
||||
}
|
||||
} else {
|
||||
if (layout === PaneLayout.FilesView) {
|
||||
if (layout === PaneLayout.TableView) {
|
||||
return [AppPaneId.Navigation, AppPaneId.Items]
|
||||
} else {
|
||||
return [AppPaneId.Navigation, AppPaneId.Items, AppPaneId.Editor]
|
||||
|
||||
Reference in New Issue
Block a user