Skip to content

Commit

Permalink
Fix create function, #151
Browse files Browse the repository at this point in the history
  • Loading branch information
njkim committed Jan 15, 2025
1 parent e0bbe60 commit 44558c7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
7 changes: 5 additions & 2 deletions arches_lingo/src/arches_lingo/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,16 @@ export const createSchemeRightStatement = async (
tileId: string,
schemeRightStatementValue: SchemeRightStatement,
) => {
const response = await fetch(arches.urls.api_scheme_right_statement_tile_create(schemeId, tileId), {
const response = await fetch(arches.urls.api_scheme_right_statement_tile_create, {
method: "PATCH",
headers: {
"X-CSRFTOKEN": getToken(),
"Content-Type": "application/json",
},
body: JSON.stringify(schemeRightStatementValue),
body: JSON.stringify({
resourceinstance: schemeId,
...schemeRightStatementValue,
}),
});
const parsed = await response.json();
if (!response.ok) throw new Error(parsed.message || response.statusText);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ const emit = defineEmits([OPEN_EDITOR, UPDATED]);
const schemeRight = ref<SchemeRights>();
const schemeRightStatement = ref<SchemeRightStatement[]>();
const schemeRightTileid = ref<string>();
const schemeRightStatementTileid = ref<string>();
const route = useRoute();
const router = useRouter();
const toast = useToast();
Expand Down Expand Up @@ -145,11 +143,11 @@ function onUpdateSchemeRightStatementReferenceDatatype(
node: keyof SchemeRightStatement,
val: ControlledListItem[],
) {
(schemeRightStatement.value[node] as unknown) = val.map((item) => toRaw(item));
(currentSchemeRightStatement.value[node] as unknown) = val.map((item) => toRaw(item));
};
function onUpdateString(node: keyof SchemeRightStatement, val: string) {
(schemeRightStatement.value[node] as unknown) = toRaw(val);
(currentSchemeRightStatement.value[node] as unknown) = toRaw(val);
}
async function saveRights() {
Expand All @@ -168,7 +166,7 @@ async function saveRights() {
} else {
await updateSchemeRights(
route.params.id as string,
props.tileId as string,
schemeRight.value.tileid as string,
schemeRight.value as SchemeRights,
);
}
Expand All @@ -189,8 +187,8 @@ async function saveRightStatement() {
} else {
await updateSchemeRightStatement(
route.params.id as string,
schemeRightTileid.value as string,
schemeRight.value as SchemeRights,
currentSchemeRightStatement.value.tileid as string,
currentSchemeRightStatement.value as SchemeRightStatement,
);
}
emit(UPDATED);
Expand All @@ -214,8 +212,6 @@ async function getSectionValue() {
}
schemeRight.value = schemeInstance?.rights;
schemeRightStatement.value = schemeInstance?.right_statement;
schemeRightTileid.value = schemeRight.value?.tileid;
schemeRightStatementTileid.value = schemeRightStatement.value?.tileid;
actorRdmOptions.value = actorOptions.map((option) => {
const savedSource = schemeRight.value?.right_holder?.find(
(source: ResourceInstanceReference) =>
Expand Down Expand Up @@ -258,7 +254,6 @@ function editStatementValue(tileId: string) {
const currentSchemeRightStatement = schemeRightStatement.value?.find(
(tile) => tile.tileid === tileId,
);
console.log(currentSchemeRightStatement?.tileid);
if (currentSchemeRightStatement && currentSchemeRightStatement?.tileid === tileId) {
console.log("this ran");
Expand Down

0 comments on commit 44558c7

Please sign in to comment.