mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 20:34:37 +03:00
Default view filters (#4962)
* Merge/adapt from yoshnopa:defaultDetails * Deprecate and remove default filter calls * Fix weird behaviour when clicking set as default * Update deprecated get/set default filter resolvers * Add config migration --------- Co-authored-by: yoshnopa <usingusenet@protonmail.com>
This commit is contained in:
@@ -17,6 +17,7 @@ import {
|
||||
SavedObjectFilter,
|
||||
SavedUIOptions,
|
||||
} from "./types";
|
||||
import { ListFilterOptions } from "./filter-options";
|
||||
|
||||
interface IDecodedParams {
|
||||
perPage?: number;
|
||||
@@ -49,7 +50,8 @@ const DEFAULT_PARAMS = {
|
||||
|
||||
// TODO: handle customCriteria
|
||||
export class ListFilterModel {
|
||||
public mode: FilterMode;
|
||||
public readonly mode: FilterMode;
|
||||
public readonly options: ListFilterOptions;
|
||||
private config?: ConfigDataFragment;
|
||||
public searchTerm: string = "";
|
||||
public currentPage = DEFAULT_PARAMS.currentPage;
|
||||
@@ -65,19 +67,18 @@ export class ListFilterModel {
|
||||
public constructor(
|
||||
mode: FilterMode,
|
||||
config?: ConfigDataFragment,
|
||||
defaultSort?: string,
|
||||
defaultDisplayMode?: DisplayMode,
|
||||
defaultZoomIndex?: number
|
||||
) {
|
||||
this.mode = mode;
|
||||
this.config = config;
|
||||
this.sortBy = defaultSort;
|
||||
this.options = getFilterOptions(mode);
|
||||
const { defaultSortBy, displayModeOptions } = this.options;
|
||||
|
||||
this.sortBy = defaultSortBy;
|
||||
if (this.sortBy === "date") {
|
||||
this.sortDirection = SortDirectionEnum.Desc;
|
||||
}
|
||||
if (defaultDisplayMode !== undefined) {
|
||||
this.displayMode = defaultDisplayMode;
|
||||
}
|
||||
this.displayMode = displayModeOptions[0];
|
||||
if (defaultZoomIndex !== undefined) {
|
||||
this.defaultZoomIndex = defaultZoomIndex;
|
||||
this.zoomIndex = defaultZoomIndex;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { FilterMode, Scene } from "src/core/generated-graphql";
|
||||
import { ListFilterModel } from "./list-filter/filter";
|
||||
import { SceneListFilterOptions } from "./list-filter/scenes";
|
||||
import { INamedObject } from "src/utils/navigation";
|
||||
|
||||
export type QueuedScene = Pick<Scene, "id" | "title" | "date" | "paths"> & {
|
||||
@@ -97,11 +96,7 @@ export class SceneQueue {
|
||||
c: params.getAll("qfc"),
|
||||
};
|
||||
const decoded = ListFilterModel.decodeParams(translated);
|
||||
const query = new ListFilterModel(
|
||||
FilterMode.Scenes,
|
||||
undefined,
|
||||
SceneListFilterOptions.defaultSortBy
|
||||
);
|
||||
const query = new ListFilterModel(FilterMode.Scenes);
|
||||
query.configureFromDecodedParams(decoded);
|
||||
ret.query = query;
|
||||
} else if (params.has("qs")) {
|
||||
|
||||
Reference in New Issue
Block a user