Skip to content

Commit

Permalink
nit #209
Browse files Browse the repository at this point in the history
  • Loading branch information
chrabyrd committed Feb 20, 2025
1 parent 7fa5d39 commit ca94360
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ const props = withDefaults(
},
);
const route = useRoute();
const { $gettext } = useGettext();
// this is to compensate for the of a Form type in the primevue/forms module
interface FormInstance {
fields: Record<
Expand All @@ -44,6 +41,9 @@ interface FormInstance {
>;
}
const route = useRoute();
const { $gettext } = useGettext();
const formRef = useTemplateRef<FormInstance>("formRef");
const formKey = ref(0);
Expand Down
128 changes: 66 additions & 62 deletions arches_lingo/src/arches_lingo/components/scheme/report/SchemeLabel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -137,75 +137,79 @@ async function update(tileId: string | undefined) {
</script>

<template>
<div v-if="mode === VIEW">
<SchemeReportSection
:title-text="$gettext('Scheme Labels')"
:button-text="$gettext('Add New Scheme Label')"
@open-editor="emit(OPEN_EDITOR)"
>
<MetaStringViewer
:meta-strings="schemeInstance?.appellative_status"
:meta-string-text="metaStringLabel"
@edit-string="editSectionValue"
@delete-string="deleteSectionValue"
<template v-if="schemeInstance">
<div v-if="mode === VIEW">
<SchemeReportSection
:title-text="$gettext('Scheme Labels')"
:button-text="$gettext('Add New Scheme Label')"
@open-editor="emit(OPEN_EDITOR)"
>
<template #name="{ rowData }">
<span>
{{
(rowData as AppellativeStatus)
.appellative_status_ascribed_name_content
}}
</span>
</template>
<template #type="{ rowData }">
<ReferenceDatatype
:value="
(rowData as AppellativeStatus)
.appellative_status_ascribed_relation
"
:mode="VIEW"
>
</ReferenceDatatype>
</template>
<template #language="{ rowData }">
<ReferenceDatatype
:value="
(rowData as AppellativeStatus)
.appellative_status_ascribed_name_language
"
:mode="VIEW"
>
</ReferenceDatatype>
</template>
<template #drawer="{ rowData }">
<div>
<span>{{ $gettext("Bibliographic Sources:") }}</span>
<ResourceInstanceRelationships
<MetaStringViewer
:meta-strings="schemeInstance?.appellative_status"
:meta-string-text="metaStringLabel"
@edit-string="editSectionValue"
@delete-string="deleteSectionValue"
>
<template #name="{ rowData }">
<span>
{{
(rowData as AppellativeStatus)
.appellative_status_ascribed_name_content
}}
</span>
</template>
<template #type="{ rowData }">
<ReferenceDatatype
:value="
(rowData as AppellativeStatus)
.appellative_status_data_assignment_object_used
.appellative_status_ascribed_relation
"
></ResourceInstanceRelationships>
</div>
<div>
<span>{{ $gettext("Contributors:") }}</span>
<ResourceInstanceRelationships
:mode="VIEW"
>
</ReferenceDatatype>
</template>
<template #language="{ rowData }">
<ReferenceDatatype
:value="
(rowData as AppellativeStatus)
.appellative_status_data_assignment_actor
.appellative_status_ascribed_name_language
"
></ResourceInstanceRelationships>
</div>
</template>
</MetaStringViewer>
</SchemeReportSection>
</div>
<div v-if="mode === EDIT">
<LabelEditor
:value="appellativeStatusToEdit"
@update="update"
/>
</div>
:mode="VIEW"
>
</ReferenceDatatype>
</template>
<template #drawer="{ rowData }">
<div>
<span>{{
$gettext("Bibliographic Sources:")
}}</span>
<ResourceInstanceRelationships
:value="
(rowData as AppellativeStatus)
.appellative_status_data_assignment_object_used
"
></ResourceInstanceRelationships>
</div>
<div>
<span>{{ $gettext("Contributors:") }}</span>
<ResourceInstanceRelationships
:value="
(rowData as AppellativeStatus)
.appellative_status_data_assignment_actor
"
></ResourceInstanceRelationships>
</div>
</template>
</MetaStringViewer>
</SchemeReportSection>
</div>
<div v-if="mode === EDIT">
<LabelEditor
:value="appellativeStatusToEdit"
@update="update"
/>
</div>
</template>
</template>
<style scoped>
:deep(.drawer) {
Expand Down
45 changes: 21 additions & 24 deletions arches_lingo/src/arches_lingo/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,36 +101,33 @@ export function treeFromSchemes(
return reshapedSchemes;
}

export function checkDeepEquality(
firstValue: unknown,
secondValue: unknown,
): boolean {
if (firstValue === secondValue) {
return true;
export function checkDeepEquality(value1: unknown, value2: unknown): boolean {
if (typeof value1 !== typeof value2) {
return false;
}

const firstValueIsArray = Array.isArray(firstValue);
const secondValueIsArray = Array.isArray(secondValue);

if (firstValueIsArray !== secondValueIsArray) {
return false;
if (
typeof value1 !== "object" ||
value1 === null ||
typeof value2 !== "object" ||
value2 === null
) {
return value1 === value2;
}

if (firstValueIsArray && secondValueIsArray) {
if (firstValue.length !== secondValue.length) {
return false;
}
return firstValue.every((element, index) =>
checkDeepEquality(element, secondValue[index]),
if (Array.isArray(value1) && Array.isArray(value2)) {
return (
value1.length === value2.length &&
value1.every((item, index) =>
checkDeepEquality(item, value2[index]),
)
);
}

const firstObject = firstValue as Record<string, unknown>;
const secondObject = secondValue as Record<string, unknown>;
const object1 = value1 as Record<string, unknown>;
const object2 = value2 as Record<string, unknown>;

return Object.keys(firstObject).every(
(objectKey) =>
objectKey in secondObject &&
checkDeepEquality(firstObject[objectKey], secondObject[objectKey]),
);
return Object.keys(object1).every((key) => {
return checkDeepEquality(object1[key], object2[key]);
});
}

0 comments on commit ca94360

Please sign in to comment.