Skip to content

Commit aaef2aa

Browse files
committed
chore: Make UID field readonly in inetorgperson.ui.yml
1 parent 83c9a93 commit aaef2aa

File tree

4 files changed

+88
-5
lines changed

4 files changed

+88
-5
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
type: Group
2+
label: Identité
3+
elements:
4+
- type: HorizontalLayout
5+
elements:
6+
- type: Control
7+
label: CN
8+
scope: "#/properties/cn"
9+
options:
10+
required: true
11+
- type: Control
12+
label: Création Nom
13+
scope: "#/properties/sn"
14+
options:
15+
required: true
16+
- type: Control
17+
label: UID
18+
scope: "#/properties/uid"
19+
options:
20+
required: true
21+
- type: HorizontalLayout
22+
elements:
23+
- type: Control
24+
label: Nom d'affichage
25+
scope: "#/properties/displayName"
26+
- type: Control
27+
label: Prénom
28+
scope: "#/properties/givenName"
29+
- type: HorizontalLayout
30+
elements:
31+
- type: Control
32+
label: Employee Number
33+
scope: "#/properties/employeeNumber"
34+
- type: Control
35+
label: Employee Type
36+
scope: "#/properties/employeeType"
37+
options:
38+
suggestion:
39+
- TAIGA
40+
- type: HorizontalLayout
41+
elements:
42+
- type: Control
43+
label: Email
44+
scope: "#/properties/mail"
45+
options:
46+
format: email
47+
- type: Control
48+
label: Mobile
49+
scope: "#/properties/mobile"
50+
- type: Control
51+
label: Adresse postale
52+
scope: "#/properties/postalAddress"
53+
- type: HorizontalLayout
54+
elements:
55+
- type: Control
56+
label: language préféré
57+
scope: "#/properties/preferredLanguage"
58+
options:
59+
required: false
60+
# suggestion:
61+
# - FR
62+
# - EN
63+
# - DE
64+
# - IT
65+
- type: Control
66+
label: Téléphone
67+
scope: "#/properties/telephoneNumber"
68+
- type: Control
69+
label: Titre
70+
scope: "#/properties/title"

src/management/identities/jsonforms/_config/inetorgperson.ui.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ elements:
1313
scope: "#/properties/sn"
1414
options:
1515
required: true
16+
readonly: true
1617
- type: Control
1718
label: UID
1819
scope: "#/properties/uid"

src/management/identities/jsonforms/identities.jsonforms.controller.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Body, Controller, Get, HttpStatus, Param, Post, Res } from '@nestjs/common';
1+
import { Body, Controller, Get, HttpStatus, Param, Post, Query, Res } from '@nestjs/common';
22
import { AbstractController } from '~/_common/abstracts/abstract.controller';
33
import { IdentitiesJsonformsService } from './identities.jsonforms.service';
44
import { Response } from 'express';
@@ -43,8 +43,8 @@ export class IdentitiesJsonFormsController extends AbstractController {
4343

4444
@Get(':schema')
4545
@ApiOperation({ summary: 'Récupère un JSON Forms d\'un schéma personnalisé' })
46-
async search(@Res() res: Response, @Param('schema') schema): Promise<any> {
47-
const result = await this._service.findOne(schema);
46+
async search(@Res() res: Response, @Param('schema') schema, @Query('mode') mode: 'create' | 'update'): Promise<any> {
47+
const result = await this._service.findOne(schema, { mode });
4848
return res.status(HttpStatus.OK).json({
4949
statusCode: HttpStatus.OK,
5050
data: result,

src/management/identities/jsonforms/identities.jsonforms.service.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,24 @@ export class IdentitiesJsonformsService extends AbstractService {
154154
return [result, files.length];
155155
}
156156

157-
async findOne(schema): Promise<any> {
157+
public async findOne(schema, options?: { mode: string }): Promise<any> {
158+
options = {
159+
mode: 'create',
160+
...options,
161+
};
162+
158163
if (schema.endsWith('.yml')) schema = schema.replace('.yml', '');
159-
const filePath = this.resolveJsonFormPath(schema + '.ui');
164+
165+
let filePath = this.resolveJsonFormPath(schema + '.' + options?.mode + '.ui')
166+
167+
if (!filePath) {
168+
filePath = this.resolveJsonFormPath(schema + '.ui');
169+
}
170+
160171
if (!filePath) {
161172
throw new ValidationConfigException({ message: `File not found: ${schema}.ui.yml` });
162173
}
174+
163175
return parse(readFileSync(filePath, 'utf-8'));
164176
}
165177
}

0 commit comments

Comments
 (0)