Skip to content

Commit

Permalink
Extract string constants
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls committed Mar 8, 2024
1 parent 8c51261 commit 8a01d36
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
6 changes: 4 additions & 2 deletions arches/app/src/components/ControlledListManager/AddLabel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { useGettext } from "vue3-gettext";
import EditLabel from "@/components/ControlledListManager/EditLabel.vue";
import { ALT_LABEL, PREF_LABEL } from "@/components/ControlledListManager/const.ts";
import type {
ControlledListItem,
Label,
Expand Down Expand Up @@ -35,9 +37,9 @@ const newLabel: NewLabel = computed(() => {
const buttonLabel = computed(() => {
switch (props.type) {
case "prefLabel":
case PREF_LABEL:
return $gettext("Add Preferred Label");
case "altLabel":
case ALT_LABEL:
return $gettext("Add Alternate Label");
default:
throw new Error();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useGettext } from "vue3-gettext";
import ItemCharacteristic from "@/components/ControlledListManager/ItemCharacteristic.vue";
import LabelEditor from "@/components/ControlledListManager/LabelEditor.vue";
import { ALT_LABEL, PREF_LABEL, URI } from "@/components/ControlledListManager/const.ts";
import { bestLabel } from "@/components/ControlledListManager/utils.ts";
import type { Language } from "@/types/arches";
Expand Down Expand Up @@ -61,11 +62,11 @@ const iconLabel = (item: ControlledListItem) => {
</span>
<LabelEditor
:item
type="prefLabel"
type="PREF_LABEL"
/>
<LabelEditor
:item
type="altLabel"
type="ALT_LABEL"
/>
<LabelEditor
:item
Expand Down
10 changes: 6 additions & 4 deletions arches/app/src/components/ControlledListManager/LabelEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { deleteLabel } from "@/components/ControlledListManager/api.ts";
import AddLabel from "@/components/ControlledListManager/AddLabel.vue";
import LabelRow from "@/components/ControlledListManager/LabelRow.vue";
import { ALT_LABEL, PREF_LABEL, URI } from "@/components/ControlledListManager/const.ts";
import type {
ControlledListItem,
Label,
Expand All @@ -30,21 +32,21 @@ const slateBlue = "#2d3c4b"; // todo: import from theme somewhere
const headings: { heading: string; subheading: string } = computed(() => {
switch (props.type) {
case "prefLabel":
case PREF_LABEL:
return {
heading: $gettext("Preferred Label(s)"),
subheading: $gettext(
"Provide at least one preferred label and language for your list item."
),
};
case "altLabel":
case ALT_LABEL:
return {
heading: $gettext("Alternate Label(s)"),
subheading: $gettext(
"Optionally, you can provide additional label/language labels for your list item. Useful if you want to make searching for labels with synonyms or common misspellings of your preferred label(s) easier."
),
};
case "URI":
case URI:
return {
heading: $gettext("List Item URI"),
subheading: $gettext(
Expand Down Expand Up @@ -84,7 +86,7 @@ const onDelete = async (label: Label) => {
/>
</div>
<AddLabel
v-if="type !== 'URI'"
v-if="type !== URI"
:item
:type="type"
:on-insert
Expand Down
5 changes: 3 additions & 2 deletions arches/app/src/components/ControlledListManager/LabelRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { computed, ref } from "vue";
import { useGettext } from "vue3-gettext";
import EditLabel from "@/components/ControlledListManager/EditLabel.vue";
import { ALT_LABEL, PREF_LABEL } from "@/components/ControlledListManager/const.ts";
import type { Label } from "@/types/ControlledListManager";
Expand All @@ -16,9 +17,9 @@ const modalVisible = ref(false);
const { $gettext } = useGettext();
const header = computed(() => {
switch (props.label.valuetype) {
case "prefLabel":
case PREF_LABEL:
return $gettext("Edit Preferred Label");
case "altLabel":
case ALT_LABEL:
return $gettext("Edit Alternate Label");
default:
throw new Error();
Expand Down
3 changes: 3 additions & 0 deletions arches/app/src/components/ControlledListManager/const.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const PREF_LABEL = "prefLabel";
const ALT_LABEL = "altLabel";
const URI = "URI";

0 comments on commit 8a01d36

Please sign in to comment.