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

RFC: New question type "MultipleFileQuestion" #1780

Open
czosel opened this issue Jun 3, 2022 · 6 comments
Open

RFC: New question type "MultipleFileQuestion" #1780

czosel opened this issue Jun 3, 2022 · 6 comments

Comments

@czosel
Copy link
Contributor

czosel commented Jun 3, 2022

When using file questions, it is often desired that more that one file can be uploaded. Currently this is only possible in Caluma using TableQuestions, which doesn't yield a good UX when the table form consists of just one FileQuestion.

We'd propose to add a new question type "MultipleFileQuestion" which is very similar to the existing "FileQuestion", but allows uploading more than one file.

The API could look like this:

FileAnswer (existing, just for reference)

Request:

{
    "operationName": "SaveDocumentFileAnswer",
    "variables": {
        "input": {
            "question": "some-slug",
            "document": "7da68336-8ccd-47cb-8800-81e4444bc649",
            "value": "test.pdf"
        }
    },
    "query": "mutation SaveDocumentFileAnswer($input: SaveDocumentFileAnswerInput!) { ... }"
}

Response:

{
  "answer": {
    "id": "some-id",
    "question": {
      "slug": "some-slug",
      "__typename": "FileQuestion"
    },
    "fileValue": {
      "id": "some-id",
      "uploadUrl": "",
      "downloadUrl": "",
      "metadata": null,
      "name": "pdf-test (copy).pdf",
      "__typename": "File"
    },
  },
}

MultipleFileAnswer

Request:

{
    "operationName": "SaveDocumentMultipleFileAnswer",
    "variables": {
        "input": {
            "question": "some-id",
            "document": "7da68336-8ccd-47cb-8800-81e4444bc649",
            "value": [
              // existing file
              {
                "id": <File UUID>,
                "name": "pdf-test (copy).pdf"
              },
              {
                "name": "pdf-test (copy).pdf" // new file
              }
              // deleting files: just leave them out
            ]
        }
    },
    "query": "mutation SaveDocumentFileAnswer($input: SaveDocumentFileAnswerInput!) { ... }"
}

Response:

{
  "answer": {
    "id": "some-id",
    "question": {
      "slug": "some-slug",
      "__typename": "MultipleFileQuestion"
    },
    "multipleFileValue": [
      {
        "id": "some_id",
        "uploadUrl": "",
        "downloadUrl": "",
        "metadata": null,
        "name": "pdf-test (copy).pdf",
        "__typename": "File"
      },
      ...
    ]
  }
}
@StephanH90
Copy link
Contributor

Does this allow you to rename the files as well by supplying an ID with a different name?

@derrabauke
Copy link
Contributor

Does this allow you to rename the files as well by supplying an ID with a different name?

Currently this is not intended. For this use-case you would have to delete the file and upload it again with the correct name.

@StephanH90
Copy link
Contributor

StephanH90 commented Jul 7, 2022

But doesn't that go against the general caluma API where you can simply supply the same mutation with new values to change an existing resource?

mutation changeTitle {
  SaveTextQuestion(input: { slug: "some-question", label: "cool new label" }) {
    question {
      id
    }
  }
}

The only 2 places where I had to implement or work with file uploads (TCS and alexandria) both required the renaming of files.

If it isn't much effort it might be worth doing it now, otherwise I guess we wait until its requested.

@winged
Copy link
Contributor

winged commented Jul 12, 2022

Does this allow you to rename the files as well by supplying an ID with a different name?

Currently this is not intended. For this use-case you would have to delete the file and upload it again with the correct name.

Sorry for correcting you, but what @StephanH90 asks is indeed possible with the current backend implementation: If you provide a new name for a given file ID, it will rename it internally and do the work needed so the file is moved in Minio as well. See the update_answer_files() implementation in the PR.

@derrabauke
Copy link
Contributor

Oh sorry, for the incorrect feedback then! But this feature will not be part of the current ember-caluma implementation for now.

@winged
Copy link
Contributor

winged commented Jul 13, 2022

Oh sorry, for the incorrect feedback then! But this feature will not be part of the current ember-caluma implementation for now.

So what's the ember-caluma release plan for this? Just not ready jet, or is it delayed on purpose?

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

4 participants