Skip to content

Commit

Permalink
[#464] Fix js
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmursa-dev committed Dec 31, 2024
1 parent 787abf0 commit a1348bf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/objects/js/components/admin/permissions/auth-fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ const authFields = (object_fields, dataFields, fields, setFields) => {
};

const versionAuthFields = (objectType, objectFields, dataFieldChoices, fields, setFields) => {
if (!(objectType in dataFieldChoices)) {
return (
<div className="errornote">
<p>To be able to select fields, first you must save the instance and then you can edit the fields!</p>
<p>Click on button <strong>'Save and continue editing'</strong></p>
</div>
);
}

const dataFields = dataFieldChoices[objectType];
const objecttypeVersions = Object.entries(dataFieldChoices).reduce((acc, [k, v]) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ const PermissionForm = ({objectFields, dataFieldChoices, tokenChoices, objecttyp
const [mode, setMode] = useState(values["mode"]);
const [useFields, setUseFields] = useState(values["use_fields"]);
const [objectType, setObjectType] = useState(values["object_type"]);

const [fields, setFields] = useState( JSON.parse(values["fields"]) || {});
if (!values["fields"]) {
values["fields"] = "{}"
}
const [fields, setFields] = useState( JSON.parse(values["fields"]) || {})

return (
<fieldset className="module aligned">
Expand Down Expand Up @@ -63,7 +65,7 @@ const PermissionForm = ({objectFields, dataFieldChoices, tokenChoices, objecttyp
name="use_fields"
id="id_use_fields"
label="Use field-based authorization"
disabled={mode === "read_and_write" || Object.keys(dataFieldChoices).length === 0}
disabled={!mode || mode === "read_and_write"}
value={useFields}
onChange={(value) => {setUseFields(value)}}
/>
Expand Down

0 comments on commit a1348bf

Please sign in to comment.