noyainrain / listling

Web app to make and edit lists collaboratively.
https://listling.org/
GNU Affero General Public License v3.0
34 stars 8 forks source link

Add Item value #88

Closed noyainrain closed 4 years ago

noyainrain commented 4 years ago

Let items have an associated decimal value, e.g. price, duration, points, ... This may also be useful to provide summary statistics, e.g. total, user share, ...

Draft:

class Item:
    """
    .. describe:: value

       Decimal value associated with the item. May be ``null``.
    """

    value: Optional[float]

class List:
    """
    .. describe:: features

       Available features are ``check``, ``vote``, ``value``, ``location`` and ``play``.
    """

    class Items:
        async def create(self, title: str, *, text: str = None, resource: Resource = None,
                         value: float = None, location: Location = None) -> Item:
            """
            .. http:post:: /api/lists/(id)/items

               ``{"title", "text": null, "resource": null, "value": null, "location": null}``
            """

Future reference:

class List:
    """
    .. describe:: value_unit

       Unit of :ref:`Item` *value*s. May be ``null``.

    .. describe:: value_summary

       Summary table of :ref:`Item` *value*s. ``total`` holds the sum over all items. For each
       assigned :ref:`User` an entry with the sum over assigned items is included. If an item has
       multiple assignees, the value is split equally between them. ``unassigned`` holds the sum
       over the remaining unassigned items.
    """

    value_unit: Optional[str]
    value_summary: typing.List[Tuple[Union[Literal['total'], Literal['unassigned'], User], float]]

UI draft