Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement delete facility functionality to moderation panel #917

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
aafcee6
feat: add update button to topbar
NabbeunNabi Nov 18, 2024
455654e
feat: add text for language to update button
NabbeunNabi Nov 18, 2024
2aea4d0
chore: add missing keys for update button on topbar
NabbeunNabi Nov 18, 2024
1dd1f06
feat: change updateFacility function to use updated api call
NabbeunNabi Nov 18, 2024
0e91a28
feat: change update to fit backend with relationship ref array
NabbeunNabi Nov 18, 2024
96750fa
feat: implement frontend filter as fake fuzzy search
NabbeunNabi Nov 18, 2024
e581a43
feat: add key for update and exit in topbar
NabbeunNabi Nov 18, 2024
dc13f7a
chore: run script to add update and exit keys to locales
NabbeunNabi Nov 18, 2024
ba25739
feat: add functionality with checks for updating facility
NabbeunNabi Nov 19, 2024
06d02a1
chore: update color of trash can to red
NabbeunNabi Nov 19, 2024
8fb87de
feat: implement view of existing healthcare relationships
NabbeunNabi Nov 19, 2024
447ab85
feat: implement healthcare professional card
NabbeunNabi Nov 20, 2024
b110119
feat: add key for added healthcare professional
NabbeunNabi Nov 20, 2024
7e6dbff
feat: implement relations for removal of HP from facility
NabbeunNabi Nov 20, 2024
f24ad9e
chore: run script to add keys to tagalog
NabbeunNabi Nov 22, 2024
e614abd
feat: add watch to remove healthcare professional in ui
NabbeunNabi Nov 22, 2024
76fc55a
feat: add gray to our theme colors
NabbeunNabi Nov 22, 2024
7a49fcb
style: update styling of healthcare professional card
NabbeunNabi Nov 22, 2024
18d83fe
feat: update facilities store delete functionality
NabbeunNabi Nov 25, 2024
1181ce2
feat: add functionality to delete facility
NabbeunNabi Nov 25, 2024
5718a9c
chore: run script to add missing keys in locale files
NabbeunNabi Nov 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions assets/css/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
--color-primary-hover: /* #D66051 */ 214 97 81;
--color-secondary-inverted: /* #FFFFFF */ 255 255 255;
--color-secondary-hover: /* #D66051 */ 214 97 81;
--color-primary-gray: /* #CBD5E1 */ 203 213 225;
/* element specific colors */
--color-text-base: /* #130402 */ 18 4 2;
--color-text-muted: /* #999999 */ 153 153 153;
Expand All @@ -55,6 +56,7 @@
--color-primary-hover: /* #d66051 */ 214 96 81;
--color-secondary-inverted: /* #ffffff */ 255 255 255;
--color-secondary-hover: /* #d66051 */ 214 96 81;
--color-primary-gray: /* #CBD5E1 */ 203 213 225;
/* element specific colors */
--color-text-base: /* #252525 */ 37 37 37;
--color-text-muted: /* #999999 */ 153 153 153;
Expand All @@ -74,6 +76,7 @@
--color-primary-hover: /* #c46fb8 */ 196 111 184;
--color-secondary-inverted: /* #ffffff */ 255 255 255;
--color-secondary-hover: /* #d66051 */ 214 96 81;
--color-primary-gray: /* #CBD5E1 */ 203 213 225;
/* element specific colors */
--color-text-base: /* #252525 */ 37 37 37;
--color-text-muted: /* #464646 */ 70 70 70;
Expand All @@ -93,6 +96,7 @@
--color-primary-hover: /* #007ccf */ 0 124 207;
--color-secondary-inverted: /* #ffffff */ 255 255 255;
--color-secondary-hover: /* #d66051 */ 214 96 81;
--color-primary-gray: /* #CBD5E1 */ 203 213 225;
/* element specific colors */
--color-text-base: /* #252525 */ 37 37 37;
--color-text-muted: /* #464646 */ 70 70 70;
Expand All @@ -112,6 +116,7 @@
--color-primary-hover: /* #1abb85 */ 26 187 133;
--color-secondary-inverted: /* #ffffff */ 255 255 255;
--color-secondary-hover: /* #d66051 */ 214 96 81;
--color-primary-gray: /* #CBD5E1 */ 203 213 225;
/* element specific colors */
--color-text-base: /* #88eecc */ 136 238 204;
--color-text-muted: /* #71c5a9 */ 113 197 169;
Expand Down
4 changes: 2 additions & 2 deletions assets/icons/trash-can.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions assets/icons/undo-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
137 changes: 137 additions & 0 deletions components/ModDashboardHealthProfessionalCard.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<template>
<div class="w-96 my-1">
<div
class="flex justify-between items-center rounded-lg p-1 border-2 border-primary"
>
<div class="w-16 self-start">
<SVGProfileIcon
role="img"
alt="profile icon"
title="profile icon"
class="profile-icon stroke-primary w-16 h-16 stroke-1 inline mx-1 self-start"
/>
</div>
<div v-if="moderationScreenStore.activeScreen === ModerationScreen.EditFacility">
<div class="flex flex-col h-full w-64 pl-1 mb-1">
<div class="flex font-bold pt-2">
<span>{{ healthcareProfessional.names[0].lastName }}</span>
<span class="mx-2">{{ healthcareProfessional.names[0].firstName }}</span>
<span v-show="healthcareProfessional.names[0].middleName">
{{ healthcareProfessional.names[0].middleName }}
</span>
</div>
<span>
ID: {{ healthcareProfessional.id }}
</span>
<div>
<div
class="flex flex-wrap justify-start items-start self-end pt-2"
>
<div
v-for="(spokenLanguage, indexOfLocale)
in healthcareProfessional.spokenLanguages"
:key="`${spokenLanguage}-${indexOfLocale}`"
class="w-24 px-2 py-[1px] mr-1 mb-1 bg-primary-bg-gray text-nowrap rounded-full
text-sm text-center"
>
<span>
{{ localeStore.formatLanguageCodeToSimpleText(
spokenLanguage) }}
</span>
</div>
</div>
</div>
</div>
</div>
<div v-if="moderationScreenStore.activeScreen === ModerationScreen.EditSubmission">
<div
v-for="(nameLocale, index) in healthcareProfessional.names"
:key="`${nameLocale.firstName}-${nameLocale.lastName}-${index}`"
>
<div class="flex font-bold pt-2">
<span>{{ nameLocale.lastName }}</span>
<span class="mx-2">{{ nameLocale.firstName }}</span>
<span v-show="nameLocale.middleName">
{{ nameLocale.middleName }}
</span>
</div>
<span
class="w-24 px-2 py-[1px] mr-1 mb-1 bg-primary-text-muted text-nowrap rounded-full
text-sm text-center"
>
{{ localeStore.formatLanguageCodeToSimpleText(
nameLocale.locale) }}
</span>
</div>
</div>
<div
v-if="!isHealthcareProfessionalReadyForRemoval(healthcareProfessional.id)"
class="flex w-8 items-center justify-center
cursor-pointer font-bold text-secondary text-sm self-start p-1"
@click="() => removeHealthcareProfessional(healthcareProfessional.id)"
>
<SVGTrashCan
class="flex items-center justify-center w-6 h-6"
/>
</div>
<div
v-if="isHealthcareProfessionalReadyForRemoval(healthcareProfessional.id)"
class="flex w-8 items-center justify-center
cursor-pointer font-bold text-secondary text-sm self-start p-1"
@click="() => undoRemovalOfHealthcareProfessional(healthcareProfessional.id)"
>
<SVGUndoIcon
class="flex items-center justify-center w-6 h-6"
/>
</div>
</div>
</div>
</template>

<script setup lang="ts">
import SVGTrashCan from '~/assets/icons/trash-can.svg'
import SVGProfileIcon from '~/assets/icons/profile-icon.svg'
import SVGUndoIcon from '~/assets/icons/undo-icon.svg'
import { useLocaleStore } from '~/stores/localeStore'
import { useFacilitiesStore } from '~/stores/facilitiesStore'
import { ModerationScreen, useModerationScreenStore } from '~/stores/moderationScreenStore'
import { RelationshipAction, type HealthcareProfessional, type Relationship } from '~/typedefs/gqlTypes'

const localeStore = useLocaleStore()
const facilitiesStore = useFacilitiesStore()
const moderationScreenStore = useModerationScreenStore()

// This checks whether an existing healthcare professional has been added for removal
const isHealthcareProfessionalReadyForRemoval = (id: string) =>
facilitiesStore.facilitySectionFields.healthProfessionalsRelations
.find(healthcareProfessionalRelation => healthcareProfessionalRelation.otherEntityId === id
&& healthcareProfessionalRelation.action === RelationshipAction.Delete)

const removeHealthcareProfessional = (id: string) => {
switch (moderationScreenStore.activeScreen) {
case ModerationScreen.EditFacility:
if (props.healthcareProfessionalsRelatedToFacility && props.healthcareProfessionalsRelatedToFacility.includes(id)) {
facilitiesStore.facilitySectionFields.healthProfessionalsRelations
.push({ otherEntityId: id, action: RelationshipAction.Delete })
return
}
facilitiesStore.facilitySectionFields.healthProfessionalsRelations
= facilitiesStore.facilitySectionFields.healthProfessionalsRelations
.filter((healthcareProfessionalRelation: Relationship) => healthcareProfessionalRelation.otherEntityId !== id)
facilitiesStore.healthProfessionalsRelationsForDisplay
= facilitiesStore.healthProfessionalsRelationsForDisplay
.filter(healthcareProfessional => healthcareProfessional.id !== id)
}
}

const undoRemovalOfHealthcareProfessional = (id: string) => {
facilitiesStore.facilitySectionFields.healthProfessionalsRelations
= facilitiesStore.facilitySectionFields.healthProfessionalsRelations
.filter((healthcareProfessionalRelation: Relationship) => healthcareProfessionalRelation.otherEntityId !== id)
}

const props = defineProps<{
healthcareProfessional: HealthcareProfessional
healthcareProfessionalsRelatedToFacility?: string[]
}>()
</script>
Loading
Loading