Skip to main content
September 23, 2022
Question

Document viewer Field Help

  • September 23, 2022
  • 13 replies
  • 0 views

How can we add something like an "Upload" or "Preview Document" button on the form that submits (typically without validation), and simply chains back to itself - this will give the user the impression they have not left the form, but turns the document into an official object that can then be previewed.

    13 replies

    csteward
    September 23, 2022

    This is pretty much as straightforward as adding a!buttonArrayLayout() on the interface that submits the form, then the form will chain back to itself - typically with a decision node to determine if they are asking for a preview, or submitting/canceling the form to move the process:

    A quick and dirty sample interface would be something like below with 2 inputs for document (document), and navigation (text):

    a!localVariables(
      local!document,
      /* there are more graceful ways to check for doc existance */
      local!documentExists: not(tostring(ri!document)="[Document:]"),
      a!formLayout(
        label: "Document Upload / Preview",
        contents: {
          a!columnsLayout(
            columns: {
              a!columnLayout(
                contents: {
                  a!boxLayout(
                    label: "Select Document",
                    style: "ACCENT",
                    contents: {
                      a!sideBySideLayout(
                        items: {
                          a!sideBySideItem(
                            item: a!fileUploadField(
                              value: local!document,
                              saveInto: local!document,
                              maxSelections: 1
                            )
                          ),
                          a!sideBySideItem(
                            item: a!buttonArrayLayout(
                              buttons: {
                                a!buttonWidget(
                                  label: "Preview Document",
                                  value: "PREVIEW",
                                  saveInto: {
                                    ri!navigation,
                                    a!save(ri!document,local!document)
                                  }
                                )
                              }
                            )
                          )
                        }
                      )
                    }
                  )
                }
              ),
              a!columnLayout(
                contents: {
                  a!boxLayout(
                    label: "Select Document",
                    style: "ACCENT",
                    contents: {
                      a!documentViewerField(
                        showWhen: local!documentExists,
                        document: ri!document
                      ),
                      a!richTextDisplayField(
                        showWhen: not(local!documentExists),
                        value: {
                          a!richTextItem(
                            text: "You must click Preview on the left for the document to be viewed",
                            style: "EMPHASIS"
                          )
                        }
                      )
                    }
                  )
                }
              )
            }
          )
        },
        buttons: a!buttonLayout(
          primaryButtons: {
            a!buttonWidget(
              label: "Submit",
              validate: true,
              submit: true,
              value: "SUBMIT",
              saveInto: {
                ri!navigation,
                a!save(ri!document,local!document)
              }
            )
          },
          secondaryButtons:  {
            a!buttonWidget(
              label: "Cancel",
              validate: false,
              submit: true,
              value: "CANCEL",
              saveInto: ri!navigation
            )
          }
        )
      )
    )

    Just to note, this is a continuation of the other thread on the topic.

    mikes0011
    Brainy
    September 23, 2022
    this is a continuation of the other thread on the topic

    and... copied nearly word-for-word from your comment -- and... posted by 2 separate accounts ... *scratches head*  [emoticon:db2e98b6d4d6460c8802c63379d79040]

    The Expression Guru
    csteward
    September 23, 2022

    ..I didn't note the 2 separate accounts...  [emoticon:ad09a845b95e4cb28c5d9684a032037c]