"""Efforts: ranked rows for the work an idea overlaps with. CSS: efforts.css.""" from .links import e, links, text from .people import avatar from .status import lz def effort(x): """One effort, as a plain block of stacked lines that wrap on phones: the main record, its class and status, what it does, the owner, the move, then its evidence. Data: {"link", "class": lozenge, "status", "does": text field, "facets", "owner": {"name", "label", "team"?} or {"label"} alone, "contributors"?, "move": {"label", "why"}, "linked"?: [links], "found"?: [links], "earlier"?: [links], "next"?: [links], "note"?, "connected"?}. Linked and found-by-search evidence stay two lists, and an empty one is left out. effort({"link": {"title": "Search alerts for Confluence spaces", "url": "#", "icon": "project"}, "class": {"text": "Same idea", "tone": "danger"}, "status": "Projects · On track", "does": "Sends a daily email when new pages match a saved query.", "owner": {"name": "Priya Nair", "label": "Owner", "team": "Team Ledger"}, "move": {"label": "Join", "why": "Updated this week"}}) """ o = x.get('owner') or {} name = o.get('name') who = (avatar(name, small=True) if name else '') + f'{e(o.get("label", "Owner not recorded"))}' who += (f' {e(name)}' if name else '') + (f' · {e(o["team"])}' if o.get('team') else '') if x.get('contributors'): who += f' · with {e(" and ".join(x["contributors"]))}' who += '' move = x.get('move') or {} parts = [ f'
{links(x["link"])}{lz(x.get("class"))}{e(x.get("status", ""))}
', f'

{text(x, "does")}

' if x.get('does') else '', f'
{e(x["facets"])}
' if x.get('facets') else '', f'
{who}
', f'

{e(move["label"])} · {text(move, "why")}

' if move.get('label') else '', ] for key, label in (('linked', 'Linked'), ('found', 'Found by search'), ('earlier', 'Earlier phases'), ('next', 'Next phase')): if x.get(key): parts.append(f'
{label}
') if x.get('note'): parts.append(f'
{e(x["note"])}
') if x.get('connected'): parts.append(f'
{e(x["connected"])}
') return f'
  • {"".join(parts)}
  • ' def efforts(items): """The efforts as a ranked list. efforts([effort_data, ...]) """ return '
      ' + ''.join(effort(x) for x in items) + '
    '