1.11.1 • Published 5 years ago

@molgenis/molgenis-ui-filter v1.11.1

Weekly downloads
62
License
LGPL-3.0
Repository
-
Last release
5 years ago

codecov Commitizen friendly

molgenis-ui-filter

Filter Container

The filter container takes a descriptive input array to create a set of filters. It will also require a 2 way bound output object to receive the filters state

<filter-container
  v-model="selections"
  :filters="filters"
  :filters-shown="filtersShown"
  :can-edit="true"
/>

Properties

  • selections: Will hold the settings set in filters.
  • filters: A definition list of all possible filters.
  • filtersShown: A array of filter names that will be shown.
  • can-edit: if true you will be able to add, move and remove filters.

Events

  • update: this event is fired when filtersShown is updated, it will return a new list of selected filters

Filter input object specifications

filters: [ {
    name: 'search',
    label: 'Search',
    description: 'search by name',
    initiallyCollapsed: true,
    placeholder: 'test',
    type: 'string-filter'
}, {
    name: 'country',
    label: 'Countries',
    initiallyCollapsed: false,
    options: [{ value: 'nl', text: 'Nederland' }, { value: 'de', text: 'Duitsland' }, { value: 'be', text: 'België' }],
    type: 'checkbox-filter'
}]

Every filter will have the following global properties:

namerequireddefault valuedescription
nametruenastring: name and id of the filter
labelfalsestring: name of the filter as used by the UI
descriptionfalsedescriptive text that is used by the UI
collapsedfalsetrueboolean: Open/Closed state of the card that holds the filter
collapsablefalsetrueboolean: Can the card be collapsed. This will force the card to be open by default if set to false
typetruenavue object that renders the filter
valuefalseemptythe (pre)selected option(s)

The type field takes a VUE object that renders a filter. Note that every object can have additional filter properties

Additional filter properties

CheckboxFilter

namerequireddefault valuedescription
optionstruenadescribe the checkboxes. This is a function holding a promise holding the options (see example below)
bulkOperationfalsetrueadds 'select all' and or 'Deselect all' button
maxVisibleOptionsfalseundefined (show all options)limit the amount of initially shown options

options example

() => {
    return new Promise(
        function (resolve) {
            resolve([{ value: 'value1', text: 'Checkbox 1' }, { value: 'value2', text: 'Checkbox 2' }])
        }
    )
}

DateTimefilter

namerequireddefault valuedescription
maxfalsenull : stringSet the minimal date you can select, needs to be able to be parsed by the Date object
minfalsenull : stringSet the maximum date you can select, needs to be able to be parsed by the Date object
opensfalse'right' : stringSet the alignment of the popup. Possible options: 'left', 'right', 'center'
timefalsetrue : booleanAdd a time selection to the data time picker
rangefalsetrue : booleanAdd a range selection to be able to make a from-to selection

Multifilter

The multifilter is a composite filter. It uses a searchbox, which searches for options. The usecase is to generate a list of checkboxes based on a user query (capped to first 100) when the options are of n length.

namerequireddefault valuedescription
optionstruena : Functiondescribe the checkboxes. This is a function returns a promise which can query and return options (see example below)
placeholderfalseempty : Stringfill the placeholder in the searchbox
maxVisibleOptionsfalse10 : Numberlimit the amount of initially shown options by n
initialDisplayItemsfalse5 : NumberInitial set of items to be displayed

options example

(params: object) => {
  const data = await axios.get(url, { params })

  return Promise.resolve(
    data.data.items.map((i: any) => {
      return { value: i.data[*idName*], text: i.data[*attrName*] }
    })
  )
}

StringFilter

namerequireddefault valuedescription
placeholderfalsePlaceholder in the input field

NumberFilter, RangeFilter

namerequireddefault valuedescription
minfalseminimal posible value
maxfalsemaximal posible value
stepfalse1step size of slider and up/down buttons
useSliderfalsefalseshow a slider to help pick a number

Resulting output object

The resulting filter status is an object that holds the name fields of the filter description object and the resulting selected values. Note the 2 way vue binding. Feed in the default values by setting them here on object creation.

selections: {
  search: '',
  country: ['nl']
},

Project setup

yarn install

Compiles and hot-reloads for development

yarn run serve

Compiles and minifies for production

yarn run build

Lints and fixes files

yarn run lint

Run your end-to-end tests

yarn run test:e2e

Run your unit tests

yarn run test:unit

How to commit

We use conventional commits to generate changelogs and release notes. Please check: https://www.conventionalcommits.org/

Example

git commit file.ext -m "fix(file.ext): fixes something"

How to publish

Each time a PR is merged a release will be done to NPM. The CHANGELOG.md and GitHub release will be ammended.

The version of the package is based upon convential commits. Check: http://commitizen.github.io/cz-cli/.

1.11.1

5 years ago

1.11.0

5 years ago

1.10.1

5 years ago

1.10.0

5 years ago

1.9.3

5 years ago

1.9.1

5 years ago

1.9.0

5 years ago

1.8.3

5 years ago

1.8.2

5 years ago

1.8.1

5 years ago

1.8.0

5 years ago

1.7.0

5 years ago

1.6.2

5 years ago

1.6.1

5 years ago

1.6.0

5 years ago

1.5.6

5 years ago

1.5.5

5 years ago

1.5.4

5 years ago

1.5.3

5 years ago

1.5.2

5 years ago

1.5.1

5 years ago

1.5.0

5 years ago

1.4.2

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago