Skip to content

Commit

Permalink
Merge pull request #6007 from mzimandl/release-fixes
Browse files Browse the repository at this point in the history
fix changing page title on changing concordance query
  • Loading branch information
tomachalek authored Aug 28, 2023
2 parents 3be85da + 86d34f3 commit eff3d77
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
21 changes: 15 additions & 6 deletions lib/action/model/concordance/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

import hashlib
import os
import re
import urllib.parse
from typing import Any, Dict, List, Optional, Tuple, Union
import hashlib
from collections import OrderedDict
from typing import Any, Dict, List, Optional, Tuple, Union

import conclib
import plugins
import settings
import strings
from action.argmapping import ConcArgsMapping
from action.argmapping.conc import build_conc_form_args
from action.argmapping.conc.filter import (
Expand Down Expand Up @@ -104,7 +105,8 @@ async def fetch_prev_query(self, query_type: str) -> Optional[QueryFormArgs]:
curr_subcorp = self.args.usesubcorp

if prev_corpora and len(curr_corpora) == 1 and prev_corpora[0] == curr_corpora[0]:
args = [('corpname', prev_corpora[0])] + [('align', a) for a in prev_corpora[1:]]
args = [('corpname', prev_corpora[0])] + [('align', a)
for a in prev_corpora[1:]]

subcorpora = await subc_arch.list(
self._req.ctx.session.get('user')['id'], SubcListFilterArgs(), corpname=prev_corpora[0])
Expand Down Expand Up @@ -347,7 +349,8 @@ async def export_query_forms(self, tpl_out: Dict[str, Any]) -> List[ConcFormArgs
if i < len(query_overview):
query_overview[i].conc_persistence_op_id = item.op_key
elif item.form_type != 'lgroup':
raise RuntimeError('Found a mismatch between Manatee query encoding and stored metadata')
raise RuntimeError(
'Found a mismatch between Manatee query encoding and stored metadata')

# Attach new form args added by the current action.
if len(self._auto_generated_conc_ops) > 0:
Expand All @@ -371,8 +374,14 @@ async def export_query_forms(self, tpl_out: Dict[str, Any]) -> List[ConcFormArgs
persist=False, struct=self.corp.get_conf('DOCSTRUCTURE')).to_dict())
tpl_out['query_overview'] = [x.to_dict() for x in query_overview]
if len(query_overview) > 0:
tpl_out['page_title'] = '{0} / {1}'.format(
self.corp.human_readable_corpname, tpl_out['query_overview'][0]['nicearg'])
tpl_out['page_title'] = '{0} ({1})'.format(
strings.shorten(
f'{self.corp.human_readable_corpname} / {tpl_out["query_overview"][0]["nicearg"]}',
length=80,
nice=True,
),
self._req.translate('Concordance'),
)
return [x for x in conc_forms_args.values()]

async def add_globals(self, app, action_props, result):
Expand Down
1 change: 1 addition & 0 deletions public/files/js/models/concordance/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ export interface AjaxConcResponse extends ConcQueryResponse {
result_shuffled:boolean;
result_arf:number;
sampled_size:number;
page_title:string;
}

/**
Expand Down
1 change: 1 addition & 0 deletions public/files/js/models/concordance/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ export class ConcordanceModel extends StatefulModel<ConcordanceModelState> {
});

} else {
document.title = action.payload.data.page_title;
this.layoutModel.updateConcPersistenceId(action.payload.data.conc_persistence_op_id);
this.changeState(state => {
this.importData(state, action.payload.data);
Expand Down
2 changes: 1 addition & 1 deletion templates/view.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#}
{% extends "document.html" %}
{% block title %}{{ page_title|default('', true)|shorten(80, True) }} ({{ "Concordance"|_ }}){% endblock %}
{% block title %}{{ page_title }}{% endblock %}

{% block headers %}

Expand Down

0 comments on commit eff3d77

Please sign in to comment.