Skip to content

Commit

Permalink
feat: Corpus Updates select button
Browse files Browse the repository at this point in the history
Fixes #367
  • Loading branch information
arildm committed Dec 4, 2024
1 parent 6c4f503 commit f8e623d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 12 additions & 1 deletion app/scripts/components/corpus-updates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -17,6 +18,9 @@ export default angular.module("korpApp").component("corpusUpdates", {
<div>
<strong>{{corpus.title | locObj:$root.lang}}</strong>
{{"front_corpus_updated" | loc:$root.lang}}.
<button class="btn btn-xs btn-default" ng-click="selectCorpus(corpus.id)">
{{"toggle_select" | loc:$root.lang}}
</button>
</div>
</article>
Expand All @@ -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
Expand All @@ -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])
}
},
],
})
Expand All @@ -71,4 +81,5 @@ type CorpusUpdatesScope = IScope & {
recentUpdatesFiltered: CorpusTransformed[] | null
expanded: boolean
toggleExpanded: (to?: boolean) => void
selectCorpus: (corpusId: string) => void
}
4 changes: 1 addition & 3 deletions app/scripts/components/search-examples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions app/translations/locale-eng.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"show_deptree": "Show Dependency Tree",
"dep_tree": "Dependency Tree",
"download": "Download as",
"toggle_select": "select",

"is": "is",
"equal": "equal",
Expand Down
1 change: 1 addition & 0 deletions app/translations/locale-swe.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit f8e623d

Please sign in to comment.