ForgeComponents
en

Components

j-MultiOptions

jComponent 20 · jcomponent@20 component Example loaded with jComponent 20
  • it expects the whole object with key: value
  • HTML body of the jComponent has to be <script type="text/plain> with (JavaScript) mapping

Configuration:

  • rebind {Boolean} rebinds a path value according to the MultiOptions schema (default: true)

Mapping:

  • it's provided on immediately when the component is ready
  • it has to wrapped in <script type="text/plain">option();option();...</script>
  • mapping method: option(key, label, value, [type], [max], [min], [step])

Basic types:

  • type: string (when is the value string you don't need to define the type)
  • type: number (when is the value number you don't need to define the type)
  • type: boolean (when is the value boolean you don't need to define the type)
  • type: date (when is the value date you don't need to define the type)
  • NEW type: multiline renders textarea instead of input

Simple Array:

option('language', 'Language', 'sk', ['sk', 'en', 'de']);

Advanced Array:

option('language', 'Language', 1, [{ text: 'sk', value: 1}, { text: 'en', value: 2}, { text: 'de', value: 3}]);

Array from URL:

option('language', 'Language', 1, '/my/api/codelist/');
// It expects some "Array"

Colors:

MultiOptions component uses this color scheme: http://codepen.io/devi8/pen/lvIeh and the declaration below will show all colors in the widget settings.

option('background', 'Background', '#FC6E51', 'Color');

Good to know:

  • all properties not defined in mapping won't be shown
  • date type is linked by Calendar component
  • follow example
  • component.remap(js_code) can remap new configuration
  • component.dependencies() returns Object with all items key/value from dropdown lists

Use it with <ui-component name="multioptions">. When the component is not loaded yet, jComponent downloads it on first use from the address in DEF.fallback (the Componentator CDN by default). Author: Peter Širka. Source: the Componentator components repository, MIT license.

example.html
<div style="width:600px;margin:30px auto">
	<ui-component name="multioptions" path="options" class="block">
		<script type="text/plain">
			option('background', 'Background Color', '#8CC152', 'Color');
			option('type', 'Type', 'days', ['hours', 'days', 'months', 'years']);
			option('showArea', 'Show area', true);
			option('body', 'Body', 'Here is enabled\nmultiline.', 'MultiLine');
			option('showPoint', 'Show point', true);
			option('showLine', 'Show line', true);
			option('smoothCurves', 'Smooth curves', true);
			option('YshowLabel', 'Axis Y: Show Label', true);
			option('YshowGrid', 'Axis Y: Show Grid', false);
			option('onlyInteger', 'Whole numbers', true);
			option('decimals', 'Decimals', 1);
		</script>
	</ui-component>
</div>

<script>
	var options = {};
	options.background = '#8CC152';
	options.type = 'years';
	options.decimals = 2;
</script>