From f8e623d74be00f53765cf1c1aa63c73daa0be4ce Mon Sep 17 00:00:00 2001 From: Arild Matsson Date: Wed, 4 Dec 2024 11:22:06 +0100 Subject: [PATCH] feat: Corpus Updates select button Fixes #367 --- CHANGELOG.md | 1 + app/scripts/components/corpus-updates.ts | 13 ++++++++++++- app/scripts/components/search-examples.ts | 4 +--- app/translations/locale-eng.json | 1 + app/translations/locale-swe.json | 1 + 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 741f84f5..b5995939 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Support `.env` - Simplify time interval CQP covering whole days [#379](https://github.com/spraakbanken/korp-frontend/issues/379) - Track some events with Matomo: search, language switch +- Select button in Corpus Updates section [#367](https://github.com/spraakbanken/korp-frontend/issues/367) ### Changed diff --git a/app/scripts/components/corpus-updates.ts b/app/scripts/components/corpus-updates.ts index af7b19be..e1ac59be 100644 --- a/app/scripts/components/corpus-updates.ts +++ b/app/scripts/components/corpus-updates.ts @@ -4,6 +4,7 @@ import moment from "moment" import settings from "@/settings" import { html } from "@/util" import { CorpusTransformed } from "@/settings/config-transformed.types" +import { RootScope } from "@/root-scope.types" export default angular.module("korpApp").component("corpusUpdates", { template: html` @@ -17,6 +18,9 @@ export default angular.module("korpApp").component("corpusUpdates", {
{{corpus.title | locObj:$root.lang}} {{"front_corpus_updated" | loc:$root.lang}}. +
@@ -35,8 +39,9 @@ export default angular.module("korpApp").component("corpusUpdates", { `, bindings: {}, controller: [ + "$rootScope", "$scope", - function ($scope: CorpusUpdatesScope) { + function ($rootScope: RootScope, $scope: CorpusUpdatesScope) { const $ctrl = this $scope.LIMIT = 5 @@ -61,6 +66,11 @@ export default angular.module("korpApp").component("corpusUpdates", { ? $scope.recentUpdates : $scope.recentUpdates!.slice(0, $scope.LIMIT) } + + $scope.selectCorpus = (corpusId: string) => { + settings.corpusListing.select([corpusId]) + $rootScope.$broadcast("corpuschooserchange", [corpusId]) + } }, ], }) @@ -71,4 +81,5 @@ type CorpusUpdatesScope = IScope & { recentUpdatesFiltered: CorpusTransformed[] | null expanded: boolean toggleExpanded: (to?: boolean) => void + selectCorpus: (corpusId: string) => void } diff --git a/app/scripts/components/search-examples.ts b/app/scripts/components/search-examples.ts index a9865367..79824388 100644 --- a/app/scripts/components/search-examples.ts +++ b/app/scripts/components/search-examples.ts @@ -5,7 +5,6 @@ import statemachine from "@/statemachine" import { html } from "@/util" import settings from "@/settings" import { SearchExample } from "@/settings/app-settings.types" -import { RootScope } from "@/root-scope.types" import { HashParams, LocationService } from "@/urlparams" import { CqpSearchEvent } from "@/statemachine/types" @@ -25,10 +24,9 @@ export default angular.module("korpApp").component("searchExamples", { `, bindings: {}, controller: [ - "$rootScope", "$scope", "$location", - function ($rootScope: RootScope, $scope: SearchExamplesScope, $location: LocationService) { + function ($scope: SearchExamplesScope, $location: LocationService) { const $ctrl = this $scope.examples = undefined diff --git a/app/translations/locale-eng.json b/app/translations/locale-eng.json index ce29653e..2292180f 100644 --- a/app/translations/locale-eng.json +++ b/app/translations/locale-eng.json @@ -79,6 +79,7 @@ "show_deptree": "Show Dependency Tree", "dep_tree": "Dependency Tree", "download": "Download as", + "toggle_select": "select", "is": "is", "equal": "equal", diff --git a/app/translations/locale-swe.json b/app/translations/locale-swe.json index f6cb8767..2bd8f1b2 100644 --- a/app/translations/locale-swe.json +++ b/app/translations/locale-swe.json @@ -79,6 +79,7 @@ "show_deptree": "Visa dependensträd", "dep_tree": "Dependensträd", "download": "Ladda ner som", + "toggle_select": "välj", "case_insensitive": "skiftlägesoberoende", "case_sensitive": "skiftlägesberoende",