From 098849d80583010e3ba5deb3bebcf75f1183ceb7 Mon Sep 17 00:00:00 2001 From: Jarlem Red de Peralta Date: Thu, 24 Nov 2022 19:24:30 +0800 Subject: [PATCH] intrn(page): remove redundant data --- pages/role/read.page.vue | 25 ++++++++----------------- pages/tag/read.page.vue | 11 ++++------- 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/pages/role/read.page.vue b/pages/role/read.page.vue index 6c83a4a9f..127b2a1b9 100644 --- a/pages/role/read.page.vue +++ b/pages/role/read.page.vue @@ -88,7 +88,7 @@ const pageContext = inject("pageContext") as PageContext<"deserialized", Require const { pageProps } = pageContext const { userProfile } = pageProps -const roles = ref( +const role = ref( { ...pageProps.role, "data": { @@ -97,13 +97,6 @@ const roles = ref( } as DeserializedRoleDocument ) -const managementInfo = computed( - () => makeManagementInfo(userProfile, roles.value.data) -) - -const role = ref>( - pageProps.role as DeserializedRoleDocument<"read"> -) const receivedErrors = ref([]) const successMessages = ref([]) @@ -121,17 +114,13 @@ const roleData = computed>({ } } }) -const isDeleted = computed(() => managementInfo.value.isDeleted) -const password = ref("") -const flagSelectors = makeFlagSelectorInfos(roleData) +const managementInfo = computed( + () => makeManagementInfo(userProfile, role.value.data) +) const mayUpdateRole = computed(() => managementInfo.value.mayUpdateRole) - -const mayArchiveOrRestoreRole = computed( - () => managementInfo.value.mayArchiveRole || managementInfo.value.mayRestoreRole) - -const mayArchiveRole = computed(() => !isDeleted.value && mayArchiveOrRestoreRole.value) -const mayRestoreRole = computed(() => isDeleted.value && mayArchiveOrRestoreRole.value) +const mayArchiveRole = computed(() => managementInfo.value.mayArchiveRole) +const mayRestoreRole = computed(() => managementInfo.value.mayRestoreRole) const { "state": isBeingConfirmed, @@ -140,11 +129,13 @@ const { } = makeSwitch(false) const nameFieldStatus = ref(mayUpdateRole.value ? "enabled" : "disabled") +const flagSelectors = makeFlagSelectorInfos(roleData) const areFlagSelectorsDisabled = computed(() => !mayUpdateRole.value) const hasSubmittedRole = ref(true) const fetcher: Fetcher = new Fetcher() +const password = ref("") async function updateRole() { hasSubmittedRole.value = false await fetcher.update(role.value.data.id, { diff --git a/pages/tag/read.page.vue b/pages/tag/read.page.vue index 4b972769f..8ea59f030 100644 --- a/pages/tag/read.page.vue +++ b/pages/tag/read.page.vue @@ -76,10 +76,7 @@ const pageContext = inject("pageContext") as PageContext<"deserialized", "tag"> const { pageProps } = pageContext const { userProfile } = pageProps -const tag = ref>( - pageProps.tag as DeserializedTagDocument<"read"> -) -const tags = ref( +const tag = ref( { ...pageProps.tag, "data": { @@ -89,7 +86,7 @@ const tags = ref( ) const managementInfo = computed( - () => makeManagementInfo(userProfile, tags.value.data) + () => makeManagementInfo(userProfile, tag.value.data) ) const mayArchiveTag = computed(() => managementInfo.value.mayArchiveTag) const mayRestoreTag = computed(() => managementInfo.value.mayRestoreTag) @@ -138,7 +135,7 @@ function updateTag() { async function archiveTag() { await fetcher.archive([ tag.value.data.id ]) .then(() => { - if (!tags.value.data.deletedAt) tags.value.data.deletedAt = new Date() + if (!tag.value.data.deletedAt) tag.value.data.deletedAt = new Date() fillSuccessMessages( receivedErrors, @@ -153,7 +150,7 @@ async function archiveTag() { async function restoreTag() { await fetcher.restore([ tag.value.data.id ]) .then(() => { - if (tags.value.data.deletedAt) tags.value.data.deletedAt = null + if (tag.value.data.deletedAt) tag.value.data.deletedAt = null fillSuccessMessages( receivedErrors,