Browse Source

Topic tag filters: one per line instead of commas

A few minor interface improvements for topic tag filters - mostly just
changing to the settings page defining them in a textarea, with one per
line. Previously this was just a text input with the tags
comma-separated, which got unwieldy very quickly.
merge-requests/68/head
Chad Birch 6 years ago
parent
commit
61558feea1
  1. 10
      tildes/tildes/templates/settings_filters.jinja2
  2. 4
      tildes/tildes/views/api/web/user.py

10
tildes/tildes/templates/settings_filters.jinja2

@ -21,8 +21,14 @@
username=request.user.username, username=request.user.username,
) }}" ) }}"
> >
<label class="form-label" for="tags">Tags (comma-separated):</label>
<input type="text" class="form-input" name="tags" id="tags" value="{{ request.user.filtered_topic_tags|join(', ') }}">
<label class="form-label" for="tags">Filtered tags (one per line):</label>
<textarea
class="form-input"
name="tags"
id="tags"
data-js-ctrl-enter-submit-form
data-js-auto-focus
>{{ request.user.filtered_topic_tags|join("\n") }}</textarea>
<div class="form-buttons"> <div class="form-buttons">
<button class="btn btn-primary" type="submit">Save filtered tags</button> <button class="btn btn-primary" type="submit">Save filtered tags</button>
</div> </div>

4
tildes/tildes/views/api/web/user.py

@ -330,11 +330,11 @@ def put_default_listing_options(
@use_kwargs({"tags": String()}) @use_kwargs({"tags": String()})
def put_filtered_topic_tags(request: Request, tags: str) -> dict: def put_filtered_topic_tags(request: Request, tags: str) -> dict:
"""Update a user's filtered topic tags list.""" """Update a user's filtered topic tags list."""
if not tags:
if not tags or tags.isspace():
request.user.filtered_topic_tags = [] request.user.filtered_topic_tags = []
return IC_NOOP return IC_NOOP
split_tags = tags.split(",")
split_tags = tags.replace("\r", "").split("\n")
try: try:
schema = TopicSchema(only=("tags",)) schema = TopicSchema(only=("tags",))

Loading…
Cancel
Save