Skip to content

Commit ca838d0

Browse files
committed
feat: added history for roles
1 parent a816a44 commit ca838d0

File tree

12 files changed

+115
-10
lines changed

12 files changed

+115
-10
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<button mat-stroked-button [color]="color" (click)="open()">
2-
<ng-content></ng-content>
3-
</button>
1+
<div role="button" class="action-inset" (click)="open()">
2+
<mat-icon>{{icon}}</mat-icon> <ng-content></ng-content>
3+
</div>

client/projects/cms/src/app/elements/link/link.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class LinkComponent {
1919
link: string;
2020

2121
@Input()
22-
color: ThemePalette;
22+
icon = 'arrow_forward';
2323

2424
open() {
2525
this.router.navigateByUrl(this.link);

client/projects/cms/src/app/modules/dashboard/modules/module-instance/guards/can-read-module/can-read-module.guard.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class CanReadModuleGuard implements CanActivate {
3434
*/
3535
const permission = documentParams % 2 ? 'list' : 'get';
3636

37-
if (!this.state.permissions[module.id]?.[permission]) {
37+
if (!this.state.permissions[route.params.module]?.[permission]) {
3838
this.router.navigate(STATIC_CONFIG.dashboardRoute);
3939
return false;
4040
}

client/projects/cms/src/assets/i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@
221221
"TOGGLE_ALL": "Toggle All",
222222

223223
"USER_HISTORY": "User History",
224+
"ROLE_HISTORY": "Role History",
224225
"PERMISSIONS": "Permissions",
225226
"CREATE": "Create",
226227
"UPDATE": "Update",

client/projects/cms/src/assets/i18n/hr.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@
221221
"TOGGLE_ALL": "Osposobi sve",
222222

223223
"USER_HISTORY": "Korinikova povijest",
224+
"ROLE_HISTORY": "Uloge povijest",
224225
"PERMISSIONS": "Dozvole",
225226
"CREATE": "Kreiraj",
226227
"UPDATE": "Uredi",

definitions/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,9 @@ export {JSX} from './jsx.compiler';
4747
import {PROCESSED} from './modules/emails/processed.const';
4848

4949
export const EMAIL_LAYOUT = PROCESSED.layout;
50-
export const EMAIL_STYLE = PROCESSED.css;
50+
export const EMAIL_STYLE = PROCESSED.css;
51+
52+
/**
53+
* Scripts
54+
*/
55+
export {compileRules} from './rules';

definitions/interfaces/collections.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,12 @@ export class Collections {
2323
static UserHistorySub(docId: string) {
2424
return Collections.HistorySub('users', docId);
2525
}
26+
27+
static get RoleHistory() {
28+
return Collections.HistorySub('roles');
29+
}
30+
31+
static RoleHistorySub(docId: string) {
32+
return Collections.HistorySub('roles', docId);
33+
}
2634
}

definitions/modules/modules.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {USERS_MODULE} from './users.module';
55
import {STORAGE_MODULE} from './storage.module';
66
import {AUTOMATIC_EMAILS_MODULE} from './emails/automatic-emails.module';
77
import {SENT_EMAILS_MODULE} from './emails/sent-emails.module';
8+
import {ROLE_HISTORY_MODULE} from './role-history.module';
89

910
/**
1011
* Schemas for all of the modules
@@ -14,6 +15,7 @@ export const MODULES = [
1415
ROLES_MODULE,
1516
USER_INVITES_MODULE,
1617
USER_HISTORY_MODULE,
18+
ROLE_HISTORY_MODULE,
1719
STORAGE_MODULE,
1820

1921
AUTOMATIC_EMAILS_MODULE,
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import {PipeType} from '../enums/pipe-type.enum';
2+
import {Collections} from '../interfaces/collections';
3+
import {Module} from '../interfaces/module.interface';
4+
import {CREATED_ON} from './shared/created-on';
5+
6+
export const ROLE_HISTORY_MODULE: Module = {
7+
id: Collections.RoleHistory,
8+
name: 'ROLE_HISTORY',
9+
layout: {
10+
sort: CREATED_ON.sort,
11+
filterModule: {
12+
schema: {
13+
properties: {
14+
type: {type: 'string'}
15+
}
16+
},
17+
definitions: {
18+
type: {
19+
component: {
20+
type: 'select',
21+
configuration: {
22+
dataSet: [
23+
{name: 'CREATE', value: 'create'},
24+
{name: 'EDIT', value: 'edit'},
25+
{name: 'DELETE', value: 'delete'}
26+
]
27+
}
28+
}
29+
}
30+
},
31+
clearFilters: {}
32+
},
33+
table: {
34+
hideAdd: true,
35+
hideImport: true,
36+
hideDelete: true,
37+
hideCheckbox: true,
38+
hideEdit: true,
39+
tableColumns: [
40+
CREATED_ON.column(),
41+
{key: '/type', label: 'TYPE', pipe: [PipeType.Titlecase]},
42+
{
43+
key: '/before',
44+
label: 'BEFORE',
45+
pipe: [PipeType.Json, PipeType.Custom, PipeType.Sanitize],
46+
pipeArguments: {
47+
1: (item) => {
48+
return `<pre style="background-color: #f2f2f2; padding: 5px; border-radius: 4px;">${item}</pre>`
49+
}
50+
}
51+
},
52+
{
53+
key: '/after',
54+
label: 'AFTER',
55+
pipe: [PipeType.Json, PipeType.Custom, PipeType.Sanitize],
56+
pipeArguments: {
57+
1: (item) => {
58+
return `<pre style="background-color: #f2f2f2; padding: 5px; border-radius: 4px;">${item}</pre>`
59+
}
60+
}
61+
},
62+
]
63+
}
64+
},
65+
schema: {
66+
properties: {
67+
id: {type: 'string'},
68+
before: {type: 'object'},
69+
after: {type: 'object'},
70+
type: {type: 'string'},
71+
...CREATED_ON.property
72+
}
73+
}
74+
};
Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
import {Collections} from '../interfaces/collections';
22
import {Module} from '../interfaces/module.interface';
3+
import JSX from '../jsx.compiler';
34
import {CREATED_ON} from './shared/created-on';
45

56
export const ROLES_MODULE: Module = {
67
id: Collections.Roles,
78
name: 'ROLES',
89
layout: {
910
editTitleKey: 'name',
10-
sort: CREATED_ON.sort,
11+
sort: {
12+
active: 'name',
13+
direction: 'desc'
14+
},
1115
instance: {
16+
actions: [
17+
{
18+
value: it => JSX(<jms-e-link icon="history" link={'/m/roles/' + it.id + '/history'}>History</jms-e-link>)
19+
}
20+
],
1221
segments: [
1322
{
1423
title: 'GENERAL',
@@ -60,5 +69,11 @@ export const ROLES_MODULE: Module = {
6069
}
6170
},
6271
...CREATED_ON.definition()
72+
},
73+
metadata: {
74+
history: true,
75+
subCollections: [
76+
{name: Collections.History}
77+
]
6378
}
6479
};

0 commit comments

Comments
 (0)