Skip to content

Commit 80d42a8

Browse files
committed
Update BrowserCell.react.js
1 parent 8fe3e7f commit 80d42a8

File tree

1 file changed

+60
-5
lines changed

1 file changed

+60
-5
lines changed

src/components/BrowserCell/BrowserCell.react.js

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,11 @@ export default class BrowserCell extends Component {
204204

205205
render() {
206206
let { type, value, hidden, width, current, onSelect, onEditChange, setCopyableValue, setRelation, onPointerClick, row, col, field, onEditSelectedRow } = this.props;
207-
let content = value;
207+
let content = value,
208+
contentArray = []
208209
this.copyableValue = content;
209210
let classes = [styles.cell, unselectable];
210-
if (hidden) {
211+
if (hidden) {
211212
content = '(hidden)';
212213
classes.push(styles.empty);
213214
} else if (value === undefined) {
@@ -246,7 +247,59 @@ export default class BrowserCell extends Component {
246247
this.copyableValue = content = dateStringUTC(value);
247248
} else if (type === 'Boolean') {
248249
this.copyableValue = content = value ? 'True' : 'False';
249-
} else if (type === 'Object' || type === 'Bytes' || type === 'Array') {
250+
} else if (type === 'Array') {
251+
252+
253+
this.copyableValue = '';
254+
contentArray.push('[');
255+
for (var i=0;i<value.length;i++) {
256+
let val = value[i];
257+
if (val === null) {
258+
this.copyableValue += content = '(undefined)';
259+
classes.push(styles.empty);
260+
} if (val === '') {
261+
contentArray.push(<span>&nbsp;</span>);
262+
classes.push(styles.empty);
263+
} else if (val && val.__type === 'Pointer') {
264+
const object = new Parse.Object(val.className);
265+
object.id = val.objectId;
266+
value[i] = object;
267+
val = object;
268+
contentArray.push(onPointerClick ? (
269+
<a href='javascript:;' onClick={onPointerClick.bind(undefined, val)}>
270+
<Pill value={val.id} />
271+
</a>
272+
) : (
273+
val.id
274+
))
275+
this.copyableValue += val.id;
276+
} else if (val && val.__type === 'Date' || new Date(val)) {
277+
if (typeof val === 'object' && val.__type) {
278+
value[i] = new Date(val.iso);
279+
val = value[i];
280+
} else if (typeof val === 'string' && new Date(val)) {
281+
value[i] = new Date(val);
282+
val = value[i];
283+
}
284+
this.copyableValue += dateStringUTC(val);
285+
} else if (val && val.__type === 'File') {
286+
const fileName = val._url ? getFileName(val) : 'Uploading\u2026';
287+
contentArray.push(<Pill value={fileName} />);
288+
this.copyableValue += fileName;
289+
} else if (type === 'Boolean') {
290+
this.copyableValue += val;
291+
} else {
292+
contentArray.push(JSON.stringify(val));
293+
this.copyableValue += JSON.stringify(val);
294+
}
295+
if (i+1 != value.length) {
296+
contentArray.push(',');
297+
}
298+
}
299+
contentArray.push(']');
300+
301+
302+
} else if (type === 'Object' || type === 'Bytes') {
250303
this.copyableValue = content = JSON.stringify(value);
251304
} else if (type === 'File') {
252305
const fileName = value.url() ? getFileName(value) : 'Uploading\u2026';
@@ -287,7 +340,9 @@ export default class BrowserCell extends Component {
287340
);
288341
this.copyableValue = undefined;
289342
}
290-
343+
if (contentArray.length == 0) {
344+
contentArray = [content];
345+
}
291346
if (current) {
292347
classes.push(styles.current);
293348
}
@@ -319,7 +374,7 @@ export default class BrowserCell extends Component {
319374
}}
320375
onContextMenu={this.onContextMenu.bind(this)}
321376
>
322-
{content}
377+
{contentArray.map((val,index) => <div style={{ display: 'inline-block'}} key={index + val}> {val} </div>)}
323378
</span>
324379
);
325380
}

0 commit comments

Comments
 (0)