Skip to content

Commit

Permalink
Link to the calendar (#221)
Browse files Browse the repository at this point in the history
* implemented a link to the calendar

* Changed to another icon

Co-authored-by: octycs <[email protected]>

* Update webclient/src/views/view/view-view.inc

Co-authored-by: octycs <[email protected]>

* added a kalendar tooltip

* moved the calendar_url to the props

* fixed minor formatting issues in the svg file (provided by our formatting suite)

Co-authored-by: octycs <[email protected]>
  • Loading branch information
CommanderStorm and octycs authored Oct 23, 2022
1 parent c20c4ec commit 08af67c
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 1 deletion.
1 change: 1 addition & 0 deletions data/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def main():
images.add_img(data)

logging.info("-- 80 Generate info card")
sections.extract_calendar_urls(data)
sections.compute_props(data)
sections.localize_links(data)

Expand Down
3 changes: 2 additions & 1 deletion data/processors/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ def export_for_api(data, path):
if "roomfinder_data" in export_data[_id]:
del export_data[_id]["roomfinder_data"]
if "props" in export_data[_id]:
to_delete = [e for e in export_data[_id]["props"].keys() if e not in {"computed", "links", "comment"}]
prop_keys_to_keep = {"computed", "links", "comment", "calendar_url"}
to_delete = [e for e in export_data[_id]["props"].keys() if e not in prop_keys_to_keep]
for k in to_delete:
del export_data[_id]["props"][k]

Expand Down
8 changes: 8 additions & 0 deletions data/processors/sections.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
from utils import TranslatableStr as _


def extract_calendar_urls(data):
"""Extracts the calendar from the tumonline data sets it to the proper value."""
for k, entry in data.items():
if entry.get("tumonline_data", {}).get("calendar", None):
url = f"https://campus.tum.de/tumonline/{entry['tumonline_data']['calendar']}"
entry["props"]["calendar_url"] = url


def compute_props(data):
"""
Create the "computed" value in "props".
Expand Down
8 changes: 8 additions & 0 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ paths:
text: 'Boltzmannstr. 3, EG, 85748 Garching b. München'
- name: Sitzplätze
text: '522'
calendar_url: 'https://campus.tum.de/tumonline/tvKalender.wSicht?cOrg=19691&cRes=12559&cReadonly=J'
ranking_factors:
rank_combined: 900
rank_type: 100
Expand Down Expand Up @@ -1005,6 +1006,13 @@ components:
It is used in the rare cases, where some aspect about the rooom/.. or its translation are misleading.
An example of a room with a comment is MW1801.
type: string
calendar_url:
items:
type: string
description: A link to the calendar of the room
example:
- 'https://campus.tum.de/tumonline/tvKalender.wSicht?cOrg=19691&cRes=12543&cReadonly=J'
- 'https://campus.tum.de/tumonline/tvKalender.wSicht?cOrg=19691&cRes=12559&cReadonly=J'
required:
- computed
ComputedProp:
Expand Down
1 change: 1 addition & 0 deletions webclient/src/views/view/i18n-view.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ view_view:
share: { de: "Teilen", en: "Share" }
share_link: { de: "Teilen mit ...", en: "Share with ..." }
copied: { de: "Kopiert", en: "Copied" }
calendar: { de: "Kalender öffnen", en: "Open calendar" }
feedback:
de: "Problem melden oder Änderung vorschlagen"
en: "Report issue or suggest changes"
Expand Down
23 changes: 23 additions & 0 deletions webclient/src/views/view/view-view.inc
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,29 @@
<span>{{ view_data.type_common_name }}</span>
</div>
<div class="column col-auto col-ml-auto">
<a
class="btn btn-link btn-action btn-sm"
v-if="view_data.props?.calendar_url"
v-bind:href="view_data.props.calendar_url"
target="_blank"
title="${{ _.view_view.header.calendar }}$"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="14"
height="14"
viewBox="0 0 16 16"
fill="currentColor"
style="margin-bottom: -2px"
>
<path
d="M4.571 0A1.143 1.143 0 0 0 3.43 1.143H2.286A2.306 2.306 0 0 0 0 3.429v10.285A2.306 2.306 0 0 0 2.286 16h11.428A2.306 2.306 0 0 0 16 13.714V3.43a2.306 2.306 0 0 0-2.286-2.286h-1.143A1.143 1.143 0 0 0 11.43 0a1.143 1.143 0 0 0-1.143 1.143H5.714A1.143 1.143 0 0 0 4.571 0zM2.286 5.714h11.428v8H2.286v-8z"
/>
<path
d="M6.857 6.857v2.286h2.286V6.857H6.857zm3.429 0v2.286h2.285V6.857h-2.285zm-6.857 3.429v2.285h2.285v-2.285H3.43zm3.428 0v2.285h2.286v-2.285H6.857z"
/>
</svg>
</a>
<button
class="btn btn-link btn-action btn-sm"
title="${{ _.view_view.header.external_link.tooltip }}$"
Expand Down

0 comments on commit 08af67c

Please sign in to comment.