-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add capabilities display feature (#1313)
- Introduce capability matrix component to display capabilities in a structured table format - Add `showCapabilities` method to handle displaying the capabilities modal - Update `OtherOrganizations.vue` to include capabilities button and functionality - Import `CapabilityMatrix.vue` in `OtherOrganizations.vue` to manage component data and actions This enhancement allows users to view organization capabilities in a modal with improved readability.
- Loading branch information
Showing
2 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<template> | ||
<div class="p-4"> | ||
<div class="overflow-x-auto"> | ||
<table class="min-w-full bg-white border border-gray-200"> | ||
<thead> | ||
<tr> | ||
<th class="px-4 py-2 border"></th> | ||
<th | ||
v-for="phase in phases" | ||
:key="phase.id" | ||
class="px-4 py-2 border text-left" | ||
> | ||
{{ $t(phase.phase_name_t) }} | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr | ||
v-for="cap in capabilities" | ||
:key="cap.capability_id" | ||
class="hover:bg-gray-100" | ||
> | ||
<td class="px-4 py-2 border font-medium"> | ||
{{ $t(cap.capability_name) }} | ||
</td> | ||
<td | ||
v-for="phase in phases" | ||
:key="phase.id" | ||
class="px-4 py-2 border text-center" | ||
> | ||
<span | ||
v-if="matrix[phase.id]?.includes(cap.capability_id)" | ||
class="text-green-500" | ||
> | ||
✓ | ||
</span> | ||
<span v-else class="text-red-500">✗</span> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import { computed, defineProps } from 'vue'; | ||
// Define the structure of the incoming rawData prop | ||
const props = defineProps({ | ||
rawData: { | ||
type: Array, | ||
required: true, | ||
default: () => [], | ||
}, | ||
}); | ||
const store = useStore(); | ||
// Extract unique phases from rawData | ||
const phases = computed(() => store.getters['enums/phases']); | ||
// Extract unique capabilities from rawData | ||
const capabilities = computed(() => { | ||
const capMap = new Map(); | ||
for (const item of props.rawData) { | ||
if (!capMap.has(item.capability_id)) { | ||
capMap.set(item.capability_id, { | ||
capability_id: item.capability_id, | ||
capability_name: item.capability_name, | ||
}); | ||
} | ||
} | ||
return [...capMap.values()].sort((a, b) => a.capability_id - b.capability_id); | ||
}); | ||
// Create the matrix mapping phases to their capabilities | ||
const matrix = computed(() => { | ||
const mat = {}; | ||
for (const item of props.rawData) { | ||
if (!mat[item.phase_id]) { | ||
mat[item.phase_id] = new Set(); | ||
} | ||
mat[item.phase_id].add(item.capability_id); | ||
} | ||
// Convert Sets to Arrays for easier handling in the template | ||
for (const key of Object.keys(mat)) { | ||
mat[key] = [...mat[key]]; | ||
} | ||
return mat; | ||
}); | ||
// Utility function to format names for better readability | ||
const formatName = (name) => { | ||
return name | ||
.split('.') | ||
.map((word) => word.charAt(0).toUpperCase() + word.slice(1)) | ||
.join(' '); | ||
}; | ||
</script> | ||
|
||
<style scoped> | ||
/* Optional: Add any additional styles if needed */ | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters