-
Notifications
You must be signed in to change notification settings - Fork 20
Vue Composition API: Suggested Script Structure
Mike Lyttle edited this page May 18, 2023
·
2 revisions
import { computed, onMounted, ref, watch } from "vue";
import { useStore } from "vue-composition-wrapper";
library.add(faEllipsisV, faDownload, faInfoCircle);
interface Props {
dependent: Dependent;
}
const props = defineProps<Props>();
const emit = defineEmits<{
(e: "needs-update"): void;
}>();
defineExpose({ generateReport });
interface Covid19LaboratoryOrderRow {
date: string;
test_type: string;
test_location: string;
result: string;
}
const homeBreadcrumbItem: BreadcrumbItem = {
text: "Home",
to: "/home",
dataTestId: "breadcrumb-home",
};
const logger = container.get<ILogger>(SERVICE_IDENTIFIER.Logger);
const reportService = container.get<IReportService>(
SERVICE_IDENTIFIER.ReportService
);
const store = useStore();
const isLoading = ref(false);
const laboratoryOrders = ref<LaboratoryOrder[]>([]);
const idleModal = ref<InstanceType<typeof IdleComponent>>();
const isMobile = computed<boolean>(() => store.getters["isMobile"]);
const user = computed<User>(() => store.getters["user/user"]);
const isResourceCentreVisible = computed(() =>
currentPathMatches(dependentsPath, reportsPath, timelinePath)
);
const isVaccineRecordDownloading = computed(
() => vaccineRecordState.value.status === LoadStatus.REQUESTED
);
function setTooManyRequestsError(key: string): void {
store.dispatch("errorBanner/setTooManyRequestsError", { key });
}
function formatDate(date: StringISODate): string {
return DateWrapper.format(date);
}
function initializeResizeListener(): void {
window.addEventListener("resize", onResize);
onResize();
}
watch(isEmpty, () => {
emit("on-is-empty-changed", isEmpty.value);
});
onMounted(async () => {
windowWidth.value = window.innerWidth;
await nextTick();
initializeResizeListener();
initializeIdleDetector();
initialized.value = true;
});
retrieveCovid19LaboratoryOrders(props.hdid).catch((err) =>
logger.error(`Error loading Covid19 data: ${err}`)
);
-
Developer Standard and Processes
-
Workstation Setup
-
IDE Configuration
-
Application Config
-
RedHat SSO Authorization Server
-
Known Issues