Skip to content

Commit

Permalink
nit re #10541, remove explicit any
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls committed Apr 25, 2024
1 parent 3b0f66d commit 3676617
Showing 1 changed file with 29 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import {
postItemToServer,
postListToServer,
} from "@/components/ControlledListManager/api.ts";
import type { ControlledList, Selectable } from "@/types/ControlledListManager";
import type {
ControlledList,
ControlledListItem,
Selectable,
} from "@/types/ControlledListManager";
const props: {
item: Selectable;
Expand All @@ -28,7 +32,11 @@ const dirtyFormValue = ref("");
const inputValue = computed({
get() {
return (props.item as any)[props.field];
if (props.field === "uri") {
return (props.item as ControlledListItem)[props.field];
} else {
return (props.item as ControlledList)[props.field];
}
},
set(newVal: string) {
dirtyFormValue.value = newVal;
Expand All @@ -47,16 +55,32 @@ const { $gettext } = useGettext();
const onSave = () => {
editing.value = false;
// eslint-disable-next-line vue/no-mutating-props
(props.item as any)[props.field] = dirtyFormValue.value;
const field = props.field;
if (field === "uri") {
// eslint-disable-next-line vue/no-mutating-props
(props.item as ControlledListItem)[field] = dirtyFormValue.value;
}
if (field === 'name') {
// eslint-disable-next-line vue/no-mutating-props
(props.item as ControlledList)[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 as any)[props.field];
let originalValue;
if (props.field === "uri") {
originalValue = (props.item as ControlledListItem)[props.field];
} else {
originalValue = (props.item as ControlledList)[props.field];
}
dirtyFormValue.value = originalValue;
};
</script>

Expand Down

0 comments on commit 3676617

Please sign in to comment.