Class

Attachment

kiss.ui.Attachment(config)

The Attachment derives from Component.

It allow to manipulate files:

  • upload files
  • preview uploaded files
  • delete files
Constructor

# new Attachment(config)

Its a Custom Web Component. Do not use the constructor directly with the new keyword. Instead, use one of the 3 following methods:

Create the Web Component and call its init method:

const myAttachment = document.createElement("a-attachment").init(config)

Or use the shorthand for it:

const myAttachment = createAttachment({
 label: "My uploaded files",
 multiple: true
})

myAttachment.render()

Or directly declare the config inside a container component:

const myPanel = createPanel({
  title: "My panel",
  items: [
      {
         type: "attachment",
         label: "My uploaded files",
         multiple: true
      }
  ]
})
myPanel.render()
Parameters:
Name Type Attributes Description
config object
label string <optional>
buttonText string <optional>

Text of the upload button. Defaults to "attach files"

value Array.<object> <optional>

Default value

layout string <optional>

"" (default) | "thumbnails" | "thumbnails-large"

allowLayout boolean <optional>

true (default) to display the buttons to change the layout

multiple boolean <optional>

TODO: true to enable multi-select

readOnly boolean <optional>
disabled boolean <optional>

TODO

required boolean <optional>

TODO

margin string <optional>
padding string <optional>

View Source client/ui/fields/attachment.js, line 41

this

Generated markup

The field is a composition of various elements:

  • a span for the field label
  • a span for the button to upload new files, which includes a span for the button icon
  • a div to display the gallery of thumbnails
<a-attachment class="a-attachment">
  <span class="field-label"></span>
  <span class="a-button attachment-button field-upload-button">
      <span class="fas fa-paperclip attachment-icon"></span> Attach files
  </span>
  <div class="field-attachment-gallery">
  </div>
</a-attachment>

Methods

# getLabel() → {string}

Get the field label

View Source client/ui/fields/attachment.js, line 414

string

# getValue() → {Array.<string>}

Get the field value

View Source client/ui/fields/attachment.js, line 394

  • The field value
Array.<string>

# renderAs(mode)

Render the attachments in different modes:

  • list
  • thumbnails
  • large thumbnails
Parameters:
Name Type Description
mode string

"list" | "thumbnails" | "thumbnails-large"

View Source client/ui/fields/attachment.js, line 183

# resetValue()

Reset the field value

View Source client/ui/fields/attachment.js, line 403

this

# setLabel(newLabel)

Set the field label

Parameters:
Name Type Description
newLabel string

View Source client/ui/fields/attachment.js, line 424

this

# setValue(newValues, rawUpdateopt)

Set the field value

Parameters:
Name Type Attributes Description
newValues Array.<object>

The new field value

rawUpdate boolean <optional>

If true, it doesn't update the associated record and doesn't trigger "change" event

View Source client/ui/fields/attachment.js, line 344

this

# showUploadWindow()

Display the upload window of the attachment field

View Source client/ui/fields/attachment.js, line 268

# validate() → {boolean}

Validate the field (always true because Attachment fields can't have wrong values)

View Source client/ui/fields/attachment.js, line 437

boolean