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

Support multipart saving #187

Closed
Tracked by #1660
olemartinorg opened this issue Feb 7, 2023 · 0 comments · Fixed by #329
Closed
Tracked by #1660

Support multipart saving #187

olemartinorg opened this issue Feb 7, 2023 · 0 comments · Fixed by #329
Assignees
Labels
fe-v4 Issues required for app-frontend v4 to be shippable kind/feature-request New feature or request org/ssb Issues relevant for Statistisk sentralbyrå.
Milestone

Comments

@olemartinorg
Copy link
Contributor

olemartinorg commented Feb 7, 2023

Description

After Altinn/app-frontend-react/pull/899 is merged, multipart saving will be implemented in app-frontend-react. This means that the PUT request for saving the data model can start sending multipart bodies containing not just the datamodel we want to save, but also the paths inside that datamodel that changed (along with their previous values).

As an example, here is a request we might send. I've added whitespace to the JSON for readability, although we won't send that in practice.

PUT /org/app/instances/512345/uuid/data/uuid
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryyWYh3C7EIYlu8pJj

------WebKitFormBoundaryyWYh3C7EIYlu8pJj
Content-Disposition: form-data; name="dataModel"

{
  "skjemanummer": "1603",
  "spesifikasjonsnummer": "12392",
  "blankettnummer": "RF-1366",
  "tittel": "Endringsmelding",
  "gruppeid": "9785",
  "Endringsmelding-grp-9786": {
    "Avgiver-grp-9787": {
      "KontaktpersonEPost-datadef-27688": {
        "value": "Ja"
      }
    },
    "OversiktOverEndringene-grp-9788": [
      {
        "SkattemeldingEndringEtterFristOpprinneligBelop-datadef-37131": {
          "value": "1"
        }
      }
    ]
  }
}
------WebKitFormBoundaryyWYh3C7EIYlu8pJj
Content-Disposition: form-data; name="previousValues"

{
  "Endringsmelding-grp-9786.OversiktOverEndringene-grp-9788[0].SkattemeldingEndringEtterFristOpprinneligBelop-datadef-37131.value": null
}
------WebKitFormBoundaryyWYh3C7EIYlu8pJj--

You now get two objects, not just one:

  1. The dataModel (always named as such, regardless of the data model name - which we don't really know or care about in app-frontend). This is the same object we used to send.
  2. The previousValues map. This uses dot-notation to indicate a path inside the data model that changed. For every item that changed, the previous value is listed as the map value. If the path did not exist before, the value will be null.

The above example contains a path inside a repeating group that changed - specifically on row 0.

Another interesting example is seen here. I added 3 rows, with the following values:

  1. 1 and 2
  2. 3 and 4
  3. 5 and 6

Then I deleted the second row (containing the values 3 and 4), which leads to this request:

PUT /org/app/instances/512345/uuid/data/uuid
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryBkzRPylfSvVRa1ym

------WebKitFormBoundaryBkzRPylfSvVRa1ym
Content-Disposition: form-data; name="dataModel"

{
  "skjemanummer": "1603",
  "spesifikasjonsnummer": "12392",
  "blankettnummer": "RF-1366",
  "tittel": "Endringsmelding",
  "gruppeid": "9785",
  "Endringsmelding-grp-9786": {
    "Avgiver-grp-9787": {
      "KontaktpersonEPost-datadef-27688": {
        "value": "Ja"
      }
    },
    "OversiktOverEndringene-grp-9788": [
      {
        "SkattemeldingEndringEtterFristOpprinneligBelop-datadef-37131": {
          "value": "1"
        },
        "SkattemeldingEndringEtterFristNyttBelop-datadef-37132": {
          "value": "2"
        }
      },
      {
        "SkattemeldingEndringEtterFristOpprinneligBelop-datadef-37131": {
          "value": "5"
        },
        "SkattemeldingEndringEtterFristNyttBelop-datadef-37132": {
          "value": "6"
        }
      }
    ]
  }
}
------WebKitFormBoundaryBkzRPylfSvVRa1ym
Content-Disposition: form-data; name="previousValues"

{
  "Endringsmelding-grp-9786.OversiktOverEndringene-grp-9788[1].SkattemeldingEndringEtterFristOpprinneligBelop-datadef-37131.value": "3",
  "Endringsmelding-grp-9786.OversiktOverEndringene-grp-9788[1].SkattemeldingEndringEtterFristNyttBelop-datadef-37132.value": "4",
  "Endringsmelding-grp-9786.OversiktOverEndringene-grp-9788[2].SkattemeldingEndringEtterFristOpprinneligBelop-datadef-37131.value": "5",
  "Endringsmelding-grp-9786.OversiktOverEndringene-grp-9788[2].SkattemeldingEndringEtterFristNyttBelop-datadef-37132.value": "6"
}
------WebKitFormBoundaryBkzRPylfSvVRa1ym--

Notice that the row indexes 1 and 2 had changed (row 0 did not change). Index 1 used to have the values 3 and 4 (but from the data model we can tell they now have the values 5 and 6), while index 2 used to have the values 5 and 6 (but index 2 no longer exists in the data model).

Other things to be aware of:

  • As an app developer, I would expect to have a somewhat rich interface to interact with this information (the raw data is a bit cumbersome to work with). I.e., a way to get a list of "changes" with previous/new values.
  • For this feature to work with app-frontend, the backend needs to inform that the multiPartSave feature is enabled (see FeatureSet #188).
  • The headers we used to send (X-DataField and X-ComponentId) are no longer passed to the backend when multipart saving is enabled. It is advised that app developers can choose to enable multipart saving when they are ready for it, although we should encourage them to do so (possibly also updating the template to enable the feature by default for new apps).

Additional Information

@olemartinorg olemartinorg added kind/feature-request New feature or request org/ssb Issues relevant for Statistisk sentralbyrå. labels Feb 7, 2023
@olemartinorg olemartinorg moved this to Todo in Issues SSB Jun 13, 2023
@olemartinorg olemartinorg moved this to 📈 Todo in Team Apps Sep 25, 2023
@olemartinorg olemartinorg added the fe-v4 Issues required for app-frontend v4 to be shippable label Sep 25, 2023
@tjololo tjololo added this to the 8.0.0 milestone Sep 26, 2023
@ivarne ivarne moved this from 📈 Todo to 👷 In Progress in Team Apps Oct 12, 2023
@ivarne ivarne modified the milestone: 8.0.0 Oct 24, 2023
@ivarne ivarne mentioned this issue Oct 24, 2023
5 tasks
@HanneLauritsen1967 HanneLauritsen1967 moved this from 👷 In Progress to 🔎 Review in Team Apps Oct 26, 2023
@ivarne ivarne linked a pull request Oct 26, 2023 that will close this issue
5 tasks
@HanneLauritsen1967 HanneLauritsen1967 moved this from 🔎 Review to 👷 In Progress in Team Apps Nov 17, 2023
@HanneLauritsen1967 HanneLauritsen1967 moved this from 👷 In Progress to 🔎 Review in Team Apps Nov 28, 2023
@tjololo tjololo moved this from 🔎 Review to 🧪 Test in Team Apps Dec 14, 2023
@tjololo tjololo closed this as completed Dec 14, 2023
@github-project-automation github-project-automation bot moved this from Todo to Done in Issues SSB Dec 14, 2023
@HanneLauritsen1967 HanneLauritsen1967 moved this from 🧪 Test to ✅ Done in Team Apps Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fe-v4 Issues required for app-frontend v4 to be shippable kind/feature-request New feature or request org/ssb Issues relevant for Statistisk sentralbyrå.
Projects
Archived in project
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants