-
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
Merged
aarongundel
merged 6 commits into
adg/146-genericize-label-viewer
from
adg/notes-section
Jan 2, 2025
Merged
adds notes section #162
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ebcca5f
adds notes section
aarongundel 29205d2
Merge branch 'adg/146-genericize-label-viewer' into adg/notes-section
aarongundel a6ed334
fix naming nit
aarongundel ae93122
wrap gettext in spans
aarongundel 753e43e
pr feedback
aarongundel d7d1c55
pr feedback
aarongundel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
156 changes: 146 additions & 10 deletions
156
arches_lingo/src/arches_lingo/components/scheme/report/SchemeNote.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,156 @@ | ||
<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 }"> | ||
<span>{{ | ||
(rowData as SchemeStatement).statement_content_n1 | ||
}}</span> | ||
</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> | ||
<ResourceInstanceRelationships | ||
:value=" | ||
(rowData as SchemeStatement) | ||
.statement_data_assignment_object_used | ||
" | ||
/> | ||
</div> | ||
<div> | ||
<span>{{ $gettext("Contributors:") }}</span> | ||
<ResourceInstanceRelationships | ||
:value=" | ||
(rowData as SchemeStatement) | ||
.statement_data_assignment_actor | ||
" | ||
/> | ||
</div> | ||
</template> | ||
</MetaStringViewer> | ||
</SchemeReportSection> | ||
</div> | ||
<div v-if="mode === EDIT"></div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
lol bad formatting but I wont block 😉
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.
That was actually automatic from the pre-commit hook, I didn't do that.
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 figured that was the case 😁