Skip to content

Commit

Permalink
pr feedback #147
Browse files Browse the repository at this point in the history
  • Loading branch information
johnatawnclementawn authored and jacobtylerwalls committed Jan 17, 2025
1 parent 470616f commit e446b17
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 11 deletions.
2 changes: 1 addition & 1 deletion arches_lingo/src/arches_lingo/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const createSchemeLabel = async (
schemeId: string,
appellative_status: AppellativeStatus,
) => {
const response = await fetch(arches.urls.api_scheme_label_create, {
const response = await fetch(arches.urls.api_scheme_label_list_create, {
method: "POST",
headers: {
"X-CSRFTOKEN": getToken(),
Expand Down
30 changes: 28 additions & 2 deletions arches_lingo/src/arches_lingo/components/generic/LabelEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,20 @@ async function save() {
async function getControlledListOptions(
listId: string,
): Promise<ControlledListItem[]> {
const parsed = await fetchControlledListOptions(listId);
let parsed;
try {
parsed = await fetchControlledListOptions(listId);
} catch (error) {
toast.add({
severity: ERROR,
summary: $gettext("Error"),
detail:
error instanceof Error
? error.message
: $gettext("Could not fetch the controlled list options"),
});
return [];
}
const options = parsed.items.map(
(item: ControlledListItemResult): ControlledListItem => ({
list_id: item.list_id,
Expand All @@ -145,7 +158,20 @@ async function getControlledListOptions(
async function getResourceInstanceOptions(
fetchOptions: () => Promise<ResourceInstanceResult[]>,
): Promise<ResourceInstanceReference[]> {
const options = await fetchOptions();
let options;
try {
options = await fetchOptions();
} catch (error) {
toast.add({
severity: ERROR,
summary: $gettext("Error"),
detail:
error instanceof Error
? error.message
: $gettext("Could not fetch the resource instance options"),
});
return [];
}
const results = options.map((option: ResourceInstanceResult) => {
const result: ResourceInstanceReference = {
display_value: option.descriptors[selectedLanguage.value.code].name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function getOptionLabels(item: ControlledListItem): string {
<Select
v-model="val"
v-if:="!props.multiValue"
:show-toggle-all="options?.length"
:show-toggle-all="!!options?.length"
:options
:option-label="getOptionLabels"
option-value="uri"
Expand All @@ -84,7 +84,7 @@ function getOptionLabels(item: ControlledListItem): string {
<MultiSelect
v-if="props.multiValue"
v-model="val"
:show-toggle-all="options?.length"
:show-toggle-all="!!options?.length"
:options
:option-label="getOptionLabels"
option-value="uri"
Expand Down
6 changes: 3 additions & 3 deletions arches_lingo/src/arches_lingo/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export interface Scheme {
top_concepts: Concept[];
}

export interface ControlledListeItemLabelValue {
export interface ControlledListItemLabelValue {
id: string;
valuetype_id: string;
language_id: string;
Expand All @@ -50,7 +50,7 @@ export interface ControlledListItem {
uri: string;
sortorder?: number;
guide?: boolean;
labels: ControlledListeItemLabelValue[];
labels: ControlledListItemLabelValue[];
}

export interface ControlledListItemResult {
Expand All @@ -59,7 +59,7 @@ export interface ControlledListItemResult {
uri: string;
sortorder?: number;
guide?: boolean;
values: ControlledListeItemLabelValue[];
values: ControlledListItemLabelValue[];
}

export interface ResourceInstanceReference {
Expand Down
2 changes: 1 addition & 1 deletion arches_lingo/templates/arches_urls.htm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
api_schemes="{% url 'schemes-list-create' %}"
api_scheme_label='(resourceid)=>{return "{% url "api-scheme-label" "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" %}".replace("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", resourceid)}'
api_scheme_label_tile='(resourceid, tileid)=>{return "{% url "api-scheme-label-tile" "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaab"%}".replace("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", resourceid).replace("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaab", tileid)}'
api_scheme_label_create="{% url 'api-scheme-label-create' %}"
api_scheme_label_list_create="{% url 'api-scheme-label-list-create' %}"
api_scheme_note='(resourceid)=>{return "{% url "api-scheme-note" "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" %}".replace("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", resourceid)}'
api_scheme_note_tile='(resourceid, tileid)=>{return "{% url "api-scheme-note-tile" "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaab" %}".replace("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", resourceid).replace("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaab", tileid)}'
api_scheme_creation='(resourceid)=>{return "{% url "api-scheme-creation" "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" %}".replace("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", resourceid)}'
Expand Down
4 changes: 2 additions & 2 deletions arches_lingo/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@
name="api-scheme-label-tile",
),
path(
"api/scheme/label",
"api/scheme/labels",
SchemeLabelCreateView.as_view(),
name="api-scheme-label-create",
name="api-scheme-label-list-create",
),
path(
"api/scheme/<uuid:pk>/note",
Expand Down

0 comments on commit e446b17

Please sign in to comment.