Skip to content

Commit

Permalink
WIP: move tab-hash functionality to parents
Browse files Browse the repository at this point in the history
  • Loading branch information
arildm committed Sep 9, 2024
1 parent 2e20d3c commit 69d9f5a
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 102 deletions.
218 changes: 117 additions & 101 deletions app/scripts/components/results.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,117 +14,113 @@ import "@/components/sidebar"
import "@/components/tab-hash"
import "@/components/word-picture"
import "@/directives/tab-preloader"
import settings from "@/settings"

angular.module("korpApp").component("results", {
template: html`
<div>
<div id="results-wrapper" ng-show="$ctrl.hasResult()">
<div class="flex" id="columns" ng-class="{sidebar_visible : $ctrl.sidebarVisible}">
<div class="overflow-auto grow" id="left-column">
<tab-hash key="result_tab">
<uib-tabset class="tabbable result_tabs" active="activeTab">
<uib-tab kwic-ctrl index="0" select="onentry()" deselect="onexit()">
<uib-tab-heading ng-class="{not_loading: progress > 99, loading : loading}"
>KWIC<tab-preloader
ng-if="loading"
value="progress"
spinner="countCorpora() < 2"
></tab-preloader>
</uib-tab-heading>
<div
class="results-kwic"
ng-class="{reading_mode : reading_mode, loading: loading}"
>
<korp-error ng-if="error"></korp-error>
<kwic
ng-if="!error"
aborted="aborted"
loading="loading"
active="active"
hits-in-progress="hitsInProgress"
hits="hits"
kwic-input="kwic"
corpus-hits="corpusHits"
is-reading="reading_mode"
page="page"
page-event="pageChange"
context-change-event="toggleReading"
hits-per-page="hitsPerPage"
prev-params="proxy.prevParams"
prev-request="proxy.prevRequest"
corpus-order="corpusOrder"
></kwic>
</div>
</uib-tab>
<uib-tab
stats-result-ctrl
ng-if="$root._settings.statistics != false"
select="onentry()"
deselect="onexit()"
index="2"
>
<uib-tab-heading ng-class="{not_loading: progress > 99, loading : loading}"
>{{'statistics' | loc:$root.lang}}
<tab-preloader
ng-if="loading"
value="progress"
spinner="countCorpora() < 2"
></tab-preloader>
</uib-tab-heading>
<uib-tabset class="tabbable result_tabs" active="activeTab">
<uib-tab kwic-ctrl index="0" select="onentry()" deselect="onexit()">
<uib-tab-heading ng-class="{not_loading: progress > 99, loading : loading}"
>KWIC<tab-preloader
ng-if="loading"
value="progress"
spinner="countCorpora() < 2"
></tab-preloader>
</uib-tab-heading>
<div class="results-kwic" ng-class="{reading_mode : reading_mode, loading: loading}">
<korp-error ng-if="error"></korp-error>
<statistics
<kwic
ng-if="!error"
aborted="aborted"
activate="activate"
columns="columns"
data="data"
error="error"
grid-data="gridData"
has-result="hasResult"
in-order="inOrder"
loading="loading"
no-hits="no_hits"
active="active"
hits-in-progress="hitsInProgress"
hits="hits"
kwic-input="kwic"
corpus-hits="corpusHits"
is-reading="reading_mode"
page="page"
page-event="pageChange"
context-change-event="toggleReading"
hits-per-page="hitsPerPage"
prev-params="proxy.prevParams"
search-params="searchParams"
show-statistics="showStatistics"
></statistics>
</uib-tab>
<uib-tab
ng-if="$root._settings['word_picture'] != false"
wordpic-ctrl
index="3"
select="onentry()"
deselect="onexit()"
>
<uib-tab-heading ng-class="{not_loading: progress > 99, loading : loading}">
{{'word_picture' | loc:$root.lang}}
<tab-preloader
ng-if="loading"
value="progress"
spinner="countCorpora() < 2"
></tab-preloader>
</uib-tab-heading>
<div ng-if="!error">
<word-picture
data="data"
word-pic="wordPic"
activate="activate"
loading="loading"
has-data="hasData"
aborted="aborted"
hit-settings="hitSettings"
settings="settings"
no-hits="noHits"
></word-picture>
</div>
<korp-error ng-if="error"></korp-error>
</uib-tab>
<kwic-tabs tabs="$root.kwicTabs"></kwic-tabs>
<graph-tabs tabs="$root.graphTabs"></graph-tabs>
<compare-tabs tabs="$root.compareTabs"></compare-tabs>
<map-tabs tabs="$root.mapTabs"></map-tabs>
<text-tabs tabs="$root.textTabs"></text-tabs>
</uib-tabset>
</tab-hash>
prev-request="proxy.prevRequest"
corpus-order="corpusOrder"
></kwic>
</div>
</uib-tab>
<uib-tab
stats-result-ctrl
ng-if="hasStatistics"
select="onentry()"
deselect="onexit()"
index="2"
>
<uib-tab-heading ng-class="{not_loading: progress > 99, loading : loading}"
>{{'statistics' | loc:$root.lang}}
<tab-preloader
ng-if="loading"
value="progress"
spinner="countCorpora() < 2"
></tab-preloader>
</uib-tab-heading>
<korp-error ng-if="error"></korp-error>
<statistics
aborted="aborted"
activate="activate"
columns="columns"
data="data"
error="error"
grid-data="gridData"
has-result="hasResult"
in-order="inOrder"
loading="loading"
no-hits="no_hits"
prev-params="proxy.prevParams"
search-params="searchParams"
show-statistics="showStatistics"
></statistics>
</uib-tab>
<uib-tab
ng-if="hasWordPicture"
wordpic-ctrl
index="3"
select="onentry()"
deselect="onexit()"
>
<uib-tab-heading ng-class="{not_loading: progress > 99, loading : loading}">
{{'word_picture' | loc:$root.lang}}
<tab-preloader
ng-if="loading"
value="progress"
spinner="countCorpora() < 2"
></tab-preloader>
</uib-tab-heading>
<div ng-if="!error">
<word-picture
data="data"
word-pic="wordPic"
activate="activate"
loading="loading"
has-data="hasData"
aborted="aborted"
hit-settings="hitSettings"
settings="settings"
no-hits="noHits"
></word-picture>
</div>
<korp-error ng-if="error"></korp-error>
</uib-tab>
<kwic-tabs tabs="$root.kwicTabs"></kwic-tabs>
<graph-tabs tabs="$root.graphTabs"></graph-tabs>
<compare-tabs tabs="$root.compareTabs"></compare-tabs>
<map-tabs tabs="$root.mapTabs"></map-tabs>
<text-tabs tabs="$root.textTabs"></text-tabs>
</uib-tabset>
<a id="json-link" ng-href="{{$root.jsonUrl}}" ng-show="$root.jsonUrl" target="_blank">
<img src="img/json.png" />
</a>
Expand All @@ -143,8 +139,10 @@ angular.module("korpApp").component("results", {
bindings: {},
controller: [
"$rootScope",
"$scope",
"searches",
function ($rootScope, searches) {
"utils",
function ($rootScope, $scope, searches, utils) {
const $ctrl = this
$ctrl.searches = searches
$ctrl.onSidebarShow = () => ($ctrl.sidebarVisible = true)
Expand All @@ -155,6 +153,24 @@ angular.module("korpApp").component("results", {
$rootScope.compareTabs.length ||
$rootScope.graphTabs.length ||
$rootScope.mapTabs.length

$scope.hasStatistics = settings.statistics !== false
$scope.hasWordPicture = settings.word_picture !== false

function updateTabs() {
$scope.tabCount =
2 + ($scope.hasStatistics ? 1 : 0) + ($scope.hasWordPicture ? 1 : 0) + $rootScope.kwicTabs.length // TODO + ...
}

$scope.$watch($rootScope.kwicTabs, updateTabs)
// TODO watch other tabs too
updateTabs()

utils.setupHash($scope, {
key: "result_tab",
scope_name: "activeTab",
val_in: (tab) => Math.min(tab, $scope.tabCount),
})
},
],
})
3 changes: 2 additions & 1 deletion app/scripts/settings/app-settings.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,12 @@ export type AppSettings = {
news_url?: string
reduce_word_attribute_selector: "union" | "intersection"
reduce_struct_attribute_selector: "union" | "intersection"
statistics?: false
statistics_search_default: boolean
urnResolver?: string
visible_modes: number
word_label: Record<string, string>
word_picture?: boolean
word_picture?: false
word_picture_tagset?: Record<string, string>
word_picture_conf?: Record<string, WordPictureDef[]>
}
Expand Down

0 comments on commit 69d9f5a

Please sign in to comment.