/* * The questions of the report's "How do I…?" help as data: each with its group, its question, more * words the search finds it by, steps in English and German, the docs page that owns the topic, and * what "Show me" marks (help-show.js). The help's own words are HELP_TEXTS. Loaded with the help * (help-module.js), not in the first load. * * Steps name the report's controls by their labels: `{rows}`, `{filter}` and the other names of * helpNames() come from labels.js and menu-labels.js in the report's language, so a step never names * a control by a word the control does not show. test/help.test.js fails on a name it cannot fill. * A step with `needs` shows only where the report is so now (a toolbar button in More, the zones * folded away) or offers that feature. Every step is a whole sentence. * * The host's `helpTopics` picks the built-in questions and adds its own (helpTopicsOf): an own * question has its answer as text, and "Show me" only where it names an element of the page by its * id (`show`, help-show.js: hostElement). The list shows the host's own questions and the built-in * ones marked `top`, at most HELP_LIST; "All questions" below them opens every question in its group, * and the search finds every question (helpList). */ import { fill } from "./labels.js"; import { warnOnce } from "./warn-once.js"; /** @typedef {{ en: string, de: string, from?: "en" }} Text `from`: the German is the English text (a host's, textLang) */ /** * @typedef {"save" | "link" | "viewsInMore" | "dataInMore" | "startOverInMore" | "zonesFolded" | "tableHidden" | "chartHidden"} Now * @typedef {{ en: string, de: string, needs?: Now | Now[], unless?: Now }} Step * `needs`: shown only where the report offers saving or a link, a button is in More now, the zones * are folded away or the other tab shows (each of a list); `unless`: not where that holds */ /** * @typedef {object} HelpTopic * @property {string} id * @property {"fields" | "filter" | "table" | "chart" | "values" | "export"} group * @property {Text} question * @property {Text} [keywords] more words the search finds it by * @property {Step[]} steps * @property {string} docs the page under docs/ and its heading anchor (tests/help-docs.test.js checks both) * @property {"drillDown" | "share" | "import" | "fullScreen" | "date" | "number"} [needs] shown only where the report offers it, or where its data has a field of that type * @property {true} [top] one of the questions the list shows first */ /** The groups of the questions, in order. */ export const HELP_GROUPS = Object.freeze(["fields", "filter", "table", "chart", "values", "export"]); /** The help's own words. */ export const HELP_TEXTS = Object.freeze({ en: { search: "Search the questions", nothing: "No question matches.", clear: "Clear the search to see all questions", groups: { general: "General", fields: "Fields", filter: "Filter and sort", table: "Table", chart: "Chart", values: "Values", export: "Export and more" }, all: "All questions", showMe: "Show me", readMore: "Read more in the docs", newTab: "(opens in a new tab)", noAxis: "There is no field in {rows} or {columns} yet. Add one first.", noRows: "There is no field in {rows} yet. Add one first.", noValue: "There is no value in {values} yet. Add one first.", needDate: "There is no date field in {rows} or {columns} yet. This data has one: “{field}”. “{showMe}” first shows you how to add it to {rows}.", needNumber: "There is no number field in {rows} or {columns} yet. This data has one: “{field}”. “{showMe}” first shows you how to add it to {rows}.", noField: "This report has no fields.", noLink: "This report offers no link to share a view.", noSubtotals: "There are no subtotals now: they show with two or more fields in {rows} or {columns}.", noGroups: "There is nothing to expand or collapse now: that needs two or more fields in {rows}.", atStart: "The report shows its start view now, so “{reset}” has nothing to do.", nothingToUndo: "There is nothing to undo yet: “{undo}” works once the report has changed.", stepOf: "Step {n} of {m}", doIt: "Do it for me", done: "Done", noTarget: "There is nothing to show on this page.", moved: "Help is now under {more}." }, de: { search: "Fragen durchsuchen", nothing: "Keine Frage passt.", clear: "Suche leeren, um alle Fragen zu sehen", groups: { general: "Allgemein", fields: "Felder", filter: "Filtern und sortieren", table: "Tabelle", chart: "Diagramm", values: "Werte", export: "Export und mehr" }, all: "Alle Fragen", showMe: "Zeig es mir", readMore: "Mehr in der Doku (Englisch)", newTab: "(öffnet in einem neuen Tab)", noAxis: "In {rows} oder {columns} steht noch kein Feld. Füge zuerst eines hinzu.", noRows: "In {rows} steht noch kein Feld. Füge zuerst eines hinzu.", noValue: "In {values} steht noch kein Wert. Füge zuerst einen hinzu.", needDate: "In {rows} oder {columns} steht noch kein Datumsfeld. Diese Daten haben eines: „{field}“. „{showMe}“ zeigt dir zuerst, wie du es zu {rows} hinzufügst.", needNumber: "In {rows} oder {columns} steht noch kein Zahlenfeld. Diese Daten haben eines: „{field}“. „{showMe}“ zeigt dir zuerst, wie du es zu {rows} hinzufügst.", noField: "Dieser Bericht hat keine Felder.", noLink: "Dieser Bericht bietet keinen Link zum Teilen einer Ansicht.", noSubtotals: "Gerade gibt es keine Teilergebnisse: Es gibt sie erst mit zwei oder mehr Feldern in {rows} oder {columns}.", noGroups: "Gerade gibt es nichts auf- oder zuzuklappen: Dafür braucht es zwei oder mehr Felder in {rows}.", atStart: "Der Bericht zeigt gerade seine Startansicht, „{reset}“ hat also nichts zu tun.", nothingToUndo: "Noch gibt es nichts rückgängig zu machen: „{undo}“ geht, sobald sich der Bericht geändert hat.", stepOf: "Schritt {n} von {m}", doIt: "Für mich erledigen", done: "Fertig", noTarget: "Auf dieser Seite gibt es dazu nichts zu zeigen.", moved: "Die Hilfe ist jetzt unter {more}." } }); /** The first step of a question about a field's menu where the zones are folded away (a phone). */ const ZONES_FOLDED = Object.freeze({ en: "{rows}, {columns} and {values} are folded away now: open “{zonesTitle}” first.", de: "{rows}, {columns} und {values} sind gerade eingeklappt: Öffne zuerst „{zonesTitle}“.", needs: "zonesFolded" }); /** A field's menu, and a value's. */ const AXIS_MENU = Object.freeze({ en: "Click a field in {rows} or {columns}: its menu opens.", de: "Klicke auf ein Feld in {rows} oder {columns}: Sein Menü öffnet sich." }); const VALUE_MENU = Object.freeze({ en: "Click a value in {values}: its menu opens.", de: "Klicke auf einen Wert in {values}: Sein Menü öffnet sich." }); /** The tab to show first where the other one shows. */ const TABLE_FIRST = Object.freeze({ en: "The table is not shown now: switch to the tab “{table}” first.", de: "Die Tabelle ist gerade nicht zu sehen: Wechsle zuerst zum Tab „{table}“.", needs: "tableHidden" }); const CHART_FIRST = Object.freeze({ en: "The chart is not shown now: switch to the tab “{chart}” first.", de: "Das Diagramm ist gerade nicht zu sehen: Wechsle zuerst zum Tab „{chart}“.", needs: "chartHidden" }); /** The settings above the result; on a phone their button shows its icon alone. */ const TABLE_SETTINGS = Object.freeze({ en: "Open “{tableSettings}” above the table, at the right. On a phone, it shows its icon alone.", de: "Öffne „{tableSettings}“ über der Tabelle, rechts. Am Handy zeigt der Knopf nur sein Symbol." }); const CHART_SETTINGS = Object.freeze({ en: "Open “{chartSettings}” above the chart, at the right. On a phone, it shows its icon alone.", de: "Öffne „{chartSettings}“ über dem Diagramm, rechts. Am Handy zeigt der Knopf nur sein Symbol." }); /** * What the card of "Show me" says at a step that is not one of the answer's (help-show.js): a control * to open, by `{name}`, the words it shows (help-guide.jsx fills them in from the control). */ export const CARD = Object.freeze({ openMenu: { en: "Click “{name}” to open its menu.", de: "Klicke auf „{name}“, um das Menü zu öffnen." }, choose: { en: "Choose “{name}”.", de: "Wähle „{name}“." }, fieldMenu: { en: "Click the dots next to “{field}” to open its menu.", de: "Klicke auf die Punkte neben „{field}“, um das Menü zu öffnen." }, notPlaced: { en: "“{field}” is not in the report yet. Click the dots next to it to open its menu.", de: "„{field}“ ist noch nicht im Bericht. Klicke auf die Punkte daneben, um das Menü zu öffnen." }, click: { en: "Click “{name}”.", de: "Klicke auf „{name}“." }, chartType: { en: "Pick a chart type under “{chartType}”.", de: "Wähle unter „{chartType}“ eine Art." }, nameView: { en: "Give the view a name and save it.", de: "Gib der Ansicht einen Namen und speichere sie." }, addToRows: { en: "Choose “{addToRows}”. This adds the field to your report.", de: "Wähle „{addToRows}“. Das fügt das Feld deinem Bericht hinzu." }, openFields: { en: "Click “{name}”: the field list opens.", de: "Klicke auf „{name}“: Die Feldliste öffnet sich." }, zones: ZONES_FOLDED, tableFirst: TABLE_FIRST, chartFirst: CHART_FIRST }); /** @type {ReadonlyArray} */ export const HELP_TOPICS = Object.freeze([ { id: "add-field", group: "fields", top: true, question: { en: "How do I add a field?", de: "Wie füge ich ein Feld hinzu?" }, keywords: { en: "drag drop place put field list", de: "ziehen ablegen platzieren feldliste" }, steps: [ { en: "Drag a field from the field list into {rows}, {columns} or {values}.", de: "Ziehe ein Feld aus der Feldliste in {rows}, {columns} oder {values}." }, { en: "Without dragging: open “{optionsFor}” (⋯) next to the field and choose “{addToRows}”.", de: "Ohne Ziehen: Öffne „{optionsFor}“ (⋯) neben dem Feld und wähle „{addToRows}“." } ], docs: "use/fields.md#adding-fields" }, { id: "filter", group: "filter", top: true, question: { en: "How do I filter?", de: "Wie filtere ich?" }, keywords: { en: "exclude hide remove leave out values pick", de: "ausschließen ausblenden entfernen weglassen werte auswählen" }, steps: [ ZONES_FOLDED, AXIS_MENU, { en: "Choose “{filter}”.", de: "Wähle „{filter}“." }, { en: "Untick the values to leave out. Each change applies at once, and {undo} takes it back.", de: "Entferne die Haken bei den Werten, die wegfallen sollen. Jede Änderung gilt sofort, {undo} nimmt sie zurück." } ], docs: "use/filters.md#filter-by-values" }, { id: "date-range", group: "filter", top: true, question: { en: "How do I show only a date range?", de: "Wie zeige ich nur einen Zeitraum?" }, keywords: { en: "dates period month year last days", de: "datum periode monat jahr letzte tage" }, steps: [ ZONES_FOLDED, { en: "Click a date field in {rows} or {columns}: its menu opens.", de: "Klicke auf ein Datumsfeld in {rows} oder {columns}: Sein Menü öffnet sich." }, { en: "Choose “{filter}”, then a choice under “{quickChoices}”, such as the last 3 months.", de: "Wähle „{filter}“ und dann unter „{quickChoices}“ etwa die letzten 3 Monate." }, { en: "Is the date not in the report? Open “{optionsFor}” (⋯) in the field list and choose “{addToFilters}”.", de: "Steht das Datum nicht im Bericht? Öffne „{optionsFor}“ (⋯) in der Feldliste und wähle „{addToFilters}“." } ], docs: "use/filters.md#quick-choices-for-dates", needs: "date" }, { id: "top-n", group: "filter", top: true, question: { en: "How do I show only the top 10?", de: "Wie zeige ich nur die obersten 10?" }, keywords: { en: "best largest highest ranking bottom", de: "top zehn beste größte höchste rangliste unterste" }, steps: [ ZONES_FOLDED, { en: "Click a field in {rows}: its menu opens.", de: "Klicke auf ein Feld in {rows}: Sein Menü öffnet sich." }, { en: "Choose “{topItems}”, then “{top10}” or a count of your own.", de: "Wähle „{topItems}“ und dann „{top10}“ oder eine eigene Anzahl." } ], docs: "use/filters.md#top-n" }, { id: "sort-value", group: "filter", top: true, question: { en: "How do I sort by the numbers?", de: "Wie sortiere ich nach den Zahlen?" }, keywords: { en: "sort order largest smallest value descending ascending", de: "sortieren reihenfolge größte kleinste wert absteigend aufsteigend" }, steps: [ ZONES_FOLDED, AXIS_MENU, { en: "Choose “{sortLargest}” or “{sortSmallest}”. With two or more values, they are under “{sortByValue}”. A click on the header of a value's column in the table sorts too.", de: "Wähle „{sortLargest}“ oder „{sortSmallest}“. Bei zwei oder mehr Werten stehen sie unter „{sortByValue}“. Ein Klick auf den Kopf der Spalte eines Werts in der Tabelle sortiert auch." } ], docs: "use/filters.md#sorting" }, { id: "group-dates", group: "filter", top: true, question: { en: "How do I group dates by month or year?", de: "Wie gruppiere ich Daten nach Monat oder Jahr?" }, keywords: { en: "group dates month year quarter week day", de: "gruppieren datum monat jahr quartal woche tag" }, steps: [ ZONES_FOLDED, { en: "Click a date field in {rows} or {columns}: its menu opens.", de: "Klicke auf ein Datumsfeld in {rows} oder {columns}: Sein Menü öffnet sich." }, { en: "Choose “{group}”.", de: "Wähle „{group}“." }, { en: "Choose a unit, such as months or years.", de: "Wähle eine Einheit, etwa Monate oder Jahre." } ], docs: "use/values.md#dates-and-number-ranges", needs: "date" }, { id: "filter-rule", group: "filter", question: { en: "How do I filter by a rule, such as a total over 100?", de: "Wie filtere ich nach einer Regel, etwa Gesamtwert über 100?" }, keywords: { en: "rule condition greater less than total name contains", de: "regel bedingung größer kleiner als gesamtwert name enthält" }, steps: [ ZONES_FOLDED, AXIS_MENU, { en: "Choose “{filter}”, then “{addRuleTotal}” under “{rulesTitle}”.", de: "Wähle „{filter}“ und dann unter „{rulesTitle}“ „{addRuleTotal}“." }, { en: "Pick a comparison and type the number, such as 100.", de: "Wähle einen Vergleich und tippe die Zahl ein, etwa 100." } ], docs: "use/filters.md#value-filter" }, { id: "number-ranges", group: "filter", question: { en: "How do I group numbers into ranges?", de: "Wie gruppiere ich Zahlen in Bereiche?" }, keywords: { en: "bins buckets intervals histogram group numbers", de: "klassen intervalle histogramm gruppieren zahlen" }, steps: [ ZONES_FOLDED, { en: "Click a number field in {rows} or {columns}: its menu opens.", de: "Klicke auf ein Zahlenfeld in {rows} oder {columns}: Sein Menü öffnet sich." }, { en: "Choose “{bins}” and set “{binSize}”: how wide each range is.", de: "Wähle „{bins}“ und gib „{binSize}“ an: wie breit jeder Bereich ist." } ], docs: "use/values.md#number-ranges", needs: "number" }, { id: "drill-down", group: "table", top: true, question: { en: "Which rows are behind a number?", de: "Welche Zeilen stecken hinter einer Zahl?" }, keywords: { en: "details records source data drill down", de: "details datensätze quelldaten drilldown" }, steps: [ { en: "Click a number in the table, or move to it with the arrow keys and press Enter.", de: "Klicke auf eine Zahl in der Tabelle, oder gehe mit den Pfeiltasten hin und drücke Enter." }, { en: "The panel “{drillTitle}” lists them.", de: "Der Bereich „{drillTitle}“ listet sie auf." } ], docs: "use/drill-down.md#open-and-close-the-panel", needs: "drillDown" }, { id: "subtotals", group: "table", question: { en: "How do I hide subtotals?", de: "Wie blende ich Teilergebnisse aus?" }, keywords: { en: "subtotal total rows group", de: "teilergebnis summe zwischensumme zeilen gruppe" }, steps: [ TABLE_FIRST, TABLE_SETTINGS, { en: "Untick “{rowSubtotals}” or “{colSubtotals}”. They show only with two or more fields in {rows} or {columns}.", de: "Entferne den Haken bei „{rowSubtotals}“ oder „{colSubtotals}“. Es gibt sie nur mit zwei oder mehr Feldern in {rows} oder {columns}." } ], docs: "use/fields.md#the-table" }, { id: "grand-totals", group: "table", question: { en: "How do I show or hide the grand totals?", de: "Wie blende ich die Gesamtergebnisse ein oder aus?" }, keywords: { en: "grand total sum last row column", de: "gesamtergebnis summe gesamt letzte zeile spalte" }, steps: [TABLE_FIRST, TABLE_SETTINGS, { en: "Tick or untick “{grandTotalRow}” and “{grandTotalColumn}”.", de: "Setze oder entferne den Haken bei „{grandTotalRow}“ und „{grandTotalColumn}“." }], docs: "use/fields.md#the-table" }, { id: "expand-collapse", group: "table", question: { en: "How do I expand or collapse all groups?", de: "Wie klappe ich alle Gruppen auf oder zu?" }, keywords: { en: "expand collapse fold open close groups details", de: "aufklappen zuklappen öffnen schließen gruppen details" }, steps: [ TABLE_FIRST, TABLE_SETTINGS, { en: "Choose “{collapseAll}” or “{expandAll}”. Both need two or more fields in {rows}. The arrow next to a group in the table expands or collapses that group alone.", de: "Wähle „{collapseAll}“ oder „{expandAll}“. Beide brauchen zwei oder mehr Felder in {rows}. Der Pfeil neben einer Gruppe in der Tabelle klappt nur diese Gruppe auf oder zu." } ], docs: "use/fields.md#the-table" }, { id: "swap", group: "table", question: { en: "How do I swap rows and columns?", de: "Wie tausche ich Zeilen und Spalten?" }, keywords: { en: "swap switch transpose pivot flip axes", de: "tauschen vertauschen transponieren drehen achsen" }, steps: [{ en: "Click “{swap}” in the heading row of “{zonesTitle}”. On a phone, it shows its icon alone.", de: "Klicke auf „{swap}“ in der Kopfzeile von „{zonesTitle}“. Am Handy zeigt der Knopf nur sein Symbol." }], docs: "use/fields.md#the-table" }, { id: "chart", group: "chart", top: true, question: { en: "How do I make a chart?", de: "Wie mache ich ein Diagramm?" }, keywords: { en: "chart graph plot diagram bars lines pie", de: "diagramm grafik balken linien kreis" }, steps: [ { en: "Switch to the tab “{chart}”, or on a wide report “{both}”.", de: "Wechsle zum Tab „{chart}“, auf einem breiten Bericht auch „{both}“." }, { en: "Open “{chartSettings}” and pick a chart type under “{chartType}”.", de: "Öffne „{chartSettings}“ und wähle unter „{chartType}“ eine Art." } ], docs: "use/charts.md#chart-types" }, { id: "chart-type", group: "chart", question: { en: "How do I change the chart type?", de: "Wie ändere ich den Diagrammtyp?" }, keywords: { en: "bars lines pie donut area heatmap treemap type kind", de: "balken linien kreis ring fläche heatmap treemap typ art" }, steps: [CHART_FIRST, CHART_SETTINGS, { en: "Pick a type under “{chartType}”, such as “{lines}”.", de: "Wähle unter „{chartType}“ eine Art, etwa „{lines}“." }], docs: "use/charts.md#chart-types" }, { id: "value-labels", group: "chart", question: { en: "How do I show the numbers on the chart?", de: "Wie zeige ich die Zahlen im Diagramm?" }, keywords: { en: "value labels numbers data labels on bars", de: "wertbeschriftung zahlen beschriftung balken" }, steps: [CHART_FIRST, CHART_SETTINGS, { en: "Open “{valueLabels}” and choose “{valueLabelValue}”.", de: "Öffne „{valueLabels}“ und wähle „{valueLabelValue}“." }], docs: "use/charts.md#display-settings" }, { id: "legend", group: "chart", question: { en: "How do I show or hide the legend?", de: "Wie blende ich die Legende ein oder aus?" }, keywords: { en: "legend series names key", de: "legende reihen namen" }, steps: [CHART_FIRST, CHART_SETTINGS, { en: "Open “{legend}” and choose where it goes, or “{legendOff}”.", de: "Öffne „{legend}“ und wähle, wo sie steht, oder „{legendOff}“." }], docs: "use/charts.md#display-settings" }, { id: "chart-title", group: "chart", question: { en: "How do I change the chart's title or axis labels?", de: "Wie ändere ich Titel oder Achsenbeschriftung des Diagramms?" }, keywords: { en: "title heading axis labels slanted", de: "titel überschrift achse beschriftung schräg" }, steps: [ CHART_FIRST, CHART_SETTINGS, { en: "Open “{chartTitle}” and type a title. “{chartAxis}” there sets how the labels along the axis show.", de: "Öffne „{chartTitle}“ und tippe einen Titel ein. „{chartAxis}“ legt dort fest, wie die Beschriftungen an der Achse erscheinen." } ], docs: "use/charts.md#display-settings" }, { id: "reference-line", group: "chart", question: { en: "How do I add a reference line, such as the average?", de: "Wie füge ich eine Bezugslinie hinzu, etwa den Durchschnitt?" }, keywords: { en: "reference line average trend target goal mean", de: "bezugslinie durchschnitt trend ziel mittelwert" }, steps: [CHART_FIRST, CHART_SETTINGS, { en: "Open “{referenceLines}” and tick “{average}” or “{trend}”.", de: "Öffne „{referenceLines}“ und setze den Haken bei „{average}“ oder „{trend}“." }], docs: "use/charts.md#reference-lines" }, { id: "chart-image", group: "chart", question: { en: "How do I save the chart as a picture?", de: "Wie speichere ich das Diagramm als Bild?" }, keywords: { en: "image picture png svg screenshot save chart", de: "bild grafik png svg bildschirmfoto speichern" }, steps: [CHART_FIRST, { en: "Open “{exportLabel}” and choose “{png}” or “{svg}”.", de: "Öffne „{exportLabel}“ und wähle „{png}“ oder „{svg}“." }], docs: "use/charts.md#save-the-chart-as-a-picture" }, { id: "percent", group: "values", top: true, question: { en: "How do I show percentages?", de: "Wie zeige ich Prozente?" }, keywords: { en: "percent share % of total", de: "prozent anteil % von gesamt" }, steps: [ZONES_FOLDED, VALUE_MENU, { en: "Choose “{showAs}”, then “{grandTotal}”.", de: "Wähle „{showAs}“ und dann „{grandTotal}“." }], docs: "use/values.md#show-as" }, { id: "summarize", group: "values", question: { en: "How do I show a sum instead of a count or average?", de: "Wie zeige ich eine Summe statt Anzahl oder Durchschnitt?" }, keywords: { en: "sum count average total minimum maximum aggregate", de: "summe anzahl durchschnitt minimum maximum zusammenfassen" }, steps: [ZONES_FOLDED, VALUE_MENU, { en: "Choose “{aggregation}”, then “{sum}”.", de: "Wähle „{aggregation}“ und dann „{sum}“." }], docs: "use/values.md#summarize-by" }, { id: "number-format", group: "values", question: { en: "How do I change the number format?", de: "Wie ändere ich das Zahlenformat?" }, keywords: { en: "format decimals currency percent euro dollar", de: "format nachkommastellen dezimalstellen währung prozent euro" }, steps: [ZONES_FOLDED, VALUE_MENU, { en: "Choose “{format}”, then a format such as “{currency}”.", de: "Wähle „{format}“ und dann ein Format wie „{currency}“." }], docs: "use/values.md#number-format" }, { id: "highlight", group: "values", question: { en: "How do I colour cells by their value?", de: "Wie färbe ich Zellen nach ihrem Wert?" }, keywords: { en: "colour color highlight heat scale data bars conditional formatting", de: "farbe färben hervorheben farbskala datenbalken bedingte formatierung" }, steps: [ZONES_FOLDED, VALUE_MENU, { en: "Under “{conditional}”, choose “{colorScale}” or “{dataBar}”.", de: "Wähle unter „{conditional}“ „{colorScale}“ oder „{dataBar}“." }], docs: "use/values.md#highlight" }, { id: "rename", group: "values", question: { en: "How do I rename a field or a value?", de: "Wie benenne ich ein Feld oder einen Wert um?" }, keywords: { en: "rename name label title caption", de: "umbenennen name bezeichnung titel" }, steps: [ ZONES_FOLDED, { en: "Click a field or a value in {rows}, {columns} or {values}: its menu opens.", de: "Klicke auf ein Feld oder einen Wert in {rows}, {columns} oder {values}: Sein Menü öffnet sich." }, { en: "Choose “{rename}” and type the new name.", de: "Wähle „{rename}“ und tippe den neuen Namen ein." } ], docs: "use/values.md#name" }, { id: "export", group: "export", top: true, question: { en: "How do I export to Excel?", de: "Wie exportiere ich nach Excel?" }, keywords: { en: "excel xlsx download spreadsheet", de: "excel xlsx herunterladen tabelle" }, steps: [ { en: "Open “{exportLabel}” and choose “{xlsx}”.", de: "Öffne „{exportLabel}“ und wähle „{xlsx}“." }, { en: "The same menu has CSV, a web page, printing and the chart as a picture.", de: "Im selben Menü gibt es CSV, eine Webseite, Drucken und das Diagramm als Bild." } ], docs: "use/export.md#what-each-one-holds" }, { id: "export-csv", group: "export", question: { en: "How do I export to CSV or a web page?", de: "Wie exportiere ich als CSV oder Webseite?" }, keywords: { en: "csv html web page text download", de: "csv html webseite text herunterladen" }, steps: [{ en: "Open “{exportLabel}” and choose “{csv}” or “{html}”.", de: "Öffne „{exportLabel}“ und wähle „{csv}“ oder „{html}“." }], docs: "use/export.md#what-each-one-holds" }, { id: "print", group: "export", question: { en: "How do I print or save as PDF?", de: "Wie drucke ich oder speichere als PDF?" }, keywords: { en: "print pdf paper printer", de: "drucken pdf papier drucker" }, steps: [ { en: "Open “{exportLabel}” and choose “{print}”. In the browser's print dialog, print the report or choose to save it as a PDF.", de: "Öffne „{exportLabel}“ und wähle „{print}“. Im Druckdialog des Browsers druckst du den Bericht oder speicherst ihn als PDF." } ], docs: "use/export.md#what-each-one-holds" }, { id: "share", group: "export", top: true, question: { en: "How do I save or share a view?", de: "Wie speichere oder teile ich eine Ansicht?" }, keywords: { en: "save share link url send bookmark", de: "speichern teilen link adresse senden lesezeichen" }, steps: [ { en: "“{views}” is under “{more}” now: open “{more}”, then “{views}…”.", de: "„{views}“ steht gerade unter „{more}“: Öffne „{more}“ und dann „{views}…“.", needs: "viewsInMore" }, { en: "Open “{views}” and choose “{saveView}…” to keep this view.", de: "Öffne „{views}“ und wähle „{saveView}…“, um diese Ansicht zu behalten.", needs: "save", unless: "viewsInMore" }, { en: "There, “{saveView}…” keeps this view.", de: "Dort behält „{saveView}…“ diese Ansicht.", needs: ["save", "viewsInMore"] }, { en: "“{copyLink}” under “{views}” copies an address that opens the same report.", de: "„{copyLink}“ unter „{views}“ kopiert eine Adresse, die denselben Bericht öffnet.", needs: "link" } ], docs: "use/views.md#share-a-view", needs: "share" }, { id: "load-data", group: "export", top: true, question: { en: "How do I use my own file?", de: "Wie nutze ich meine eigene Datei?" }, keywords: { en: "load import open upload csv json excel file data", de: "laden importieren öffnen hochladen csv json excel datei daten" }, steps: [ { en: "“{data}” is under “{more}” now: open “{more}”, then “{data}…”.", de: "„{data}“ steht gerade unter „{more}“: Öffne „{more}“ und dann „{data}…“.", needs: "dataInMore" }, { en: "Drop a CSV, JSON or Excel file onto the report, or open “{data}” and choose “{loadData}”. The file is read in this browser. Nothing is uploaded.", de: "Ziehe eine CSV-, JSON- oder Excel-Datei auf den Bericht, oder öffne „{data}“ und wähle „{loadData}“. Die Datei wird in diesem Browser gelesen. Nichts wird hochgeladen." } ], docs: "use/load-data.md#load-a-file", needs: "import" }, { id: "undo", group: "export", question: { en: "How do I undo a step?", de: "Wie mache ich einen Schritt rückgängig?" }, keywords: { en: "undo redo back revert mistake", de: "rückgängig wiederholen zurück fehler" }, steps: [{ en: "Click “{undo}” in the toolbar, or press {undoKeys}. “{redo}” next to it repeats the step.", de: "Klicke in der Werkzeugleiste auf „{undo}“, oder drücke {undoKeys}. „{redo}“ daneben wiederholt den Schritt." }], docs: "use/views.md#undo-redo-start-over" }, { id: "start-over", group: "export", question: { en: "How do I start over?", de: "Wie fange ich neu an?" }, keywords: { en: "start over reset new empty clear begin again", de: "neu beginnen zurücksetzen leer anfangen" }, steps: [ { en: "Open “{more}” and choose “{reset}” to go back to the start view. On a narrow report, “{startOver}” is there.", de: "Öffne „{more}“ und wähle „{reset}“, um zur Startansicht zurückzukehren. Auf einem schmalen Bericht steht „{startOver}“ dort.", needs: "startOverInMore" }, { en: "Open “{startOver}” and choose “{reset}” to go back to the start view.", de: "Öffne „{startOver}“ und wähle „{reset}“, um zur Startansicht zurückzukehren.", unless: "startOverInMore" }, { en: "“{newEmpty}” there empties the report. {undo} brings it back.", de: "„{newEmpty}“ leert dort den Bericht. {undo} holt ihn zurück." } ], docs: "use/views.md#start-over" }, { id: "full-screen", group: "export", question: { en: "How do I show the report on the full screen?", de: "Wie zeige ich den Bericht im Vollbild?" }, keywords: { en: "full screen fullscreen bigger enlarge maximize", de: "vollbild größer vergrößern maximieren" }, steps: [{ en: "Click “{fullScreen}” above the result, at the right. On a phone, it shows its icon alone. Escape or the same button leaves it.", de: "Klicke auf „{fullScreen}“ über dem Ergebnis, rechts. Am Handy zeigt der Knopf nur sein Symbol. Escape oder derselbe Knopf beendet es." }], docs: "use/layout.md#more-room-for-the-result", needs: "fullScreen" } ]); /** * The names a step may use, from the report's labels with the menus' texts: what each control shows. * @param {any} labels * @param {string} field the field a step is about, for "Options for {field}" * @param {string} [value] the value a sort goes by, for "Largest {value} first" * @param {string} [mod] "⌘" on a Mac, else "Ctrl+": the keys of Undo */ export function helpNames(labels, field, value = "…", mod = "Ctrl+") { const zone = (z) => fill(labels.addTo, { zone: labels.zones[z] }); const words = labels.core?.referenceLines ?? {}; return { rows: labels.zones.rows, columns: labels.zones.cols, values: labels.zones.values, zonesTitle: labels.zonesTitle, more: labels.more, field, optionsFor: fill(labels.fieldMenu, { field }), showMe: HELP_TEXTS[labels.lang === "de" ? "de" : "en"].showMe, addToRows: zone("rows"), addToFilters: zone("filters"), filter: labels.filterTopic, rulesTitle: labels.rulesTitle, addRuleTotal: labels.addRuleTotal, undo: labels.undo, redo: labels.redo, undoKeys: `${mod}Z`, quickChoices: labels.quickTitle, topItems: labels.topN, top10: fill(labels.topBadge, { count: 10 }), sortByValue: labels.sortByValue, sortLargest: fill(labels.sortValueDesc, { value }), sortSmallest: fill(labels.sortValueAsc, { value }), showAs: labels.showAs, grandTotal: labels.showAsNames?.percentOfGrandTotal, group: labels.groupTopic, bins: labels.bins, binSize: labels.binSize, aggregation: labels.aggregation, sum: labels.core?.aggregators?.sum, format: labels.format, currency: labels.formats?.currency, conditional: labels.conditional, colorScale: labels.colorScale, dataBar: labels.dataBar, rename: labels.rename, table: labels.table, tableSettings: labels.tableSettings, rowSubtotals: labels.rowSubtotals, colSubtotals: labels.colSubtotals, grandTotalRow: labels.grandTotalRow, grandTotalColumn: labels.grandTotalColumn, expandAll: labels.expandAll, collapseAll: labels.collapseAll, swap: labels.swap, chart: labels.chart, both: labels.both, chartSettings: labels.chartSettings, chartType: labels.chartType, lines: labels.chartTypes?.line, valueLabels: labels.valueLabels, valueLabelValue: labels.valueLabelNames?.value, legend: labels.legend, legendOff: labels.legendNames?.off, chartTitle: labels.chartTitle, chartAxis: labels.chartAxis, referenceLines: labels.referenceLines, average: words.average, trend: words.trend, drillTitle: labels.drillTitle, exportLabel: labels.exportLabel, xlsx: labels.exportXlsx, csv: labels.exportCsv, html: labels.exportHtml, png: labels.exportPng, svg: labels.exportSvg, print: labels.exportPrint, views: labels.views, saveView: labels.saveView, copyLink: labels.copyLink, data: labels.data, loadData: labels.loadData, startOver: labels.startOver, reset: labels.reset, newEmpty: labels.newEmpty, fullScreen: labels.fullScreen }; } /** * A text of the help with its names filled in. * @param {string} text * @param {Record} names */ export const helpText = (text, names) => fill(text, names); /** * The most questions the list shows before "All questions": the host's own first, then the built-in * ones marked `top`. Every question marked `top` fits (test/help.test.js). */ export const HELP_LIST = 12; /** The most own questions of a host, and the longest texts of one. */ export const OWN_LIMITS = Object.freeze({ count: 50, id: 64, question: 200, answer: 2000, group: 60 }); /** * @typedef {string | { en: string, de?: string }} HelpText one text for every language, or English and German * @typedef {object} HelpTopicInput a question of the host's own * @property {string} id letters, digits, "-" and "_"; not a built-in question's id * @property {HelpText} question * @property {HelpText} answer shown as text; a line break starts a paragraph * @property {HelpText} [group] a heading of its own, or a built-in group's id; without it "General" * @property {string | false} [docs] the address "Read more" opens, or false for none * @property {{ target: string, text?: HelpText }} [show] "Show me" rings the page's element with the id `target` (like `id`) and its card says `text`, else the answer's first paragraph * @typedef {{ builtIn?: boolean | string[], own?: HelpTopicInput[] }} HelpTopicsInput * @typedef {{ target: string, text: Text | null }} OwnShow * @typedef {{ id: string, own: true, group: string | Text, question: Text, answer: Text, docs?: string | false, show?: OwnShow }} OwnTopic */ /** The help's own test ids after "help-" (help-*.jsx), which no question may take. */ export const HELP_RESERVED = Object.freeze(["shortcuts", "search", "list", "all", "clear", "more", "nothing", "panel", "title", "back", "steps", "answer", "none", "note", "notice", "show", "card", "card-count", "card-text", "do", "done", "dim", "origin", "moved", "in-toolbar", "ring", "docs"]); /** Markup in a host's text ("<" and a letter, "/", "!" or "?"): the help shows text as it is, so a tag would show as written. */ const MARKUP = /<[a-z!/?]/i; /** * A host's text as { en, de } (one text for both, or `de` taken from `en`), or null where it is not * 1 to `max` characters of text without markup. * @param {any} value * @param {number} max * @returns {Text | null} */ function hostText(value, max) { // English alone: German shows it too, marked as English (`from`, textLang); one text is every language's const text = typeof value === "string" ? { en: value, de: value } : value?.de === undefined ? { en: value?.en, de: value?.en, from: /** @type {const} */ ("en") } : { en: value.en, de: value.de }; return [text.en, text.de].every((t) => typeof t === "string" && t.trim() && t.length <= max && !MARKUP.test(t)) ? text : null; } /** * The `lang` a host's text needs inside the help (which has the report's): "en" where a German report * shows its English text (#1133), else none. * @param {Text} text * @param {"en" | "de"} lang */ export const textLang = (text, lang) => (lang === "de" && text.from === "en" ? "en" : undefined); /** * A host's group as a built-in group's id where its text names one in either language, whatever the * case and the spaces around it (#1134): "Fields" joins the built-in Fields, not a second section. * @param {Text} text * @returns {string | Text} */ function groupOf(text) { const same = (/** @type {string} */ a, /** @type {string} */ b) => a.trim().toLocaleLowerCase() === b.toLocaleLowerCase(); const key = Object.keys(HELP_TEXTS.en.groups).find((k) => [text.en, text.de].some((t) => same(t, HELP_TEXTS.en.groups[k]) || same(t, HELP_TEXTS.de.groups[k]))); return key ?? text; } /** A host's group: its text, as a built-in group's id where it names one (groupOf); null where it is wrong. @param {unknown} group */ const groupText = (group) => { const text = hostText(group, OWN_LIMITS.group); return text && groupOf(text); }; /** One id: what an own question's `id` and its `show.target` may be. */ const ID = /^[\w-]+$/; /** Whether a value is an id of 1 to OWN_LIMITS.id letters, digits, "-" or "_". @param {unknown} value */ const isId = (value) => typeof value === "string" && ID.test(value) && value.length <= OWN_LIMITS.id; /** * An own question's `show` checked: { target, text } (text null: the answer's), or null where it is * wrong. Only an id, never a selector: the report looks it up with getElementById. * @param {any} show * @returns {OwnShow | null} */ function ownShow(show) { const text = show?.text === undefined ? null : hostText(show.text, OWN_LIMITS.question); return isId(show?.target) && (show.text === undefined || text) ? { target: show.target, text } : null; } /** * An own question checked, or what is wrong with it. * @param {any} entry * @param {Set} taken the ids so far * @returns {OwnTopic | string} */ function ownTopic(entry, taken) { const { id, group = "general", docs, show } = entry ?? {}; if (!isId(id)) { return `id must be 1 to ${OWN_LIMITS.id} letters, digits, "-" or "_"`; } if (taken.has(id)) { return `id "${id}" is taken: by a built-in question, a part of the help or an own question before it`; } const topic = { id, own: /** @type {const} */ (true), group: typeof group === "string" && Object.hasOwn(HELP_TEXTS.en.groups, group) ? group : groupText(group), question: hostText(entry.question, OWN_LIMITS.question), answer: hostText(entry.answer, OWN_LIMITS.answer), docs }; const wrong = /** @type {Array<"group" | "question" | "answer">} */ (["question", "answer", "group"]).find((key) => !topic[key]); if (wrong) { return `${wrong} must be 1 to ${OWN_LIMITS[wrong]} characters of text or { en, de }, without markup${wrong === "group" ? ", or a built-in group's id" : ""}`; } if (docs !== undefined && docs !== false && typeof docs !== "string") { return "docs must be an address or false"; } if (show === undefined) { return /** @type {OwnTopic} */ (topic); } const checked = ownShow(show); return checked ? /** @type {OwnTopic} */ ({ ...topic, show: checked }) : `show must be { target, text? }: target an element's id of 1 to ${OWN_LIMITS.id} letters, digits, "-" or "_", text 1 to ${OWN_LIMITS.question} characters of text or { en, de }, without markup`; } /** * What the card of an own question's "Show me" says: its `show.text`, else the answer's first * paragraph, cut after a word to the length of a question (OWN_LIMITS.question) with "…". * @param {OwnTopic & { show: OwnShow }} topic * @param {"en" | "de"} lang */ export function ownCardText(topic, lang) { if (topic.show.text) { return topic.show.text[lang]; } const first = topic.answer[lang].split(/\n+/).find((line) => line.trim()) ?? ""; if (first.length <= OWN_LIMITS.question) { return first; } const cut = first.lastIndexOf(" ", OWN_LIMITS.question - 1); return `${first.slice(0, cut > 0 ? cut : OWN_LIMITS.question - 1)}…`; } /** * The questions of the help for the host's `helpTopics`: its own first, then the built-in ones * (`builtIn`: true all, false none, a list only those). What is wrong is left out and said once in * the console; a wrong shape gives the built-in questions. * @param {unknown} input * @returns {Array} */ export function helpTopicsOf(input) { const warn = (/** @type {string} */ text) => warnOnce(`pivotkit: helpTopics${text}`); const shaped = input === undefined || input === null || (typeof input === "object" && !Array.isArray(input)); if (!shaped) { warn(" must be { builtIn, own }; the built-in questions show"); } let { builtIn = true, own = [] } = shaped ? /** @type {any} */ (input ?? {}) : {}; if (typeof builtIn !== "boolean" && !Array.isArray(builtIn)) { warn(".builtIn must be true, false or a list of ids; every built-in question shows"); builtIn = true; } if (!Array.isArray(own)) { warn(".own must be a list of questions"); own = []; } for (const id of Array.isArray(builtIn) ? builtIn : []) { if (!HELP_TOPICS.some((t) => t.id === id)) { warn(`.builtIn has no question "${id}"`); } } if (own.length > OWN_LIMITS.count) { warn(`.own holds more than ${OWN_LIMITS.count} questions; the first ${OWN_LIMITS.count} show`); } // the built-in ids, and the help's own parts: a row's test id is help- const taken = new Set([...HELP_RESERVED, ...HELP_TOPICS.map((t) => t.id)]); /** @type {OwnTopic[]} */ const mine = []; own.slice(0, OWN_LIMITS.count).forEach((entry, i) => { const topic = ownTopic(entry, taken); if (typeof topic === "string") { warn(`.own[${i}]${typeof entry?.id === "string" ? ` "${entry.id.slice(0, OWN_LIMITS.id)}"` : ""} is left out: ${topic}`); } else { taken.add(topic.id); mine.push(topic); } }); return [...mine, ...HELP_TOPICS.filter((t) => builtIn === true || (Array.isArray(builtIn) && builtIn.includes(t.id)))]; } /** * Questions in sections by group: the host's own groups first (General and its headings, in the * order of their first question), then the built-in groups in HELP_GROUPS' order, the host's own * questions of a built-in group first in it. * @param {Array} topics */ export function helpSections(topics) { /** @type {Map>} */ const groups = new Map(); for (const topic of topics) { const key = typeof topic.group === "string" ? topic.group : `:${topic.group.en}`; groups.set(key, [...(groups.get(key) ?? []), topic]); } const rank = (/** @type {string} */ key) => HELP_GROUPS.indexOf(key); return [...groups].map(([key, list]) => ({ key, title: list[0].group, topics: list })).sort((a, b) => rank(a.key) - rank(b.key)); } /** Umlauts and ß as readers type them without those keys. */ const FOLDS = Object.freeze({ ä: "ae", ö: "oe", ü: "ue", ß: "ss" }); /** * The words of a text as the search compares them: in lower case, umlauts and ß written out (ä as ae), * split at anything that is not a letter, a digit or "%". * @param {string} text * @param {"en" | "de"} lang */ const wordsOf = (text, lang) => text .toLocaleLowerCase(lang) .replace(/[äöüß]/g, (c) => FOLDS[/** @type {keyof typeof FOLDS} */ (c)]) .split(/[^\p{L}\p{N}%]+/u) .filter(Boolean); /** * Whether a text holds every word searched at the start of one of its words (#1150): "bild" finds * "Bild", not "Vollbild"; "rueckgaengig" finds "Rückgängig". An empty search matches. * @param {string} text * @param {string} query * @param {"en" | "de"} lang */ export function helpMatch(text, query, lang) { const own = wordsOf(text, lang); return wordsOf(query, lang).every((word) => own.some((w) => w.startsWith(word))); } /** * The list: without a search, the host's own questions and the built-in ones marked `top` (where the * host picked none of those, its first built-in ones), at most HELP_LIST, with `more` where "All * questions" holds more; with one, every question whose text or keywords hold each word searched * (helpMatch). In sections by group (helpSections). * @param {Array} topics * @param {string} query * @param {"en" | "de"} lang */ export function helpList(topics, query, lang) { if (wordsOf(query, lang).length) { const text = (/** @type {HelpTopic | OwnTopic} */ t) => `${t.question[lang]} ${"keywords" in t && t.keywords ? t.keywords[lang] : ""}`; return { sections: helpSections(topics.filter((t) => helpMatch(text(t), query, lang))), more: false }; } const builtIn = /** @type {HelpTopic[]} */ (topics.filter((t) => !("own" in t))); const top = builtIn.some((t) => t.top) ? builtIn.filter((t) => t.top) : builtIn; const first = [...topics.filter((t) => "own" in t), ...top].slice(0, HELP_LIST); return { sections: helpSections(first), more: first.length < topics.length }; } /** * The address of a topic's docs. A built-in topic: the host's `docsUrl` - a base address (the page's * path and anchor follow it), a function of the topic's id, or false for none - else the pivotkit * docs site. An own topic: its own `docs`, else the host's function, else none. Only an http(s) * address, or one relative to the page, is a link; anything else (javascript:) gives none. A function * that throws gives none, said once in the console. * @param {HelpTopic | OwnTopic} topic * @param {string | ((id: string) => unknown) | false | undefined} docsUrl * @param {string} site the pivotkit docs site, with a trailing slash * @returns {string | null} */ export function docsHref(topic, docsUrl, site) { // asked only where its address is used; the host's mistake must not take the help down const fromHost = () => { try { return typeof docsUrl === "function" ? docsUrl(topic.id) : null; } catch { warnOnce("pivotkit: docsUrl threw: no docs link"); return null; } }; let href; if ("own" in topic) { href = topic.docs ?? fromHost(); } else if (docsUrl !== false) { const [page, anchor] = topic.docs.split("#"); const path = `${page.replace(/(^|\/)index\.md$/, "$1").replace(/\.md$/, "/")}#${anchor}`; href = typeof docsUrl === "function" ? fromHost() : `${(typeof docsUrl === "string" && docsUrl.trim() ? docsUrl.trim() : site).replace(/\/?$/, "/")}${path}`; } if (typeof href !== "string") { return null; } try { return /^https?:$/.test(new URL(href, "https://relative.invalid/").protocol) ? href : null; } catch { return null; } }