Skip to content

Commit

Permalink
Merge pull request #64 from architecture-building-systems/3096-fix-ed…
Browse files Browse the repository at this point in the history
…it-validator

Fix edit validator
  • Loading branch information
shanshanhsieh committed Mar 16, 2022
2 parents 72f2fdd + 8e0cca8 commit c60047e
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions src/renderer/components/InputEditor/EditSelectedModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,26 @@ const Table = ({ inputTable }) => {
return (
<div style={{ overflow: 'auto', maxHeight: 200 }}>
<table>
<tr>
{inputTable.getColumnDefinitions().map((columnDef) => (
<th style={{ padding: '0 15px' }} key={columnDef.title}>
{columnDef.title}
</th>
))}
</tr>
{inputTable
.getSelectedData()
.sort((a, b) => (a.Name > b.Name ? 1 : -1))
.map((data) => {
const row = inputTable.getColumnDefinitions().map((columnDef) => (
<td style={{ padding: '0 15px' }} key={columnDef.title}>
{data[columnDef.title]}
</td>
));
return <tr key={data.Name}>{row}</tr>;
})}
<tbody>
<tr>
{inputTable.getColumnDefinitions().map((columnDef) => (
<th style={{ padding: '0 15px' }} key={columnDef.title}>
{columnDef.title}
</th>
))}
</tr>
{inputTable
.getSelectedData()
.sort((a, b) => (a.Name > b.Name ? 1 : -1))
.map((data) => {
const row = inputTable.getColumnDefinitions().map((columnDef) => (
<td style={{ padding: '0 15px' }} key={columnDef.title}>
{data[columnDef.title]}
</td>
));
return <tr key={data.Name}>{row}</tr>;
})}
</tbody>
</table>
</div>
);
Expand Down Expand Up @@ -133,7 +135,7 @@ const createFormItem = (form, title, columnInfo) => {

const checkNumeric = (value, type) => {
if (type == 'string') return value;
if (value === null || value == '') return 0;
if (value === undefined || value == '') return 0;
const regex =
type === 'int' ? /^([1-9][0-9]*|0)$/ : /^([1-9][0-9]*|0)(\.\d+)?$/;
return regex.test(value) ? Number(value) : NaN;
Expand Down

0 comments on commit c60047e

Please sign in to comment.