-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adds notes section #162
adds notes section #162
Changes from 4 commits
ebcca5f
29205d2
a6ed334
ae93122
753e43e
d7d1c55
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,154 @@ | ||
<script setup lang="ts"> | ||
import { onMounted, ref } from "vue"; | ||
import { useGettext } from "vue3-gettext"; | ||
import { useRoute } from "vue-router"; | ||
import { useToast } from "primevue/usetoast"; | ||
import MetaStringViewer from "@/arches_lingo/components/generic/MetaStringViewer.vue"; | ||
import SchemeReportSection from "@/arches_lingo/components/scheme/report/SchemeSection.vue"; | ||
import { deleteSchemeNoteTile, fetchSchemeNotes } from "@/arches_lingo/api.ts"; | ||
import { ERROR, OPEN_EDITOR, VIEW, EDIT } from "@/arches_lingo/constants.ts"; | ||
import type { | ||
DataComponentMode, | ||
MetaStringText, | ||
SchemeInstance, | ||
SchemeStatement, | ||
} from "@/arches_lingo/types.ts"; | ||
import ResourceInstanceRelationships from "@/arches_lingo/components/generic/ResourceInstanceRelationships.vue"; | ||
import ControlledListItem from "@/arches_lingo/components/generic/ControlledListItem.vue"; | ||
|
||
const save = () => { | ||
console.log("save"); | ||
}; | ||
const getSectionValue = async () => { | ||
console.log("update"); | ||
const { $gettext } = useGettext(); | ||
const schemeInstance = ref<SchemeInstance>(); | ||
const route = useRoute(); | ||
const toast = useToast(); | ||
const metaStringLabel: MetaStringText = { | ||
deleteConfirm: $gettext("Are you sure you want to delete this note?"), | ||
language: $gettext("Note Language"), | ||
name: $gettext("Note Name"), | ||
type: $gettext("Note Type"), | ||
}; | ||
|
||
defineExpose({ save, getSectionValue }); | ||
const { $gettext } = useGettext(); | ||
withDefaults( | ||
defineProps<{ | ||
mode?: DataComponentMode; | ||
tileId?: string | null; | ||
}>(), | ||
{ | ||
mode: VIEW, | ||
tileId: null, // editor arg specifying what tile to operate on. | ||
}, | ||
); | ||
|
||
const emits = defineEmits([OPEN_EDITOR]); | ||
|
||
defineExpose({ getSectionValue }); | ||
|
||
onMounted(() => { | ||
getSectionValue(); | ||
}); | ||
|
||
async function getSectionValue() { | ||
try { | ||
const result = await fetchSchemeNotes(route.params.id as string); | ||
schemeInstance.value = { | ||
statement: result.statement, | ||
}; | ||
} catch (error) { | ||
toast.add({ | ||
severity: ERROR, | ||
summary: $gettext("Error"), | ||
detail: | ||
error instanceof Error | ||
? error.message | ||
: $gettext("Could not fetch the notes for the resource"), | ||
}); | ||
} | ||
} | ||
|
||
async function deleteSectionValue(tileId: string) { | ||
let result = false; | ||
try { | ||
result = await deleteSchemeNoteTile(route.params.id as string, tileId); | ||
} catch (error) { | ||
toast.add({ | ||
severity: ERROR, | ||
summary: $gettext("Error"), | ||
detail: | ||
error instanceof Error | ||
? error.message | ||
: $gettext("Could not delete selected note"), | ||
}); | ||
} | ||
|
||
if (result) { | ||
getSectionValue(); | ||
} | ||
} | ||
|
||
function editSectionValue(tileId: string) { | ||
const schemeStatement = schemeInstance.value?.statement?.find( | ||
(tile) => tile.tileid === tileId, | ||
); | ||
if (schemeStatement && schemeStatement.tileid === tileId) { | ||
emits(OPEN_EDITOR, schemeStatement.tileid); | ||
} else { | ||
toast.add({ | ||
severity: ERROR, | ||
summary: $gettext("Error"), | ||
detail: $gettext("Could not find the selected label to edit"), | ||
}); | ||
} | ||
} | ||
</script> | ||
|
||
<template> | ||
<SchemeReportSection :title-text="$gettext('Scheme Notes')"> | ||
abc | ||
</SchemeReportSection> | ||
<div v-if="mode === VIEW"> | ||
<SchemeReportSection | ||
:title-text="$gettext('Scheme Notes')" | ||
@open-editor="emits(OPEN_EDITOR)" | ||
> | ||
<MetaStringViewer | ||
:meta-strings="schemeInstance?.statement" | ||
:meta-string-text="metaStringLabel" | ||
@edit-string="editSectionValue" | ||
@delete-string="deleteSectionValue" | ||
> | ||
<template #name="{ rowData }"> | ||
{{ (rowData as SchemeStatement).statement_content_n1 }} | ||
</template> | ||
<template #type="{ rowData }"> | ||
<ControlledListItem | ||
:value="(rowData as SchemeStatement).statement_type_n1" | ||
/> | ||
</template> | ||
<template #language="{ rowData }"> | ||
<ControlledListItem | ||
:value=" | ||
(rowData as SchemeStatement).statement_language_n1 | ||
" | ||
/> | ||
</template> | ||
<template #drawer="{ rowData }"> | ||
<div> | ||
<span>{{ $gettext("Bibliographic Sources") }}:</span> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. had to look up i18n patterns for this: TIL -- the colon should go inside the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good to know, guess it makes sense from an RTL text perspective. |
||
<ResourceInstanceRelationships | ||
:value=" | ||
(rowData as SchemeStatement) | ||
.statement_data_assignment_object_used | ||
" | ||
/> | ||
</div> | ||
<div> | ||
<span>{{ $gettext("Contributors") }}:</span> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
<ResourceInstanceRelationships | ||
:value=" | ||
(rowData as SchemeStatement) | ||
.statement_data_assignment_actor | ||
" | ||
/> | ||
</div> | ||
</template> | ||
</MetaStringViewer> | ||
</SchemeReportSection> | ||
</div> | ||
<div v-if="mode === EDIT"></div> | ||
</template> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsure, but I think this needs
span
wrapping as wellThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no objections. 🏓