Class

Gallery

kiss.ui.Gallery(config)

The Gallery derives from DataComponent.

It's a simple gallery with the following features:

  • choosing the fields to display in the cards
  • multi-fields sorting
  • complex filtering with combination of AND/OR filters
  • mutli-level grouping
  • virtual scrolling which also works with grouped data
  • possibility to choose the featured image to display in the card
Constructor

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

Create the Web Component and call its init method:

const myGallery = document.createElement("a-gallery").init(config)

Or use the shorthand for it:

const myGallery = createGallery({
  id: "my-gallery",
  color: "#00aaee",
  collection: kiss.app.collections["contact"],

  // We can define a menu with custom actions
  actions: [
      {
          text: "Group by status",
          icon: "fas fa-sort",
          action: () => $("my-gallery").groupBy(["Status"])
      }
  ],
  
  // We can add custom methods, and also override default ones
  methods: {

     // Override the createRecord method
     createRecord(model) {
         // Create a record from this model
         console.log(model)
     },

     // Override the selectRecord method
     selectRecord(record) {
         // Show the clicked record
         console.log(record)
     },

     sayHello: () => console.log("Hello"),
  }
})

myGallery.render()
Parameters:
Name Type Attributes Description
config object
collection Collection

The data source collection

showImage boolean <optional>

Show the image in the gallery (default = true)

imageFieldId string <optional>

The field to use as the image in the gallery. If not set, the first attachment field will be used.

record object <optional>

Record to persist the view configuration into the db

columns Array.<object> <optional>

Where each column is: {title: "abc", type: "text|number|integer|float|date|button", id: "fieldId", button: {config}, renderer: function() {}}

color string <optional>

Hexa color code. Ex: #00aaee

showToolbar boolean <optional>

false to hide the toolbar (default = true)

showActions boolean <optional>

false to hide the custom actions menu (default = true)

showLayoutButton boolean <optional>

false to hide the button to adjust the layout (default = true)

canSearch boolean <optional>

false to hide the search button (default = true)

canSelect boolean <optional>

false to hide the selection checkboxes (default = true)

canSort boolean <optional>

false to hide the sort button (default = true)

canFilter boolean <optional>

false to hide the filter button (default = true)

canGroup boolean <optional>

false to hide the group button (default = true)

canSelectFields boolean <optional>

Can we select the fields (= columns) to display in the gallery? (default = true)

canCreateRecord boolean <optional>

Can we create new records from the gallery?

createRecordText boolean <optional>

Optional text to insert in the button to create a new record, instead of the default model's name

actions Array.<object> <optional>

Array of menu actions, where each menu entry is: {text: "abc", icon: "fas fa-check", action: function() {}}

width number | string <optional>
height number | string <optional>

View Source client/ui/data/gallery.js, line 50

this

Generated markup

<a-gallery class="a-gallery">
     <div class="gallery-toolbar">
         <!-- Gallery toolbar items -->
     </div>
     <div class="gallery-body-container">
         <div class="gallery-body">
             <!-- Body columns -->
         </div>
     </div>
</a-gallery>

Methods

# collapseAll()

Collapse all groups

View Source client/ui/data/gallery.js, line 479

this

# collapseGroup(groupId)

Collapse a group

Parameters:
Name Type Description
groupId string

returns this

View Source client/ui/data/gallery.js, line 412

# expandAll()

Expand all groups

View Source client/ui/data/gallery.js, line 492

this

# expandGroup(groupId)

Expand a group

Parameters:
Name Type Description
groupId string

View Source client/ui/data/gallery.js, line 439

this

# async resetColumnsWidth()

Reset all the columns to their default width

View Source client/ui/data/gallery.js, line 398

# resetSearchMode()

Reset search mode

View Source client/ui/data/gallery.js, line 243

# async setColor(newColor)

Update the gallery color (toolbar buttons + modal windows)

Parameters:
Name Type Description
newColor string

View Source client/ui/data/gallery.js, line 257

# setColumnWidth(width)

Set the gallery column width

Parameters:
Name Type Description
width number

The column width in pixels

View Source client/ui/data/gallery.js, line 385

# showFieldsWindow()

Show the window just under the fields selector button

View Source client/ui/data/gallery.js, line 356

# showFilterWindow()

Show the window just under the filter button

View Source client/ui/data/gallery.js, line 365

# showSetupWindow()

Show the window to setup the gallery:

  • field used to display the image

View Source client/ui/data/gallery.js, line 268

# showSortWindow()

Show the window just under the sorting button

View Source client/ui/data/gallery.js, line 347

# switchToSearchMode()

Switch to search mode

Show/hide only the necessary buttons in this mode.

View Source client/ui/data/gallery.js, line 231

# updateLayout()

Update the gallery size (recomputes its width and height functions)

View Source client/ui/data/gallery.js, line 372

new Gallery

Methods