Skip to content

Duration field type

We want to introduce a new field type that can store a duration in hours, minutes, and seconds. Below all the requirements, although I recommend splitting it up into different merge requests.

  • It should be possible to choose the following formatting:
    • h:mm (hours:minutes)
    • h:mm:ss (hours:minutes:seconds)
    • h:mm:ss.s
    • h:mm:ss.ss
    • h:mm:ss.sss
  • All views should be compatible:
    • Grid
      • The formatting will be shown as a placeholder in the cell when it's active, and doesn't have a value.
      • When the cell is being edited, it should not force the format. This should only happen when the user stops editing.
    • Gallery
    • Form
    • Kanban
    • Calendar
  • When the user provides a value like 1:70, it should actually be converted to 2:10 because 70 minutes equals 1 hour and 10 minutes.
  • It should be possible to edit the duration in the row edit modal, using a normal text input, but with the same constraints as in the grid view cell.
  • It should be possible to search on the human-readable value, so if the cell contains 20:45, and the user searches for 20, 45, or 20:45, it should match that row.
  • It should be possible to sort ascending (empty, empty, 00:10, 1:10, 2:50), and descending (2:50, 1:10, 00:10, empty, empty)
  • It should be possible to export to a CSV file. The cells in the export should contain the human-readable value.
  • It should be possible to import from a CSV file into an existing table. It should try to parse the value as good as possible.
  • It should be compatible with the serialized import/export, which is used for duplication.
  • It should be possible to filter on the duration field. When filtering the filter input must show the the format that the duration accepts. The following filters should work:
    • equal
    • not equal
    • higher than
    • lower than
    • empty
    • not empty
  • It should be possible to reference the duration field in a formula. This probably means that we need to introduce a new formula field type.
    • It should be possible to use addition and subtraction of two duration references.
    • It should be possible to use addition and subtraction of a date and duration.
  • It should be possible to group by the duration field type.
  • When using the fill_table_rows management command, we want the value to be random.
  • When converting to a text field type, the value should remain the human-readable value.
  • When converting from a text field type, it should try to parse the duration as good as possible.
Edited by Bram Wiepjes