这是indexloc提供的服务,不要输入任何密码
Skip to content
Closed
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions console/src/components/Common/Common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ table thead tr th
color: #4D4D4D;
font-weight: 600 !important;
}

.textareaButtonAlign {
position: relative;
float: right;
margin-left: -30px;
margin-right: 5px;
margin-top: 10px;
}

.pageSidebar {
height: calc(100vh - 50px);
overflow: auto;
Expand Down
66 changes: 66 additions & 0 deletions console/src/components/Common/Toggler/Toggler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import React, { Component } from 'react';

const styles = require('../Common.scss');

class Toggler extends Component {
constructor(props) {
super(props);

this.state = {
input_textarea: 0,
input_value: this.props.standardProps.defaultValue,
};

this.handleClick = this.handleClick.bind(this);
}

handleClick(e) {
e.preventDefault();
const stateValue = this.state.input_textarea;
if (stateValue === 0) {
this.setState({ input_textarea: 1 });
} else {
this.setState({ input_textarea: 0 });
}
}

render() {
return (
<span>
<label>
{this.state.input_textarea === 1 ? (
<textarea
{...this.props.standardProps}
placeholder={this.props.placeholderProp}
value={this.state.input_value}
onChange={e => {
this.setState({ input_value: e.target.value });
}}
rows="5"
cols="5"
/>
) : (
<input
{...this.props.standardProps}
placeholder={this.props.placeholderProp}
value={this.state.input_value}
onChange={e => {
this.setState({ input_value: e.target.value });
}}
/>
)}
</label>
<i
className={
this.state.input_textarea === 1
? 'fa fa-compress' + ' ' + styles.textareaButtonAlign
: 'fa fa-expand' + ' ' + styles.textareaButtonAlign
}
onClick={this.handleClick}
/>
</span>
);
}
}

export default Toggler;
41 changes: 19 additions & 22 deletions console/src/components/Services/Data/TableBrowseRows/EditItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import globals from '../../../../Globals';
import { modalClose } from './EditActions';
import Button from '../../Layout/Button/Button';

import Toggler from '../../../Common/Toggler/Toggler';
// import RichTextEditor from 'react-rte';
import { replace } from 'react-router-redux';

Expand Down Expand Up @@ -187,37 +188,33 @@ class EditItem extends Component {
defaultValue = this.state.editorColumnMap[colName];
currentValue = this.state.editorColumnMap[colName];
}
const standardInputProps = {
type: 'text',
className: `form-control ${styles.insertBox}`,
onClick: clicker,
ref: inputRef,
onChange: e => {
this.onTextChange(e, colName);
},
defaultValue: currentValue,
'data-test': `typed-input-${i}`,
};
if (currentValue !== '') {
typedInput = (
<span>
<input
placeholder={'text'}
type="text"
className={'form-control ' + styles.insertBox}
onClick={clicker}
ref={inputRef}
onChange={e => {
this.onTextChange(e, colName);
}}
value={currentValue}
data-test={`typed-input-${i}`}
<Toggler
placeholderProp={'text'}
standardProps={standardInputProps}
/>
</span>
);
} else {
standardInputProps.defaultValue = defaultValue;
typedInput = (
<span>
<input
placeholder={'text'}
type="text"
className={'form-control ' + styles.insertBox}
onClick={clicker}
ref={inputRef}
onChange={e => {
this.onTextChange(e, colName);
}}
value={defaultValue}
data-test={`typed-input-${i}`}
<Toggler
placeholderProp={'text'}
standardProps={standardInputProps}
/>
</span>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { insertItem, I_RESET } from './InsertActions';
import { ordinalColSort } from '../utils';
import { setTable } from '../DataActions';
import Button from '../../Layout/Button/Button';
import Toggler from '../../../Common/Toggler/Toggler';

class InsertItem extends Component {
constructor() {
Expand Down Expand Up @@ -150,6 +151,15 @@ class InsertItem extends Component {
);
}

if (colType === 'text') {
typedInput = (
<Toggler
standardProps={standardInputProps}
placeholderProp={getPlaceholder(colType)}
/>
);
}

if (colType === 'json' || colType === 'jsonb') {
// JSON/JSONB
typedInput = (
Expand Down