Skip to content

Commit

Permalink
feat: create user group model table component
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed-Hacene committed Mar 5, 2024
1 parent f3d265f commit aa9a8b8
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 25 deletions.
22 changes: 0 additions & 22 deletions backend/iam/migrations/0002_auto_20240305_1351.py

This file was deleted.

28 changes: 28 additions & 0 deletions backend/iam/migrations/0002_purge_validator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 5.0.2 on 2024-03-05 13:51

from django.db import migrations

def purge_validator(apps, schema_editor):
"""
Purge the validator role since it has been replaced by approver.
"""
UserGroup = apps.get_model("iam", "UserGroup")
validator_user_group = UserGroup.objects.filter(name="BI-UG-GVA")
if validator_user_group.exists():
validator_user_group.delete()
Role = apps.get_model("iam", "Role")
validator_role = Role.objects.filter(name="BI-RL-VAL")
if validator_role.exists():
validator_role.delete()



class Migration(migrations.Migration):

dependencies = [
('iam', '0001_initial'),
]

operations = [
migrations.RunPython(purge_validator),
]
2 changes: 0 additions & 2 deletions frontend/src/lib/components/ModelTable/ModelTable.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,6 @@
{/if}
{:else if value && value.hexcolor}
<p class="flex w-fit min-w-24 justify-center px-2 py-1 rounded-md ml-2 whitespace-nowrap" style="background-color: {value.hexcolor}">{value.name ?? value.str ?? '-'}</p>
<!-- {:else if value && value.role}
{value.folder} - {localItems(languageTag())[toCamelCase(value.role)]} -->
{:else if ISO_8601_REGEX.test(value)}
{new Date(value).toLocaleString(languageTag())}
{:else}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<script lang="ts">
import { localItems, toCamelCase } from "$lib/utils/locales";
import { languageTag } from "$paraglide/runtime";
export let cell: { folder: string; role: string };
export const meta: any = undefined;
</script>

<span>{cell.folder} - {localItems(languageTag())[toCamelCase(cell.role)]}</span>
4 changes: 4 additions & 0 deletions frontend/src/lib/utils/crud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { BASE_API_URL } from './constants';
import EvidenceFilePreview from '$lib/components/ModelTable/EvidenceFilePreview.svelte';
import LanguageDisplay from '$lib/components/ModelTable/LanguageDisplay.svelte';
import LibraryActions from '$lib/components/ModelTable/LibraryActions.svelte';
import UserGroupNameDisplay from '$lib/components/ModelTable/UserGroupNameDisplay.svelte';

type GetOptionsParams = {
objects: any[];
Expand Down Expand Up @@ -366,6 +367,9 @@ export const FIELD_COMPONENT_MAP = {
libraries: {
locale: LanguageDisplay,
actions: LibraryActions
},
'user-groups': {
'localization_dict': UserGroupNameDisplay
}
};

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/utils/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const listViewFields = {
},
'user-groups': {
head: ['name'],
body: ['name'],
body: ['localization_dict'],
meta: ['id', 'builtin']
},
roles: {
Expand Down

0 comments on commit aa9a8b8

Please sign in to comment.