|
| 1 | +<!-- Copyright by the Spark Development Network; Licensed under the Rock Community License --> |
| 2 | +<template> |
| 3 | + <Modal v-model="isVisible" |
| 4 | + title="Settings" |
| 5 | + saveText="Save" |
| 6 | + @save="onSave"> |
| 7 | + <SectionHeader title="Filters" /> |
| 8 | + |
| 9 | + <NotificationBox v-if="errorMessage" |
| 10 | + alertType="warning"> |
| 11 | + {{ errorMessage }} |
| 12 | + </NotificationBox> |
| 13 | + |
| 14 | + <div class="row"> |
| 15 | + <div class="col-md-6"> |
| 16 | + <DropDownList v-model="gridSettingsForm.filterProcessed" |
| 17 | + :items="enumToListItemBag(ProcessedDescription)" |
| 18 | + :showBlankItem="false" |
| 19 | + label="Processed" /> |
| 20 | + </div> |
| 21 | + |
| 22 | + <div class="col-md-6"> |
| 23 | + <DropDownList v-model="gridSettingsForm.filterMoveType" |
| 24 | + :items="enumToListItemBag(MoveTypeDescription)" |
| 25 | + label="Move Type" /> |
| 26 | + </div> |
| 27 | + </div> |
| 28 | + |
| 29 | + <div class="row"> |
| 30 | + <div class="col-md-6"> |
| 31 | + <SlidingDateRangePicker v-model="gridSettingsForm.filterMoveDate" |
| 32 | + label="Created Date Range" |
| 33 | + :isRangeClearable="true" /> |
| 34 | + </div> |
| 35 | + |
| 36 | + <div class="col-md-6"> |
| 37 | + <SlidingDateRangePicker v-model="gridSettingsForm.filterNcoaProcessedDate" |
| 38 | + label="NCOA Processed Date Range" |
| 39 | + :isRangeClearable="true" /> |
| 40 | + </div> |
| 41 | + </div> |
| 42 | + |
| 43 | + <div class="row"> |
| 44 | + <div class="col-md-6"> |
| 45 | + <DropDownList v-model="gridSettingsForm.filterAddressStatus" |
| 46 | + :items="enumToListItemBag(AddressStatusDescription)" |
| 47 | + label="Address Status" /> |
| 48 | + </div> |
| 49 | + |
| 50 | + <div class="col-md-6"> |
| 51 | + <DropDownList v-model="gridSettingsForm.filterInvalidReason" |
| 52 | + :items="enumToListItemBag(AddressInvalidReasonDescription)" |
| 53 | + label="Invalid Reason" /> |
| 54 | + </div> |
| 55 | + </div> |
| 56 | + <div class="row"> |
| 57 | + <div class="col-md-4"> |
| 58 | + <NumberBox v-model="gridSettingsForm.filterMoveDistance" |
| 59 | + label="Move Distance" /> |
| 60 | + </div> |
| 61 | + |
| 62 | + <div class="col-md-4"> |
| 63 | + <TextBox v-model="gridSettingsForm.filterLastName" |
| 64 | + label="Last Name" /> |
| 65 | + </div> |
| 66 | + <div class="col-md-4"> |
| 67 | + <CampusPicker v-model="gridSettingsForm.filterCampus" |
| 68 | + :forceVisible="true" |
| 69 | + :includeInactive="true" |
| 70 | + :showBlankItem="true" |
| 71 | + label="Campus" /> |
| 72 | + </div> |
| 73 | + </div> |
| 74 | + </Modal> |
| 75 | +</template> |
| 76 | + |
| 77 | +<script setup lang="ts"> |
| 78 | + import Modal from "@Obsidian/Controls/modal.obs"; |
| 79 | + import DropDownList from "@Obsidian/Controls/dropDownList.obs"; |
| 80 | + import SectionHeader from "@Obsidian/Controls/sectionHeader.obs"; |
| 81 | + import NotificationBox from "@Obsidian/Controls/notificationBox.obs"; |
| 82 | + import SlidingDateRangePicker from "@Obsidian/Controls/slidingDateRangePicker.obs"; |
| 83 | + import { ref, PropType, watch } from "vue"; |
| 84 | + import { GridSettingsOptions } from "./types.partial"; |
| 85 | + import { useVModelPassthrough } from "@Obsidian/Utility/component"; |
| 86 | + import { deepEqual } from "@Obsidian/Utility/util"; |
| 87 | + import { ListItemBag } from "@Obsidian/ViewModels/Utility/listItemBag"; |
| 88 | + import { clone } from "@Obsidian/Utility/objectUtils"; |
| 89 | + import TextBox from "@Obsidian/Controls/textBox.obs"; |
| 90 | + import NumberBox from "@Obsidian/Controls/numberBox.obs"; |
| 91 | + import CampusPicker from "@Obsidian/Controls/campusPicker.obs"; |
| 92 | + import { MoveTypeDescription } from "@Obsidian/Enums/Core/moveType"; |
| 93 | + import { ProcessedDescription } from "@Obsidian/Enums/Core/processed"; |
| 94 | + import { AddressStatusDescription } from "@Obsidian/Enums/Core/addressStatus"; |
| 95 | + import { AddressInvalidReasonDescription } from "@Obsidian/Enums/Core/addressInvalidReason"; |
| 96 | + import { enumToListItemBag } from "@Obsidian/Utility/enumUtils"; |
| 97 | + |
| 98 | + const props = defineProps({ |
| 99 | + modelValue: { |
| 100 | + type: Object as PropType<GridSettingsOptions>, |
| 101 | + required: true |
| 102 | + }, |
| 103 | + |
| 104 | + visible: { |
| 105 | + type: Boolean as PropType<boolean>, |
| 106 | + required: true |
| 107 | + }, |
| 108 | + |
| 109 | + currentPerson: { |
| 110 | + type: Object as PropType<ListItemBag>, |
| 111 | + required: false, |
| 112 | + } |
| 113 | + }); |
| 114 | + |
| 115 | + const emit = defineEmits<{ |
| 116 | + (e: "update:modelValue", value: GridSettingsOptions): void; |
| 117 | + (e: "update:visible", value: boolean): void; |
| 118 | + (e: "close"): void; |
| 119 | + }>(); |
| 120 | + |
| 121 | + const errorMessage = ref(); |
| 122 | + const gridSettingsForm = ref(clone(props.modelValue)); |
| 123 | + |
| 124 | + const isVisible = useVModelPassthrough(props, "visible", emit); |
| 125 | + |
| 126 | + function onSave(): void { |
| 127 | + |
| 128 | + if (!deepEqual(gridSettingsForm.value, props.modelValue, true)) { |
| 129 | + emit("update:modelValue", clone(gridSettingsForm.value)); |
| 130 | + } |
| 131 | + |
| 132 | + isVisible.value = false; |
| 133 | + } |
| 134 | + |
| 135 | + // watch(() => props.modelValue, () => { |
| 136 | + // createdBy.value = props.modelValue.createdBy?.value ?? "Selected Person"; |
| 137 | + // filterPerson.value = props.modelValue.filterPerson; |
| 138 | + // createdDateRange.value = props.modelValue.createdDateRange ?? defaultCreatedDateRange; |
| 139 | + // }); |
| 140 | + |
| 141 | + // watch(filterPerson, () => { |
| 142 | + // if (!filterPerson.value) { |
| 143 | + // createdBy.value = "Not Specified"; |
| 144 | + // } |
| 145 | + // }); |
| 146 | + |
| 147 | + // watch(createdBy, () => { |
| 148 | + // if (createdBy.value === "Not Specified") { |
| 149 | + // filterPerson.value = undefined; |
| 150 | + // } |
| 151 | + // else if (createdBy.value === "Selected Person" && !filterPerson.value) { |
| 152 | + // filterPerson.value = props.currentPerson; |
| 153 | + // } |
| 154 | + // }); |
| 155 | + |
| 156 | + // watch(createdDateRange, () => { |
| 157 | + // if (!isNullOrWhiteSpace(errorMessage.value)) { |
| 158 | + // const dates = calculateSlidingDateRange(createdDateRange.value); |
| 159 | + |
| 160 | + // if (dates.start && dates.end) { |
| 161 | + // errorMessage.value = ""; |
| 162 | + // } |
| 163 | + // } |
| 164 | + // }); |
| 165 | + |
| 166 | + watch(isVisible, () => { |
| 167 | + errorMessage.value = ""; |
| 168 | + if (!isVisible.value) { |
| 169 | + emit("close"); |
| 170 | + } |
| 171 | + }); |
| 172 | +</script> |
0 commit comments