# j-Detail

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

Framework: jcomponent20
Product: jComponent 20 (jcomponent@20)
Language: pl
Content-SHA256: b9af70e4c11b6ea671c9aacca4a0680ac1fc64e901ec84a1cf13169eb7f1529b
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: components@910ed1a86f6e72b4f031d3ad0dc7844f9fc5cb8e
Review: not-recorded

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__:

```javascript
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.

```html 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>
```
