Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combination of Form Pages and repeating_subfields do not work properly in edit mode. #385

Open
MandanaMoshref opened this issue Aug 14, 2023 · 2 comments

Comments

@MandanaMoshref
Copy link

MandanaMoshref commented Aug 14, 2023

using form pages repeating_subfields causes inconsistency. While adding a new resource works perfectly, for editing the resource, it does not work for those fields with repeating_subfields. The main problem is that the repeating subfields only take the initial value (can be also empty) and after editing the new values do not update.

to reproduce the error:
ckan version: 2.10
ckanext-scheming: latest (installed on 01.07.2023)
scheming.yml -> Try to add one organization and date when creating a new dataset, and then edit these same fields with a new organization and date

scheming_version: 2
dataset_type: test
about_url: http://example.com/the-camel-photos-schema


dataset_fields:

- start_form_page:
    title: Basic Info
    description: Required and core dataset fields

  field_name: title
  label: Title
  preset: title
  form_placeholder: eg. A descriptive title

- field_name: name
  label: URL
  preset: dataset_slug
  form_placeholder: eg. my-dataset

- field_name: notes
  label: Description
  form_snippet: markdown.html
  form_placeholder: eg. Some useful notes about the data

- field_name: owner_org
  label: Organization
  preset: dataset_organization

- start_form_page:
    title: Detailed Info
    description:
      These fields improve search and give users important links

  field_name: tag_string
  label: Tags
  preset: tag_string_autocomplete
  form_placeholder: eg. economy, mental health, government

- field_name: citation
  label: Citation
  repeating_subfields:
  - field_name: originator
    label: Originator
    preset: multiple_text
    form_blanks: 3
    required: true
  - field_name: publication_date
    label: Publication Date
    preset: date
  - field_name: online_linkage
    label: Online Linkage
    preset: multiple_text
    form_blanks: 2

resource_fields:

- field_name: url
  label: URL
  preset: resource_url_upload

- field_name: name
  label: Name
  form_placeholder: eg. January 2011 Gold Prices

- field_name: description
  label: Description
  form_snippet: markdown.html
  form_placeholder: Some useful notes about the data

- field_name: format
  label: Format
  preset: resource_format_autocomplete
@wardi
Copy link
Contributor

wardi commented Aug 14, 2023

@MandanaMoshref thanks for the report. Can you tell if it's an issue with the repeating subfields javascript or with the way the form page is rendering? If you come up with a fix please submit a PR.

@MandanaMoshref
Copy link
Author

MandanaMoshref commented Aug 19, 2023

@MandanaMoshref thanks for the report. Can you tell if it's an issue with the repeating subfields javascript or with the way the form page is rendering? If you come up with a fix please submit a PR.

@wardi from my understanding it is related to the form page. I studied the behavior of view.py and found another strange behavior.

Regarding Edit: def edit causes the editing problematic. commenting out the if h.scheming_get_dataset_form_pages(package_type): seems to solve the problem for editing the Schemata with and without form_pages. I just did some clicking tests.

One more error is related to creating a new dataset with form pages. Creating the package and being in the last stage (resource creation), if the user decides to go back by clicking the previous button, it starts from page 1 (default by ckan) in edit mode which is OK. The problem is clicking next and from form page 2 it shifts to new and does not stay in edit mode causing all repeating_subfields to be removed and appear empty.

These are just my assumptions. Cannot say it for sure as I am not familiar with the code. For example, I do not understand that it is only the problem with lists like repeating_subfields and not a simple added text field.

in summary, i guess the form_page still needs more testing and therefore, it is better to be mentioned in the readme, that at the moment for complex attributes, required, etc. it cannot be used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants