Skip to content

Commit

Permalink
Fix map button disabled, fix #238
Browse files Browse the repository at this point in the history
  • Loading branch information
arildm committed Mar 7, 2024
1 parent 3a9c371 commit f61f7a6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
### Fixed

- Unnecessarily complex query when combining initial/medial/final part [#235](https://github.com/spraakbanken/korp-frontend/issues/235)
- Disable "Show map" button if no location data is available [#238](https://github.com/spraakbanken/korp-frontend/issues/238)
- Drop console error when loading page without `cqp` param

### Removed
Expand Down
19 changes: 13 additions & 6 deletions app/scripts/components/statistics.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,14 @@ export const statisticsComponent = {
auto-close="outsideClick"
ng-show="$ctrl.mapEnabled"
>
<button class="btn btn-sm btn-default" uib-dropdown-toggle>
<button
class="btn btn-sm btn-default"
uib-dropdown-toggle
ng-disabled="!$ctrl.mapAttributes.length"
uib-tooltip="{{'map_no_data' | loc:$root.lang}}"
tooltip-placement="right"
tooltip-enable="!$ctrl.mapAttributes.length"
>
{{'show_map' | loc:$root.lang}}<span class="caret"></span>
</button>
<div uib-dropdown-menu>
Expand Down Expand Up @@ -426,12 +433,12 @@ export const statisticsComponent = {
}
}

attrs = _.map(attrs, (val) => val)
if (attrs && attrs.length > 0) {
attrs[0].selected = true
}
$ctrl.mapAttributes = Object.values(attrs)

$ctrl.mapAttributes = attrs
// Select first attribute
if ($ctrl.mapAttributes.length) {
$ctrl.mapAttributes[0].selected = true
}
}

$ctrl.mapToggleSelected = function (index, event) {
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 @@ -100,6 +100,7 @@
"search_aborted": "The search was aborted",

"show_map": "Show map",
"map_no_data": "Selected corpora have no geographical data.",
"map_relative": "Relative",
"map_relative_help": "Make map marker sizes relative to location prevalence in the corpus selection.",
"map_name": "Place",
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 @@ -89,6 +89,7 @@
"word_pic_hits": "träffar",

"show_map": "Visa karta",
"map_no_data": "Valt material saknar geografisk data.",
"map_relative": "Relativ",
"map_relative_help": "Gör varje platsmarkörs storlek relativ till platsens förekomst i korpusurvalet.",
"map_name": "Plats",
Expand Down

0 comments on commit f61f7a6

Please sign in to comment.