diff --git a/arches_lingo/serializers.py b/arches_lingo/serializers.py
index 126520d7..5a07aed7 100644
--- a/arches_lingo/serializers.py
+++ b/arches_lingo/serializers.py
@@ -4,7 +4,7 @@
from arches.app.models.models import ResourceInstance, TileModel
from arches.app.models.serializers import ArchesModelSerializer, ArchesTileSerializer
-from arches_controlled_lists.datatypes.datatypes import ReferenceDataType
+from arches_controlled_lists.datatypes.datatypes import Reference, ReferenceDataType
from arches_controlled_lists.models import ListItem
@@ -12,7 +12,7 @@
class LingoResourceSerializer(ArchesModelSerializer):
class Meta:
model = ResourceInstance
- graph_slug = None # generic
+ graph_slug = None
nodegroups = "__all__"
fields = "__all__"
@@ -26,12 +26,13 @@ class Meta:
def validate_appellative_status(self, data):
if data:
- # TODO: consider having serializer run to_python().
- if new_label_languages := ReferenceDataType().to_python(
+ new_label_lang = None
+ new_label_type = None
+ if new_label_languages := self.get_reference_object(
data.get("appellative_status_ascribed_name_language")
):
new_label_lang = new_label_languages[0]
- if new_label_types := ReferenceDataType().to_python(
+ if new_label_types := self.get_reference_object(
data.get("appellative_status_ascribed_relation")
):
new_label_type = new_label_types[0]
@@ -41,6 +42,14 @@ def validate_appellative_status(self, data):
return data
+ @staticmethod
+ def get_reference_object(data) -> Reference:
+ # TODO: serializer should just do this itself, only waiting to tackle:
+ # https://github.com/archesproject/arches/issues/10851#issuecomment-2427305853
+ datatype_instance = ReferenceDataType()
+ transformed = datatype_instance.transform_value_for_tile(data)
+ return datatype_instance.to_python(transformed)
+
@staticmethod
def _check_pref_label_uniqueness(data, new_label_language, new_label_type):
try:
diff --git a/arches_lingo/src/arches_lingo/components/generic/reference-datatype/ReferenceDatatypeViewer.vue b/arches_lingo/src/arches_lingo/components/generic/reference-datatype/ReferenceDatatypeViewer.vue
index a863750f..72711868 100644
--- a/arches_lingo/src/arches_lingo/components/generic/reference-datatype/ReferenceDatatypeViewer.vue
+++ b/arches_lingo/src/arches_lingo/components/generic/reference-datatype/ReferenceDatatypeViewer.vue
@@ -14,13 +14,13 @@ withDefaults(
- {{ val.labels[0].value }}
+ {{ val.display_value }}
- {{ (value as ControlledListItem).labels[0].value }}
+ {{ value.display_value }}
{{ $gettext("None") }}
diff --git a/arches_lingo/src/arches_lingo/types.ts b/arches_lingo/src/arches_lingo/types.ts
index b16c1ae8..62cdef23 100644
--- a/arches_lingo/src/arches_lingo/types.ts
+++ b/arches_lingo/src/arches_lingo/types.ts
@@ -51,12 +51,8 @@ export interface ControlledListItemLabelValue {
}
export interface ControlledListItem {
- item_id?: string;
- list_id: string;
- uri: string;
- sortorder?: number;
- guide?: boolean;
- labels: ControlledListItemLabelValue[];
+ list_item_id: string;
+ display_value: string;
}
export interface ControlledListItemResult {