All Projects → vazco → meteor-universe-autoform-select

vazco / meteor-universe-autoform-select

Licence: MIT License
Meteor universe autoform select

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

vazco/Universe Autoform Select

 

 

An add-on Meteor package for aldeed:autoform. Provides a single custom input type, "universe-select".

This package is part of Universe, a framework based on Meteor platform maintained by Vazco.

It works standalone, but you can get max out of it when using the whole system.

Demo

http://universe-autoform-select.stg.vazco.eu/
https://github.com/vazco/meteor-universe-autoform-select-demo.git

Prerequisites

The plugin library must be installed separately.

In a Meteor app directory, enter:

$ meteor add aldeed:autoform

Installation

In a Meteor app directory, enter:

$ meteor add vazco:universe-autoform-select

For use without autoform

Universe selectize standalone:

https://github.com/vazco/meteor-universe-selectize/

Usage

Specify "universe-select" for the type attribute of any input. This can be done in a number of ways:

In the schema, which will then work with a quickForm or afQuickFields:

{
  tags: {
    type: [String],
    autoform: {
      type: "universe-select",
      afFieldInput: {
        multiple: true
      }
    }
  }
}

Or on the afFieldInput component or any component that passes along attributes to afFieldInput:

{{> afQuickField name="tags" type="universe-select" multiple=true}}

{{> afFormGroup name="tags" type="universe-select" multiple=true}}

{{> afFieldInput name="tags" type="universe-select" multiple=true}}

Autosave

If you enable autosave option in autoform, then it triggering after blur of universe-select (if multiple).

Options

universe-select options
Option Description Type Default
options Required. A function returning either an array of options, or a Mongo.Cursor. The function is re-evaluated automatically using Tracker when its reactive data sources change. function undefined
uniPlaceholder Optional. A placeholder option. String null
optionsPlaceholder Optional. Show placeholder in options dropdown. Boolean or String false
uniDisabled Optional. Boolean false
multiple Optional. Boolean false
removeButton Optional. Boolean true
valuesLimit Optional. Number undefined
create Optional. Allows the user to create a new items that aren't in the list of options. Boolean true
createOnBlur Optional. If true, when user exits the field (clicks outside of input or presses ESC) new option is created and selected (if `create`-option is enabled). Boolean true
createSlug Optional. After creating new label, converts value into a slug. Boolean true
createMethod Optional. Name of method to call after create new item. Method can return new value for item. function (label, value) undefined
optionsMethod Optional. Name of method to get more items. Method should return array of options. String undefined
optionsMethodParams Optional. Additional params for optionsMethod. Object undefined

Example optionsMethod:

Meteor.methods({
    getOptions: function (options) {
        this.unblock();
        var searchText = options.searchText;
        var values = options.values;

        if (searchText) {
            return OptionsCollection.find({label: {$regex: searchText}}, {limit: 5}).fetch();
        } else if (values.length) {
            return OptionsCollection.find({value: {$in: values}}).fetch();
        }
        return OptionsCollection.find({}, {limit: 5}).fetch();
    }
});

License

Like every package maintained by Vazco, Universe Autoform Select is MIT licensed.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].