这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class InsertItem extends Component {

const elements = columns.map((col, i) => {
const colName = col.column_name;
const isDefault = col.column_default && col.column_default.trim() !== '';
const hasDefault = col.column_default && col.column_default.trim() !== '';
const isNullable = col.is_nullable && col.is_nullable !== 'NO';

refs[colName] = { valueNode: null, nullNode: null, defaultNode: null };
Expand All @@ -81,10 +81,10 @@ class InsertItem extends Component {
onClick: clicker,
onChange: e => {
if (isAutoIncrement) return;
if (!isNullable && !isDefault) return;
if (!isNullable && !hasDefault) return;

const textValue = e.target.value;
const radioToSelectWhenEmpty = isDefault
const radioToSelectWhenEmpty = hasDefault
? refs[colName].defaultNode
: refs[colName].nullNode;

Expand All @@ -93,15 +93,15 @@ class InsertItem extends Component {
},
onFocus: e => {
if (isAutoIncrement) return;
if (!isNullable && !isDefault) return;
if (!isNullable && !hasDefault) return;

const textValue = e.target.value;
if (
textValue === undefined ||
textValue === null ||
textValue.length === 0
) {
const radioToSelectWhenEmpty = isDefault
const radioToSelectWhenEmpty = hasDefault
? refs[colName].defaultNode
: refs[colName].nullNode;

Expand Down Expand Up @@ -152,40 +152,13 @@ class InsertItem extends Component {
e.target.focus();
}}
>
<option value="" disabled>-- bool --</option>
<option value="true">True</option>
<option value="false">False</option>
</select>
);
}

let showDefaultOption = (
<input
type="radio"
ref={node => {
refs[colName].defaultNode = node;
}}
name={colName + '-value'}
value="option3"
defaultChecked={isDefault}
data-test={`typed-input-default-${i}`}
/>
);
if (!isDefault) {
showDefaultOption = (
<input
disabled
type="radio"
ref={node => {
refs[colName].defaultNode = node;
}}
name={colName + '-value'}
value="option3"
defaultChecked={isDefault}
data-test={`typed-input-default-${i}`}
/>
);
}

return (
<div key={i} className="form-group">
<label
Expand All @@ -203,7 +176,7 @@ class InsertItem extends Component {
}}
name={colName + '-value'}
value="option1"
defaultChecked={!isDefault & !isNullable}
defaultChecked={!hasDefault & !isNullable}
/>
{typedInput}
</label>
Expand All @@ -222,7 +195,17 @@ class InsertItem extends Component {
<span className={styles.radioSpan}>NULL</span>
</label>
<label className={styles.radioLabel + ' radio-inline'}>
{showDefaultOption}
<input
disabled={!hasDefault}
type="radio"
ref={node => {
refs[colName].defaultNode = node;
}}
name={colName + '-value'}
value="option3"
defaultChecked={hasDefault}
data-test={`typed-input-default-${i}`}
/>
<span className={styles.radioSpan}>Default</span>
</label>
</div>
Expand Down