Skip to content

Commit

Permalink
fixup! nit re #10541, improve names
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls committed Feb 21, 2024
1 parent 4d838cc commit 93f7d13
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import {
postItemToServer,
postListToServer,
} from "@/components/ControlledListManager/api.ts";
import type { Item } from "@/types/ControlledListManager";
import type { ControlledList, Selectable } from "@/types/ControlledListManager";
const props: {
item: Item;
item: Selectable;
editable: boolean;
field: "name" | "uri";
field: "name" | "dynamic" | "uri";
label: string;
} = defineProps(["item", "editable", "field", "label"]);
Expand All @@ -28,7 +28,7 @@ const dirtyFormValue = ref("");
const inputValue = computed({
get() {
return props.item[props.field];
return (props.item as any)[props.field];
},
set(newVal: string) {
dirtyFormValue.value = newVal;
Expand All @@ -39,7 +39,7 @@ const width = computed(() => {
if (props.field === "uri") {
return "100%";
}
return Math.max((props.item[props.field]).length + 2, 4) + "rem";
return '12rem'; // todo: change in next iteration
});
const toast = useToast();
Expand All @@ -48,15 +48,15 @@ const { $gettext } = useGettext();
const onSave = () => {
editing.value = false;
// eslint-disable-next-line vue/no-mutating-props
props.item[props.field] = dirtyFormValue.value;
(props.item as any)[props.field] = dirtyFormValue.value;
const isList = Object.hasOwn(props.item, "items");
const saveFn = isList ? postListToServer : postItemToServer;
saveFn(props.item, toast, $gettext);
};
const onCancel = () => {
editing.value = false;
dirtyFormValue.value = props.item[props.field];
dirtyFormValue.value = (props.item as any)[props.field];
};
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ import type { Ref } from "vue";
import type {
ControlledList,
ControlledListItem,
Selectable,
Selectables,
} from "@/types/ControlledListManager";
type Selectable = ControlledList | ControlledListItem;
type Selectables = ControlledList[] | ControlledListItem[];
const lightGray = "#f4f4f4";
const slateBlue = "#2d3c4b";
const { $gettext } = useGettext();
Expand Down
3 changes: 3 additions & 0 deletions arches/app/src/types/controlledListManager.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ export type ControlledList = {
dynamic: boolean,
items: ControlledListItem[],
};

export type Selectable = ControlledList | ControlledListItem;
export type Selectables = ControlledList[] | ControlledListItem[];

0 comments on commit 93f7d13

Please sign in to comment.