ForgeKomponenty
pl

Komponenty

j-Detail

jComponent 20 · jcomponent@20 component Przykład załadowany z jComponent 20

Ten element może przekazać wartości z modelu. obsługuje mapowanie w linii - zobacz kod źródłowy przykładu.


Konfiguracja:

  • dateformat {String} w formacie daty (default: DEF.dateformat)
  • datetimeformat {String} w formacie daty/czasu (default: DEF.dateformat + ' ' + DEF.timeformat)
  • numberformat {Number} - standardowy format liczby (default: empty)
  • small {Boolean} umożliwia mniejsze projektowanie (default: false)
  • Styl składowy style {Number} (default: 1), wspiera styl 2, 3 (minimalny) i 4 (nowoczesny)
  • defaultgroup {String} - domyślna nazwa grupy (default: Default)
  • notnull {Boolean} Wskaźnik wartości nullable (default): false)
  • track {String} może zawierać ścieżki podzielone przez komę, ta nieruchomość będzie obserwować tylko zmiany w wyciągniętych kluczy

Deklaracja danych:

var model = { firstname: 'Peter', lastname: 'Širka', age: 33 };
var items = [{ id: 2, name: 'Banská Bystrica' }, { id: 3, name: 'Bratislava' }];
var form = [];

// The below values will be binded automatically from the "model" (according to the "path" field) because they contain "path" field
form.push({ group: 'Personal', label: 'First name', path: 'firstname', type: 'string', value: model, note: 'This is first name' });
form.push({ group: 'Personal', label: 'Last name', path: 'lastname', type: 'string', value: model, placeholder: 'String' });
form.push({ group: 'Personal', label: 'Age', path: 'age', type: 'number', value: model });

// The below values will be binded from "value" key
form.push({ group: 'Personal', label: 'Birth date', type: 'date', value: NOW });
form.push({ group: 'Additional', label: 'Newsletter', type: 'bool', value: true });
form.push({ group: 'Additional', label: 'City', type: 'list', value: 2, items: 'items' });
form.push({ group: 'Additional', label: 'Color', type: 'color', value: '#e73323' });
form.push({ group: 'Additional', label: 'Icon', type: 'fontawesome', value: 'fas fa-home' });

Właściwości danych w deklaracji danych:

  • group {String} nazwa grupy (wymagane)
  • label {String} etykietę (wymagane)
  • type {String} typu (wymagane)
  • note {String} - mała notka poniżej wartości
  • Numer format {String} np. 2 lub format daty dd.MM.yyyy
  • Adres URL detail {String} do uzyskania danych dla typu list, przykład: /users/{0}/ i {0} zostaną zastąpione wartością z listy
  • Elementy items {Object Array/String} dla typu list mogą zawierać ścieżkę do Array lub URL address do wyszukiwania
  • value {Object} wartość lub model z wartościami (wówczas wymagany jest path)
  • path {String} - droga do wartości w modelu (value musi zawierać model)
  • template {String} A Tangular szablon (pracuje tylko z type:'template' i {{ value }} zawiera wartość surową, a {{ item }} zawiera cały element)
  • empty {String} Wartość pusta, gdy wartość jest zerowalna (default: ---)
  • show {String} Funkcja warunkowa value.type === 'company' Wyjaśnij, czy oceniany stan jest true
  • NEW autoformat {Boolean} umożliwia automatyczny format dla email, lub phones, i tylko dla typu string (default: false)
  • NEW colorize {Boolean} koloruje wartość z wyjątkiem typów list, color i icon
  • NEW plus {String} dodaje wartość do końca wartości renderowanej dla typów number i string

Dozwolone typy w danych:

  • string
  • bool
  • number
  • date
  • datetime
  • list
  • color
  • emoji
  • fontawesome
  • password
  • template

Dobrze wiedzieć:

  • Jeśli grupa zawiera tylko jeden z nich, nazwa grupy nie zostanie przekazana.

Użyj go z <ui-component name="detail">Gdy element nie jest jeszcze ładowany, jComponent Pobierz go po pierwszym użyciu z adresu DEF.fallback (Wydaje się Componentator Autor: Peter Širka Źródło: Componentator Zestaw składników, licencja MIT.

example.html
<div style="width:500px">
	<ui-component name="detail" path="form"></ui-component>
	<br />
	<div>-- OR --</div>
	<br />
	<ui-component name="detail" path="model" config="style:2">
		<script type="text/plain">
			[
				{ name: 'First name', path: 'firstname', type: 'string' },
				{ name: 'Last name', path: 'lastname', type: 'string' },
				{ name: 'Age', path: 'age', type: 'number' }
			]
		</script>
	</ui-component>
	<br />
	<div>-- OR FILTERED --</div>
	<br />
	<ui-component name="detail" path="model" config="style:3">
		<script type="text/plain">
			[
				// Will be displayed, look to show condition ("value" means "model")
				{ name: 'First name', path: 'firstname', type: 'string', show: 'value.type==1' },
				{ name: 'Last name', path: 'lastname', type: 'string', show: 'value.type==1' },
				// Won't be displayed, look to show condition ("value" means "model")
				{ name: 'Age', path: 'age', type: 'number', show: 'value.type==2' }
			]
		</script>
	</ui-component>
	<br />
	<ui-component name="detail" path="model" config="style:4">
		<script type="text/plain">
			[
				// Will be displayed, look to show condition ("value" means "model")
				{ name: 'First name', path: 'firstname', type: 'string', show: 'value.type==1' },
				{ name: 'Last name', path: 'lastname', type: 'string', show: 'value.type==1' },
				// Won't be displayed, look to show condition ("value" means "model")
				{ name: 'Age', path: 'age', type: 'number', show: 'value.type==2' }
			]
		</script>
	</ui-component>
</div>

<script>
	var model = { firstname: 'Peter', lastname: 'Širka', age: 33, type: 1 };
	var items = [{ id: 2, name: 'Banská Bystrica' }, { id: 3, name: 'Bratislava' }];
	var form = [];

	// The below values will be binded automatically from the "model" (according to the "path" field) because they contain "path" field
	form.push({ group: 'Personal', label: 'First name', path: 'firstname', type: 'string', value: model, note: 'This is first name' });
	form.push({ group: 'Personal', label: 'Last name', path: 'lastname', type: 'string', value: model, placeholder: 'String' });
	form.push({ group: 'Personal', label: 'Age', path: 'age', type: 'number', value: model });

	// The below values will be binded from "value" key
	form.push({ group: 'Personal', label: 'Birth date', type: 'date', value: NOW });
	form.push({ group: 'Additional', label: 'Newsletter', type: 'bool', value: true });
	form.push({ group: 'Additional', label: 'City', type: 'list', value: 2, items: 'items' });
	form.push({ group: 'Additional', label: 'Color', type: 'color', value: '#e73323' });
	form.push({ group: 'Additional', label: 'Icon', type: 'fontawesome', value: 'ti ti-home' });
</script>