Skip to content

Commit 1603be9

Browse files
sadakchapmtrezza
andauthored
Edit Array of pointers (#1771)
* show pill pointer design for array of pointers * ctrl+c copy array of pointer value * encoding data to avoid conversion of object to ParseObjects * updated changelog.md * Update CHANGELOG.md Co-authored-by: Manuel <[email protected]>
1 parent a1463b5 commit 1603be9

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- fix: date cell value not selected on double clicks (fn-faisal) [#1730](https://github.com/parse-community/parse-dashboard/pull/1730)
1212

1313
## Fixes
14+
- Fixed bug when editing or copying a field containing an array of pointers [#1770](https://github.com/parse-community/parse-dashboard/issues/1770) (Prerna Mehra) [#1771](https://github.com/parse-community/parse-dashboard/pull/1771)
1415

1516
# 2.2.0
1617
[Full Changelog](https://github.com/parse-community/parse-dashboard/compare/2.1.0...2.2.0)

src/components/BrowserCell/BrowserCell.react.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -273,13 +273,18 @@ export default class BrowserCell extends Component {
273273
const object = new Parse.Object(v.className);
274274
object.id = v.objectId;
275275
array.push(
276-
<a key={i} href='javascript:;' onClick={onPointerClick.bind(undefined, object)}>
277-
<Pill value={v.objectId} />
278-
</a>);
276+
<Pill
277+
key={v.objectId}
278+
value={v.objectId}
279+
onClick={onPointerClick.bind(undefined, object)}
280+
followClick={true}
281+
/>
282+
);
279283
});
280-
this.copyableValue = content = <ul>
284+
content = <ul>
281285
{ array.map( a => <li>{a}</li>) }
282286
</ul>
287+
this.copyableValue = JSON.stringify(value);
283288
if ( array.length > 1 ) {
284289
classes.push(styles.hasMore);
285290
}

src/dashboard/Data/Browser/EditRowDialog.react.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import FileEditor from 'components/FileEditor/FileEditor.react';
1515
import ObjectPickerDialog from 'dashboard/Data/Browser/ObjectPickerDialog.react';
1616
import styles from 'dashboard/Data/Browser/Browser.scss';
1717
import getFileName from 'lib/getFileName';
18+
import encode from 'parse/lib/browser/encode';
1819

1920
export default class EditRowDialog extends React.Component {
2021
constructor(props) {
@@ -57,7 +58,12 @@ export default class EditRowDialog extends React.Component {
5758
columns.forEach(column => {
5859
const { name, type } = column;
5960
if (['Array', 'Object'].indexOf(type) >= 0) {
60-
const stringifyValue = JSON.stringify(currentObject[name], null, 4);
61+
// This is needed to avoid unwanted conversions of objects to Parse.Objects.
62+
// "Parse._encoding" is responsible to convert Parse data into raw data.
63+
// Since array and object are generic types, we want to render them the way
64+
// they were stored in the database.
65+
let val = encode(currentObject[name], undefined, true);
66+
const stringifyValue = JSON.stringify(val, null, 4);
6167
currentObject[name] = stringifyValue;
6268
const rows = stringifyValue ? stringifyValue.split('\n').length : 1;
6369
expandedTextAreas[name] = { rows: rows, expanded: false };

0 commit comments

Comments
 (0)