ForgeComponentes
pt

Componentes

j-Detail

jComponent 20 · jcomponent@20 component Exemplo carregado com jComponent 20

Este componente pode render valores do modelo. Apoia o mapeamento inline - olhe para o código-fonte do exemplo.


Configuração:

  • dateformat {String} um formato de data (default: DEF.dateformat)
  • datetimeformat {String} um formato de data/tempo (default: DEF.dateformat + ' ' + DEF.timeformat)
  • numberformat {Number} um formato de número padrão (default: vazio)
  • small {Boolean} permite design mais pequeno (default: false)
  • Estilo de componente style {Number} (default: 1), suporta o estilo 2, 3 (minimal) e 4 (moderno)
  • defaultgroup {String} um nome de grupo padrão (default: Default)
  • Valores nulos de notnull {Boolean} (default: false)
  • track {String} pode conter caminhos divididos por comma, esta propriedade só verá mudanças em chaves traçadas

Declaração de dados:

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' });

Propriedades de dados na declaração de dados:

  • group {String} um nome de grupo (requerido)
  • label {String} um rótulo (requerido)
  • type {String} um tipo (requerido)
  • note {String} - uma pequena nota abaixo do valor
  • Número format {String}, por exemplo, 2 ou formato de data dd.MM.yyyy
  • O endereço de URL detail {String} para a obtenção de dados para o tipo list, por exemplo: /users/{0}/ e {0} serão substituídos pelo valor da lista
  • Elementos items {Object Array/String} para o tipo list apenas, a fila pode conter um caminho para Array ou URL address para pesquisar
  • value {Object} um valor ou modelo com valores (até path é necessário)
  • path {String} um caminho para o valor no modelo (value deve conter um modelo)
  • template {String} A Tangular Atividades (só com type:'template' e {{ value }} contém um valor razoável, e {{ item }} Contém o item inteiro)
  • empty {String} Um valor vazio quando o valor é nulo (default: ---)
  • show {String} a função condicional value.type === 'company' então mostra se a condição avaliada é true
  • NEW autoformat {Boolean} permite o formato automático para email, ou phones, e apenas para o tipo string (default: false)
  • NEW colorize {Boolean} colora o valor com exceção do tipo list, color e icon
  • NEW plus {String} adiciona um valor ao fim do valor renderizado para os tipos number e string

Tipos permitidos em dados:

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

Bom para saber:

  • Se o grupo contém apenas um carrinho, então o nome do grupo não é apresentado.

Use-o com <ui-component name="detail">Quando o componente ainda não está carregado, jComponent Descarrega-o no primeiro uso do endereço DEF.fallback (a partir do Componentator CDN por padrão). autor: Peter Širka. fonte: o Componentator Reserva de componentes, licença 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>