Skip to content

Commit

Permalink
store whole conf in hidden div
Browse files Browse the repository at this point in the history
  • Loading branch information
interrogator committed Aug 21, 2019
1 parent 17d93fe commit 7ca888a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
21 changes: 11 additions & 10 deletions buzzword/parts/explore.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import flask

from buzzword.parts.main import app, CORPORA, INITIAL_TABLES, CORPORA_CONFIGS
from buzzword.parts.main import app, CORPORA, INITIAL_TABLES

# we can't keep tables in dcc.store, they are too big. so we keep all here with
# a tuple that can identify them (ideally, even dealing with user sessions)
Expand Down Expand Up @@ -137,7 +137,7 @@ def _on_load_callback(n_clicks):
State("search-from", "options"),
State("conll-view", "columns"),
State("conll-view", "data"),
State("corpus-slug", "children"),
State("corpus-config", "children"),
State("session-search", "data"),
State("session-clicks-clear", "data"),
],
Expand All @@ -152,7 +152,7 @@ def _new_search(
search_from_options,
current_cols,
current_data,
slug,
conf,
session_search,
session_clicks_clear,
):
Expand All @@ -178,7 +178,7 @@ def _new_search(
session_clicks_clear,
)

conf = CORPORA_CONFIGS[slug]
slug = conf["slug"]
add_governor = conf["add_governor"]
max_row, max_col = conf["table_size"]

Expand Down Expand Up @@ -319,7 +319,7 @@ def _new_search(
State("sort-for-table", "value"),
State("chart-from-1", "options"),
State("chart-from-1", "value"),
State("corpus-slug", "children"),
State("corpus-config", "children"),
State("session-search", "data"),
State("session-tables", "data"),
State("session-clicks-table", "data"),
Expand All @@ -338,7 +338,7 @@ def _new_table(
sort,
table_from_options,
nv1,
slug,
conf,
session_search,
session_tables,
session_click_table,
Expand All @@ -350,7 +350,7 @@ def _new_table(
if n_clicks is None:
raise PreventUpdate

conf = CORPORA_CONFIGS[slug]
slug = conf["slug"]

# because no option below can return initial table, rows can now be deleted
row_deletable = True
Expand Down Expand Up @@ -475,17 +475,19 @@ def _new_table(
State("search-from", "value"),
State("conc-table", "columns"),
State("conc-table", "data"),
State("corpus-slug", "children"),
State("corpus-config", "children"),
State("session-search", "data"),
],
)
def _new_conc(n_clicks, show, search_from, cols, data, slug, session_search):
def _new_conc(n_clicks, show, search_from, cols, data, conf, session_search):
"""
Callback for concordance. We just pick what to show and where from...
"""
if n_clicks is None:
raise PreventUpdate

slug = conf["slug"]

# easy validation!
msg = "" if show else "No choice made for match formatting."
if not show:
Expand All @@ -499,7 +501,6 @@ def _new_conc(n_clicks, show, search_from, cols, data, slug, session_search):
met.append("speaker")

conc = corpus.conc(show=show, metadata=met, window=(100, 100))
conf = CORPORA_CONFIGS[slug]
max_row, max_col = conf["table_size"]
short = conc.iloc[:max_row, :max_col]
cols, data = _update_datatable(CORPORA[slug], short, conc=True)
Expand Down
2 changes: 1 addition & 1 deletion buzzword/parts/tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,6 @@ def _make_tabs(corpus, table, config):
)
]
tab_contents = html.Div(id="tab-contents", children=tab_contents)
hidden_corpus_name = html.Div(id="corpus-slug", children=slug, style=hide)
hidden_corpus_name = html.Div(id="corpus-config", children=config, style=hide)
children = [top_bit, tab_headers, tab_contents, hidden_corpus_name]
return html.Div(id="everything", children=children)

0 comments on commit 7ca888a

Please sign in to comment.