Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
intrn(page): remove redundant data
Browse files Browse the repository at this point in the history
  • Loading branch information
lemredd committed Nov 24, 2022
1 parent 9a66804 commit 098849d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 24 deletions.
25 changes: 8 additions & 17 deletions pages/role/read.page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const pageContext = inject("pageContext") as PageContext<"deserialized", Require
const { pageProps } = pageContext
const { userProfile } = pageProps
const roles = ref<DeserializedRoleDocument>(
const role = ref<DeserializedRoleDocument>(
{
...pageProps.role,
"data": {
Expand All @@ -97,13 +97,6 @@ const roles = ref<DeserializedRoleDocument>(
} as DeserializedRoleDocument
)
const managementInfo = computed<RoleManagementInfo>(
() => makeManagementInfo(userProfile, roles.value.data)
)
const role = ref<DeserializedRoleDocument<"read">>(
pageProps.role as DeserializedRoleDocument<"read">
)
const receivedErrors = ref<string[]>([])
const successMessages = ref<string[]>([])
Expand All @@ -121,17 +114,13 @@ const roleData = computed<RoleAttributes<"deserialized">>({
}
}
})
const isDeleted = computed<boolean>(() => managementInfo.value.isDeleted)
const password = ref<string>("")
const flagSelectors = makeFlagSelectorInfos(roleData)
const managementInfo = computed<RoleManagementInfo>(
() => makeManagementInfo(userProfile, role.value.data)
)
const mayUpdateRole = computed<boolean>(() => managementInfo.value.mayUpdateRole)
const mayArchiveOrRestoreRole = computed<boolean>(
() => managementInfo.value.mayArchiveRole || managementInfo.value.mayRestoreRole)
const mayArchiveRole = computed<boolean>(() => !isDeleted.value && mayArchiveOrRestoreRole.value)
const mayRestoreRole = computed<boolean>(() => isDeleted.value && mayArchiveOrRestoreRole.value)
const mayArchiveRole = computed<boolean>(() => managementInfo.value.mayArchiveRole)
const mayRestoreRole = computed<boolean>(() => managementInfo.value.mayRestoreRole)
const {
"state": isBeingConfirmed,
Expand All @@ -140,11 +129,13 @@ const {
} = makeSwitch(false)
const nameFieldStatus = ref<FieldStatus>(mayUpdateRole.value ? "enabled" : "disabled")
const flagSelectors = makeFlagSelectorInfos(roleData)
const areFlagSelectorsDisabled = computed<boolean>(() => !mayUpdateRole.value)
const hasSubmittedRole = ref<boolean>(true)
const fetcher: Fetcher = new Fetcher()
const password = ref<string>("")
async function updateRole() {
hasSubmittedRole.value = false
await fetcher.update(role.value.data.id, {
Expand Down
11 changes: 4 additions & 7 deletions pages/tag/read.page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ const pageContext = inject("pageContext") as PageContext<"deserialized", "tag">
const { pageProps } = pageContext
const { userProfile } = pageProps
const tag = ref<DeserializedTagDocument<"read">>(
pageProps.tag as DeserializedTagDocument<"read">
)
const tags = ref<DeserializedTagDocument>(
const tag = ref<DeserializedTagDocument>(
{
...pageProps.tag,
"data": {
Expand All @@ -89,7 +86,7 @@ const tags = ref<DeserializedTagDocument>(
)
const managementInfo = computed<TagManagementInfo>(
() => makeManagementInfo(userProfile, tags.value.data)
() => makeManagementInfo(userProfile, tag.value.data)
)
const mayArchiveTag = computed<boolean>(() => managementInfo.value.mayArchiveTag)
const mayRestoreTag = computed<boolean>(() => managementInfo.value.mayRestoreTag)
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 098849d

Please sign in to comment.