Skip to content

Commit 4991610

Browse files
committed
- Added groupDropDown Obsidian File
1 parent 2474d75 commit 4991610

File tree

3 files changed

+84
-1
lines changed

3 files changed

+84
-1
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<template>
2+
<RockFormField v-bind="fieldProps" :modelValue="formFieldValue" name="group-drop-down" :disabled="disabled">
3+
<BaseAsyncPicker
4+
v-model="internalValue"
5+
v-bind="standardProps"
6+
:label="label"
7+
:items="groupItems"
8+
:multiple="false"
9+
:disabled="disabled"
10+
showBlankItem
11+
rules=""
12+
:displayStyle="PickerDisplayStyle.Condensed" />
13+
</RockFormField>
14+
</template>
15+
16+
<script setup lang="ts">
17+
import { computed } from "vue";
18+
import { useHttp } from "@Obsidian/Utility/http";
19+
import { PickerDisplayStyle } from "@Obsidian/Enums/Controls/pickerDisplayStyle";
20+
import RockFormField from "./rockFormField.obs";
21+
import BaseAsyncPicker from "./baseAsyncPicker.obs";
22+
import { ListItemBag } from "@Obsidian/ViewModels/Utility/listItemBag";
23+
import { useVModelPassthrough } from "@Obsidian/Utility/component";
24+
import {
25+
useStandardRockFormFieldProps,
26+
useStandardAsyncPickerProps,
27+
standardAsyncPickerProps
28+
} from "@Obsidian/Utility/component";
29+
30+
const props = defineProps({
31+
modelValue: {
32+
type: Object as () => ListItemBag | null,
33+
default: null
34+
},
35+
36+
includeInactive: {
37+
type: Boolean,
38+
default: false
39+
},
40+
41+
disabled: {
42+
type: Boolean,
43+
default: false
44+
},
45+
46+
...standardAsyncPickerProps
47+
});
48+
49+
const emit = defineEmits(["update:modelValue"]);
50+
51+
const http = useHttp();
52+
const fieldProps = useStandardRockFormFieldProps(props);
53+
const standardProps = useStandardAsyncPickerProps(props);
54+
const internalValue = useVModelPassthrough(props, "modelValue", emit);
55+
56+
const formFieldValue = computed(() => internalValue.value);
57+
58+
const groupItems = async (): Promise<ListItemBag[]> => {
59+
const response = await http.get<Array<{ guid: string, name: string, isActive: boolean }>>(
60+
`/api/v2/Controls/GroupList?includeInactive=${props.includeInactive}`
61+
);
62+
63+
if (response.isSuccess && response.data) {
64+
return response.data.map(g => ({
65+
text: `${g.name}${g.isActive === false ? " (Inactive)" : ""}`,
66+
value: g.guid
67+
}));
68+
}
69+
70+
console.error(response.errorMessage ?? "Error loading group list.");
71+
return [];
72+
};
73+
</script>

Rock.JavaScript.Obsidian/Framework/Utility/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"composite": true,
55
"module": "ESNext"
66
},
7-
"include": [ "./*.ts" ],
7+
"include": [ "./*.ts", "../ViewModels/Utility/listGroupsOptionsBag.ts" ],
88
"references": [
99
{ "path": "../Enums" },
1010
{ "path": "../Libs" }
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export type ListGroupsOptionsBag = {
2+
/** Gets or sets the category for this item. */
3+
guid?: string | null;
4+
5+
/** Gets or sets disabled for this item. */
6+
name?: string | null;
7+
8+
/** Gets or sets the text. */
9+
isactive?: boolean | null;
10+
};

0 commit comments

Comments
 (0)