Skip to content

Commit

Permalink
refactor: Moar LangString
Browse files Browse the repository at this point in the history
  • Loading branch information
arildm committed Jul 5, 2024
1 parent 2bb13d4 commit 15ba098
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/scripts/settings/app-settings.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @format
*/

import { Labeled, LangMap, LangString } from "@/i18n/types"
import { Labeled, LangString } from "@/i18n/types"
import { Attribute } from "./config.types"

export type AppSettings = {
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/settings/config-transformed.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
* @format
*/

import { LangMap } from "@/i18n/types"
import { LangString } from "@/i18n/types"
import { Attribute, Config, Corpus, CustomAttribute, Folder } from "./config.types"

export type ConfigTransformed = Omit<Config, "attributes" | "corpora" | "label"> & {
corpora: Record<string, CorpusTransformed>
folders: Record<string, Folder>
mode: {
label: string | LangMap
label: LangString
}
}

Expand Down
9 changes: 4 additions & 5 deletions app/scripts/statistics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import { reduceStringify } from "../config/statistics_config"
import type { StatsNormalized, StatisticsWorkerMessage, StatisticsWorkerResult, SearchParams } from "./statistics.types"
import { hitCountHtml } from "@/util"
import { Row } from "./statistics_worker"
import { LangString } from "./i18n/types"
const pieChartImg = require("../img/stats2.png")

const createStatisticsService = function () {
const createColumns = function (
corpora: Record<string, any>,
reduceVals: string[],
reduceValLabels: Label[]
reduceValLabels: LangString[]
): SlickgridColumn[] {
const valueFormatter: SlickgridFormatter = function (row, cell, value, columnDef, dataContext) {
const [absolute, relative] = [...dataContext[columnDef.id + "_value"]]
Expand Down Expand Up @@ -83,7 +84,7 @@ const createStatisticsService = function () {
originalCorpora: string,
data: StatsNormalized,
reduceVals: string[],
reduceValLabels: Label[],
reduceValLabels: LangString[],
ignoreCase: boolean,
prevNonExpandedCQP: string
) {
Expand Down Expand Up @@ -120,16 +121,14 @@ export type SlickgridColumn = {
field: string
formatter: SlickgridFormatter
name?: string
translation?: Label
translation?: LangString
sortable?: boolean
minWidth?: number
maxWidth?: number
cssClass?: string
headerCssClass?: string
}

type Label = string | Record<string, string>

type SlickgridFormatter = (
// There's currently no Korp code that uses these first three args
row: unknown,
Expand Down

0 comments on commit 15ba098

Please sign in to comment.