Skip to content

Commit

Permalink
refactor(ts): globalFilterService, globalFilter(s) components
Browse files Browse the repository at this point in the history
  • Loading branch information
arildm committed Oct 24, 2024
1 parent ca838e0 commit 2387825
Show file tree
Hide file tree
Showing 10 changed files with 291 additions and 206 deletions.
1 change: 0 additions & 1 deletion app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,4 @@ require("./scripts/app")

require("./scripts/video_controllers.js")
require("./scripts/backend/struct-service")
require("./scripts/filter_directives.js")
require("./scripts/matomo")
13 changes: 10 additions & 3 deletions app/scripts/backend/struct-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import { httpConfAddMethod } from "@/util"
import { KorpResponse } from "./types"

export type StructService = {
/** Returns list if `options.returnByCorpora` is set to false, otherwise record of lists. */
getStructValues: (
corpora: string[],
attributes: string[],
options?: StructServiceOptions
) => IPromise<Record<string, string[]> | string[]>
) => IPromise<Record<string, AttrValues> | AttrValues>
}

export type StructServiceOptions = {
Expand All @@ -20,18 +21,24 @@ export type StructServiceOptions = {
split?: boolean
}

/** @see https://ws.spraakbanken.gu.se/docs/korp#tag/Misc/paths/~1attr_values/get */
export type StructServiceParameters = {
corpus: string
struct: string
count: boolean
split?: string
}

/** @see https://ws.spraakbanken.gu.se/docs/korp#tag/Misc/paths/~1attr_values/get */
export type StructServiceResponse = {
corpora: { [corpus: string]: { [attribute: string]: string[] } }
combined: { [attribute: string]: string[] }
corpora: { [corpus: string]: AttrValues }
combined: AttrValues
}

export type AttrValues = RecursiveRecord<string[] | Record<string, number>>

export type RecursiveRecord<T> = T | { [k: string]: RecursiveRecord<T> }

angular.module("korpApp").factory("structService", [
"$http",
"$q",
Expand Down
1 change: 1 addition & 0 deletions app/scripts/components/extended/extended-standard.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { matomoSend } from "@/matomo"
import "@/services/compare-searches"
import "@/components/extended/tokens"
import "@/components/search-submit"
import "@/global-filter/global-filters"

angular.module("korpApp").component("extendedStandard", {
template: html`
Expand Down
1 change: 1 addition & 0 deletions app/scripts/components/simple-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import "@/backend/lexicons"
import "@/services/searches"
import "@/components/autoc"
import "@/components/search-submit"
import "@/global-filter/global-filters"

angular.module("korpApp").component("simpleSearch", {
template: html`
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/cqp_parser/cqp.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type Condition = {
type: string
op: OperatorKorp
val: string | DateRange
flags: Record<string, true>
flags?: Record<string, true>
}

/** Should be `[fromdate, todate, fromtime, totime]` */
Expand Down
Loading

0 comments on commit 2387825

Please sign in to comment.