docassemble icon indicating copy to clipboard operation
docassemble copied to clipboard

One cannot add DADict items to a table with `show incomplete`

Open fkohrt opened this issue 10 months ago • 1 comments

If I try to add items using an editable table to a DADict, this fails if show incomplete is enabled. It does work with a table populated by a DAList, so I'm suspecting this is a bug.

---
objects:
  - income: DADict.using(object_type = DAObject)
---
table: income.table
rows: income
show incomplete: true
columns:
  - Type: row_index
  - A: row_item.a
  - B: row_item.b
edit:
  - a
  - b
---
event: review_table
question: |
  Summary of income
review:
  - note: |
      ${ income.table }
    
      ${ income.add_action() }
continue button field: show_review_screen
skip undefined: False
---
question: |
  Add another income?
yesno: income.there_is_another
---
question: |
  Income name?
fields:
  - Income: income.new_item_name
---
question: |
  A?
yesno: income[i].a
---
question: |
  B?
fields:
  - B: income[i].b
    datatype: number
---
question: |
  Any?
yesno: income.there_are_any
---
mandatory: True
question: Test
subquestion: |
  [Review your answers](${ url_action('review_table')})

fkohrt avatar Feb 03 '25 21:02 fkohrt

Oh, and the same is true if one sets require gathered: False for the table.

fkohrt avatar Feb 03 '25 21:02 fkohrt

I just realized there is no response to this issue on GitHub; I thought I had addressed it on Slack, but now I don't remember.

In any case, the issue here is that DAObject is the object type and complete_attribute is not used. These changes to the interview will cause the add_action() button to work:

objects:
  - income: DADict.using(object_type=DAObject, complete_attribute='complete')
---
code: |
  income[i].a
  income[i].b
  income[i].complete = True

The add_action() method will add a new DAObject to the list, but it doesn't know to ask about attributes a and b because without the complete_attribute, there is nothing to convey that those attributes are required.

See https://docassemble.org/docs/groups.html#list%20of%20objects

If you use a plain DAObject as the object_type, then no questions will be asked; this is because the DAObject is meant to be a “base class,” with no meaningful attributes of its own. Thus, calling str(y) on a plain DAObject will simply return a name based on the variable name; no questions will be asked. The section goes on to discuss the use of .complete_attribute.

jhpyle avatar Aug 11 '25 10:08 jhpyle