Skip to content

Commit

Permalink
FP-2716 + FP-2711
Browse files Browse the repository at this point in the history
- [FP-2716](https://movai.atlassian.net/browse/FP-2716): Annotations imported cannot be edited
- [FP-2711](https://movai.atlassian.net/browse/FP-2711): Corrupted data in Annotation
  • Loading branch information
Paulo Andre Azevedo Quirino committed Aug 20, 2024
1 parent 66dd32d commit b932edc
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 20 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# v1.2.5

- [FP-2716](https://movai.atlassian.net/browse/FP-2716): Annotations imported cannot be edited
- [FP-2711](https://movai.atlassian.net/browse/FP-2711): Corrupted data in Annotation
- [FP-2879](https://movai.atlassian.net/browse/FP-2879): Closing last tab keeps bookmarks
- [FP-2882](https://movai.atlassian.net/browse/FP-2882): Clicking in the bar under the documents loses context, not easy to get back

Expand Down
12 changes: 10 additions & 2 deletions src/editors/_shared/hooks/DataTypes/AbstractDataType.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,21 @@ class AbstractDataType {
*/
stringEditComponent(props, placeholder, parsedValue) {
const value = parsedValue !== undefined ? parsedValue : props.rowData.value;
const wasObject = typeof value === "object";
return (
<TextField
inputProps={{ "data-testid": "input_value" }}
fullWidth
placeholder={placeholder}
value={value || ""}
onChange={evt => props.onChange(evt.target.value)}
defaultValue={(wasObject ? JSON.stringify(value) : value) || ""}
onChange={evt => {
if (!wasObject)
return props.onChange(evt.target.value);

try {
props.onChange(JSON.parse(evt.target.value));
} catch (e) {}
}}
></TextField>
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/editors/_shared/hooks/DataTypes/types/ArrayType.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ArrayType extends DataType {
* @returns
*/
validate(value) {
value = value?.replace(/'/g, '"');
value = typeof value === "string" ? value?.replace(/'/g, '"'): value;
return new Promise(resolve => {
try {
if (checkIfDefaultOrDisabled(value)) {
Expand Down
21 changes: 4 additions & 17 deletions src/editors/_shared/hooks/DataTypes/types/StringType.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import { DATA_TYPES } from "../../../../../utils/Constants";
import DataType from "../AbstractDataType";
import { checkIfDefaultOrDisabled } from "./utils";

class StringType extends DataType {
// String type properties definition
key = DATA_TYPES.STRING;
label = "String";
default = '""';
default = '';

editComponent = (props, mode = "row") => {
// Define editor by mode
const editorByMode = {
row: () => this.stringEditComponent(props, '""'),
row: () => this.stringEditComponent(props, ''),
dialog: () => this.codeEditComponent(props)
};
// Return editor by mode
Expand All @@ -23,20 +22,8 @@ class StringType extends DataType {
* @param {*} value
* @returns
*/
validate(value) {
return new Promise(resolve => {
try {
if (checkIfDefaultOrDisabled(value)) {
return resolve({ success: true, value });
}
const parsed = this.getParsedValue(value);
const isValid =
typeof parsed === DATA_TYPES.STRING || parsed instanceof String;
resolve({ success: isValid });
} catch (e) {
resolve({ success: false, error: "MandatoryStringQuotes" });
}
});
validate(_value) {
return Promise.resolve({ success: true });
}
}

Expand Down

0 comments on commit b932edc

Please sign in to comment.