From 5208d4d8223cb5c94bf693e8f45ce4d47e043513 Mon Sep 17 00:00:00 2001 From: Pedro Jesus Date: Fri, 9 Jun 2017 21:38:11 -0300 Subject: [PATCH 1/2] =?UTF-8?q?Implementado=20mecanismo=20para=20que=20o?= =?UTF-8?q?=20campo=20do=20tipo=20InputGridForm=20possa=20ser=20preenchido?= =?UTF-8?q?=20por=20um=20valor=20inicial.=20Ex:=20uma=20lista=20de=20items?= =?UTF-8?q?=20j=C3=A1=20gravados=20em=20um=20form=20de=20edi=C3=A7=C3=A3o.?= =?UTF-8?q?=20Ajustes=20na=20serializa=C3=A7=C3=A3o=20de=20campos=20tipo?= =?UTF-8?q?=20Autocomplete=20e=20Select.=20Ajuste=20na=20exibi=C3=A7=C3=A3?= =?UTF-8?q?o=20de=20campos=20do=20tipo=20number=20no=20componente=20Grid.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/js/components/grid_form/grid_form.js | 5 +++- .../input/grid_form/input_grid_form.js | 12 ++++++++++ src/js/components/table/table_cell.js | 2 +- src/js/mixins/input/select_component_mixin.js | 23 +++++++++---------- 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/js/components/grid_form/grid_form.js b/src/js/components/grid_form/grid_form.js index efb529a..1e3cc86 100644 --- a/src/js/components/grid_form/grid_form.js +++ b/src/js/components/grid_form/grid_form.js @@ -72,6 +72,9 @@ export default class GridForm extends Component { eagerLoad: true, readOnly: false, formComponent: Form, + data: { + dataRows: [] + }, onSubmit() {}, onReset() {}, onSuccess() { return true; }, @@ -87,7 +90,7 @@ export default class GridForm extends Component { selectedDataRow: {}, selectedRowId: null, isLoading: this.props.isLoading, - clientSideData: [], + clientSideData: this.props.data.dataRows, }; constructor(props) { diff --git a/src/js/components/input/grid_form/input_grid_form.js b/src/js/components/input/grid_form/input_grid_form.js index ae160c7..baa12b7 100644 --- a/src/js/components/input/grid_form/input_grid_form.js +++ b/src/js/components/input/grid_form/input_grid_form.js @@ -2,6 +2,7 @@ import React from 'react'; import _ from 'lodash'; import PropTypes from '../../../prop_types'; import { autobind, mixin } from '../../../utils/decorators'; +import { uuid } from '../../../utils'; import GridForm from '../../grid_form/grid_form'; import InputGridFormFields from './input_grid_form_fields'; @@ -31,6 +32,7 @@ export default class InputGridForm extends InputBase { fields: {}, form: {}, clientSide: true, + clientSideIdField: '_clientSideId', inputWrapperComponent: null, onSuccess() {}, onDestroySuccess() {}, @@ -58,6 +60,15 @@ export default class InputGridForm extends InputBase { })); } + buildGridData() { + const { value, clientSideIdField } = this.props; + const dataRows = !value || value === '' + ? [] + : value.map((v) => { return { ...v, [clientSideIdField]: uuid.v4() }; }); + + return { dataRows }; + } + /* GridForm Result serializer */ serialize() { @@ -108,6 +119,7 @@ export default class InputGridForm extends InputBase { formComponent={InputGridFormFields} form={this.parseFormProp()} columns={this.parseColumnsProp()} + data={this.buildGridData()} onSuccess={this.handleOnSuccess} onDestroySuccess={this.handleOnDestroySuccess} errors={this.props.errors} diff --git a/src/js/components/table/table_cell.js b/src/js/components/table/table_cell.js index 0d59b6f..95854f0 100644 --- a/src/js/components/table/table_cell.js +++ b/src/js/components/table/table_cell.js @@ -136,7 +136,7 @@ export default class TableCell extends Component { renderFormattedValue(value) { const valueFormatter = this.getValueFormatter().bind(this); - return (!_.isEmpty(value) || typeof value === 'boolean') ? valueFormatter(value) : '-'; + return (!_.isEmpty(value) || typeof value === 'boolean' || typeof value === 'number') ? valueFormatter(value) : '-'; } renderValue() { diff --git a/src/js/mixins/input/select_component_mixin.js b/src/js/mixins/input/select_component_mixin.js index 67493f9..ce122e3 100644 --- a/src/js/mixins/input/select_component_mixin.js +++ b/src/js/mixins/input/select_component_mixin.js @@ -251,17 +251,16 @@ export default { /* Serializer functions */ - getDisplayValues () { - return map(this.selectedOptions(), function(selectedOption) { - return selectedOption[this.props.nameField]; - }.bind(this)); - }, + getSelectValue() { + const { multiple } = this.props; + const { value } = this.state; - serialize () { - var serializedInput = {}; - serializedInput[this.props.name] = this.getValue(); - serializedInput[this.props.name + "Display"] = this.getDisplayValues(); + return (!multiple && Array.isArray(value)) + ? value[0] + : value; + }, - return serializedInput; - } -} + serialize() { + return { [this.props.name]: this.getSelectValue() }; + }, +}; From 352452d18e4ab4fb43886749669304eabada8f1c Mon Sep 17 00:00:00 2001 From: Pedro Jesus Date: Fri, 9 Jun 2017 21:41:59 -0300 Subject: [PATCH 2/2] =?UTF-8?q?Atualiza=C3=A7=C3=A3o=20do=20n=C3=BAmero=20?= =?UTF-8?q?da=20vers=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- bower.json | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 881d16b..cc670fe 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ ![alt tag](https://working-minds.github.io/realizejs/assets/img/content/realizejs.png) -### Current version: 0.9.10 beta +### Current version: 0.9.11 beta Read the documentation on how to get started on [Realize.js](https://working-minds.github.io/realizejs/en) diff --git a/bower.json b/bower.json index 2fce50b..7767270 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "realizejs", - "version": "0.9.10", + "version": "0.9.11", "authors": [ "Ariel Lindgren ", "Pedro Jesus ", diff --git a/package.json b/package.json index 5bce9e4..34d3045 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "realizejs", - "version": "0.9.10", + "version": "0.9.11", "description": "A rich set of UI components based on Material Design using React.js", "authors": [ "Ariel Lindgren ",