j-Detail
Este componente puede representar valores del modelo. Admite mapeo en línea: consulte el código fuente del ejemplo.
Configuración:
dateformat {String}un formato de fecha (predeterminado:DEF.dateformat)datetimeformat {String}un formato de fecha/hora (predeterminado:DEF.dateformat + ' ' + DEF.timeformat)numberformat {Number}un formato de número predeterminado (predeterminado: vacío)small {Boolean}permite un diseño más pequeño (predeterminado:false)- Estilo de componente
style {Number}(predeterminado:1), admite el estilo2,3(mínimo) y4(moderno) defaultgroup {String}un nombre de grupo predeterminado (predeterminado:Default)notnull {Boolean}omite valores que aceptan valores NULL (predeterminado:false)track {String}puede contener rutas divididas por comas, esta propiedad observará solo los cambios en las claves rastreadas
Declaración de datos:
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' });Propiedades de datos en la declaración de datos:
group {String}un nombre de grupo (obligatorio)label {String}una etiqueta (obligatoria)type {String}un tipo (obligatorio)note {String}una pequeña nota por debajo del valor- Número
format {String}, p.2o formato de fechadd.MM.yyyy detail {String}Dirección URL para obtener datos para el tipolist, ejemplo:/users/{0}/y{0}se reemplazarán con el valor de la lista.- Elementos
items {Object Array/String}solo para el tipolist, la cadena puede contener una ruta aArrayoURL addresspara buscar value {Object}un valor o modelo con valores (entonces se requierepath)path {String}una ruta al valor en el modelo (valuedebe contener un modelo)template {String}Una plantilla Tangular (funciona solo contype:'template'y{{ value }}contiene un valor sin procesar y{{ item }}contiene el elemento completo)empty {String}Un valor vacío cuando el valor admite valores NULL (predeterminado:---)show {String}la función condicionalvalue.type === 'company'luego se muestra si la condición evaluada estrue- NEW
autoformat {Boolean}habilita el formato automático paraemailophones, y solo para el tipostring(predeterminado:false) - NEW
colorize {Boolean}colorea el valor excepto el tipolist,coloryicon. - NEW
plus {String}agrega un valor al final del valor representado para los tiposnumberystring
Tipos permitidos en datos:
stringboolnumberdatedatetimelistcoloremojifontawesomepasswordtemplate
Es bueno saberlo:
- si el grupo contiene solo un carácter, entonces el nombre del grupo no se representa
Úselo con <ui-component name="detail">. Cuando el componente aún no está cargado, jComponent lo descarga en el primer uso desde la dirección en DEF.fallback (la CDN Componentator de forma predeterminada). Autor: Peter Širka. Fuente: repositorio de componentes Componentator, licencia MIT.
<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>