Skip to content

Commit ddf53dd

Browse files
Merge pull request #101 from Sohith-code/cbrelease-4.8.20-custom-registration-sohith
Organization update api added
2 parents d107387 + c228eb7 commit ddf53dd

File tree

5 files changed

+117
-40
lines changed

5 files changed

+117
-40
lines changed

project/ws/app/src/lib/head/ui-admin-table/create-organisation/create-organisation.component.html

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,20 @@
1010
<div class="px-5 pt-6">
1111
<ng-container *ngIf="openMode !== 'createNew'">
1212
<div class="flex items-end gap-6 mb-10">
13-
<ng-container *ngIf="rowData?.logo">
14-
<div class="flex justify-center items-center log-frame">
15-
<img class="log" [src]="rowData?.logo" alt="log">
13+
<div class="flex justify-center items-center log-frame relative rounded">
14+
<input type="file" name="edit-orgLogo" id="edit-orgLogo" class="hidden" (change)="uploadLogo($event)"
15+
accept=".png, .jpeg, .jpg">
16+
<ng-container *ngIf="rowData?.logo">
17+
<img class="log" [src]="selectedLogo" alt="log">
18+
<ng-container *ngIf="!rowData?.logo">
19+
<div class="">Logo</div>
20+
</ng-container>
21+
</ng-container>
22+
<div class="edit-logo" onclick="document.getElementById('edit-orgLogo').click()">
23+
<mat-icon>edit</mat-icon>
1624
</div>
25+
</div>
1726

18-
</ng-container>
1927
<div>
2028
<div class="organisationLable">
2129
Organisation
@@ -39,20 +47,22 @@
3947
</mat-form-field>
4048
</div>
4149

42-
<mat-radio-group aria-labelledby="example-radio-group-label" class="flex gap-12 organisation-form"
43-
formControlName="category">
50+
<ng-container *ngIf="this.openMode !== 'editMode'">
51+
<mat-radio-group aria-labelledby="example-radio-group-label" class="flex gap-12 organisation-form"
52+
formControlName="category">
4453

45-
<div [ngClass]="{'active-radio-button': getCategory === 'state'}">
46-
<mat-radio-button color="primary" value="state">
47-
State
48-
</mat-radio-button>
49-
</div>
50-
<div [ngClass]="{'active-radio-button': getCategory === 'center'}">
51-
<mat-radio-button color="primary" value="center">
52-
Center
53-
</mat-radio-button>
54-
</div>
55-
</mat-radio-group>
54+
<div [ngClass]="{'active-radio-button': getCategory === 'state'}">
55+
<mat-radio-button color="primary" value="state">
56+
State
57+
</mat-radio-button>
58+
</div>
59+
<div [ngClass]="{'active-radio-button': getCategory === 'ministry'}">
60+
<mat-radio-button color="primary" value="ministry">
61+
Center
62+
</mat-radio-button>
63+
</div>
64+
</mat-radio-group>
65+
</ng-container>
5666

5767
<ng-container *ngIf="getCategory === 'state'">
5868
<div class="grayBox p-4 mt-5 flex flex-column gap-1 organisation-form mat-field-rounded">
@@ -63,7 +73,8 @@
6373
<mat-form-field class="w-full">
6474
<input type="text" placeholder="Type to search" aria-label="Type to search" matInput
6575
(input)="filterStates($event.target.value)" formControlName="state" [matAutocomplete]="auto">
66-
<mat-autocomplete #auto="matAutocomplete" [displayWith]="displayFn">
76+
<mat-autocomplete #auto="matAutocomplete" [displayWith]="displayFn"
77+
(optionSelected)="onSelectStateMinistry($event.option.value)">
6778
<ng-container *ngFor="let option of filteredStates">
6879
<mat-option [value]="option">{{ option.orgName }}</mat-option>
6980
</ng-container>
@@ -72,7 +83,7 @@
7283
</mat-form-field>
7384
</div>
7485
</ng-container>
75-
<ng-container *ngIf="getCategory === 'center'">
86+
<ng-container *ngIf="getCategory === 'ministry'">
7687
<div class="grayBox p-4 mt-5 flex flex-column gap-1 organisation-form mat-field-rounded">
7788
<div class="flex items-center gap-1 required">
7889
<span class="lable">Ministry</span>
@@ -81,7 +92,8 @@
8192
<mat-form-field class="w-full">
8293
<input type="text" placeholder="Type to search" aria-label="Type to search" matInput
8394
(input)="filterMinistry($event.target.value)" formControlName="ministry" [matAutocomplete]="auto">
84-
<mat-autocomplete #auto="matAutocomplete" [displayWith]="displayFn">
95+
<mat-autocomplete #auto="matAutocomplete" [displayWith]="displayFn"
96+
(optionSelected)="onSelectStateMinistry($event.option.value)">
8597
<ng-container *ngFor="let option of filteredMinistry">
8698
<mat-option [value]="option">{{ option.orgName }}</mat-option>
8799
</ng-container>
@@ -129,18 +141,18 @@
129141
</ng-container>
130142
<ng-container *ngIf="openMode === 'editMode'">
131143
<div class="flex gap-8 mt-4">
132-
<div class="w-full flex flex-col gap-2">
144+
<!-- <div class="w-full flex flex-col gap-2">
133145
<div class="viewModeLable">Created By</div>
134146
<div class="viewModeValue">{{rowData?.createdBy}}</div>
135-
</div>
147+
</div> -->
136148
<div class="w-full flex flex-col gap-2">
137149
<div class="viewModeLable">Created Date and Time</div>
138150
<div class="viewModeValue">{{rowData?.createdOn}}</div>
139151
</div>
140152
</div>
141153
</ng-container>
142154
<ng-container *ngIf="getCategory">
143-
<div class="flex flex-column gap-1 w-full mt-4">
155+
<div class="flex flex-column gap-1 w-full mt-8">
144156
<div class="flex items-center gap-1 required">
145157
<span class="lable">Description</span>
146158
</div>
@@ -202,7 +214,7 @@
202214
<div class="right-sidenav-footer flex items-center justify-end gap-4 items-center px-5 pt-3 pb-5 bg-white">
203215
<ng-container *ngIf="openMode !== 'viewMode'">
204216
<button mat-button class="cancelButton" (click)="closeNaveBar()">Cancel</button>
205-
<button mat-flat-button class="mat-btn-flat" [disabled]="isLoading || this.organisationForm.valid"
217+
<button mat-flat-button class="mat-btn-flat" [disabled]="isLoading || this.organisationForm.invalid"
206218
(click)="onSubmitCreateOrganization()">{{openMode
207219
=== 'editMode' ? 'Update' : 'Add'}}</button>
208220
</ng-container>

project/ws/app/src/lib/head/ui-admin-table/create-organisation/create-organisation.component.scss

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,18 @@
186186
margin-top: 2px !important;
187187
}
188188
}
189+
190+
.edit-logo {
191+
position: absolute;
192+
top: -8px;
193+
right: -8px;
194+
cursor: pointer;
195+
196+
mat-icon {
197+
font-size: 14px;
198+
height: 14px;
199+
width: 14px;
200+
color: #1b4ca1;
201+
202+
}
203+
}

project/ws/app/src/lib/head/ui-admin-table/create-organisation/create-organisation.component.ts

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class CreateOrganisationComponent implements OnInit, OnDestroy {
3939
isLoading = false
4040
filteredStates: any[] = []
4141
filteredMinistry: any[] = []
42-
42+
heirarchyObject: any
4343
constructor(
4444
private formBuilder: FormBuilder,
4545
private snackBar: MatSnackBar,
@@ -55,13 +55,18 @@ export class CreateOrganisationComponent implements OnInit, OnDestroy {
5555
ngOnInit(): void {
5656
this.loggedInUserId = _.get(this.activatedRoute, 'snapshot.parent.data.configService.userProfile.userId')
5757
this.initialization()
58+
if (this.openMode === 'editMode') {
59+
this.getOrganization(this.rowData.organisation, this.rowData.type.toLowerCase())
60+
}
5861
}
5962

6063
ngOnDestroy(): void {
6164
this.removeOverflowHidden()
6265
}
6366

6467
initialization() {
68+
console.log(this.rowData)
69+
6570
if (this.dropdownList) {
6671
this.statesList = _.get(this.dropdownList, 'statesList', [])
6772
this.filteredStates = [...this.statesList]
@@ -113,7 +118,7 @@ export class CreateOrganisationComponent implements OnInit, OnDestroy {
113118
this.organisationForm.controls.ministry.setValue('')
114119
this.organisationForm.controls.ministry.clearValidators()
115120
this.organisationForm.controls.ministry.updateValueAndValidity()
116-
} else if (val === 'center') {
121+
} else if (val === 'ministry') {
117122
this.organisationForm.controls.ministry.setValidators([Validators.required])
118123
this.organisationForm.controls.ministry.updateValueAndValidity()
119124
this.organisationForm.controls.state.setValue('')
@@ -140,17 +145,17 @@ export class CreateOrganisationComponent implements OnInit, OnDestroy {
140145

141146
onSubmitCreateOrganization() {
142147
const payload = {
143-
"orgName": this.controls['organisationName'].value,
144-
"channel": this.controls['organisationName'].value,
145-
"organisationType": "",
146-
"organisationSubType": "",
147-
"isTenant": true,
148-
"requestedBy": this.loggedInUserId,
149-
150-
"logo": this.selectedLogo,
151-
"description": this.controls['description'].value,
152-
"parentMapId": "",
153-
"sbRootOrgId": "",
148+
orgName: this.controls['organisationName'].value,
149+
channel: this.controls['organisationName'].value,
150+
organisationType: this.heirarchyObject?.sbOrgType || "",
151+
organisationSubType: this.heirarchyObject?.sbOrgSubType || "",
152+
isTenant: true,
153+
requestedBy: this.loggedInUserId,
154+
155+
logo: this.selectedLogo,
156+
description: this.controls['description'].value,
157+
parentMapId: this.heirarchyObject?.parentMapId || "",
158+
sbRootOrgId: this.heirarchyObject?.parentMapId || "",
154159
}
155160

156161
if (this.controls['category'].value === "state") {
@@ -191,11 +196,19 @@ export class CreateOrganisationComponent implements OnInit, OnDestroy {
191196
}
192197
})
193198
}
194-
private updateOrganization(payload: any): void {
199+
private updateOrganization(request: any): void {
195200
this.loaderService.changeLoad.next(true)
196201
this.isLoading = true
202+
const payload = {
203+
orgName: request.orgName,
204+
channel: request.channel,
205+
organisationSubType: this.heirarchyObject.sbOrgSubType,
206+
orgId: this.rowData.id,
207+
logo: request.logo,
208+
description: request.description
209+
}
197210

198-
this.createMDOService.updateStateOrMinistry(payload).subscribe({
211+
this.createMDOService.updateOrganization(payload).subscribe({
199212
next: (response: any) => {
200213
if (response.result) {
201214
this.organizationCreated.emit(payload)
@@ -247,4 +260,22 @@ export class CreateOrganisationComponent implements OnInit, OnDestroy {
247260
document.body.classList.remove('overflow-hidden')
248261
}
249262

263+
getOrganization(orgName: string, type: string) {
264+
this.createMDOService.searchOrgs(orgName, type).subscribe({
265+
next: (response: any) => {
266+
const organization = response.result.response.find(
267+
(org: any) => org.orgName === orgName
268+
)
269+
if (organization) {
270+
this.heirarchyObject = organization
271+
}
272+
},
273+
})
274+
}
275+
276+
onSelectStateMinistry(org: any) {
277+
this.getOrganization(org.orgName, this.controls['category'].value)
278+
279+
}
280+
250281
}

project/ws/app/src/lib/head/ui-admin-table/directory-list/directory-table.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ export class UIDirectoryTableComponent implements OnInit, AfterViewInit, OnChang
305305
this.openCreateNavBar = true
306306
this.openMode = 'editMode'
307307
this.rowData = data
308+
this.toggleOverlay(true)
308309
}
309310

310311
linkGeneratedEmit(event: any): void {

project/ws/app/src/lib/routes/home/services/create-mdo.services.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ const API_END_POINTS = {
1414
GET_ORGS_OF_DEPT: '/apis/public/v8/org/v1/list',
1515
CREATE_STATE_OR_MINISTRY: '/apis/proxies/v8/org/ext/v1/create',
1616
UPDATE_STATE_OR_MINISTRY: '/apis/proxies/v8/org/ext/v1/update',
17-
17+
SEARCH_ORG: '/api/org/ext/v2/signup/search',
18+
UPDATE_ORGANIZATION: '/apis/proxies/v8/org/ext/v1/update',
1819
}
1920

2021
@Injectable({
@@ -105,4 +106,21 @@ export class CreateMDOService {
105106
createOrganization(request: any) {
106107
return this.http.post<any>(`${API_END_POINTS.CREATE_STATE_OR_MINISTRY}`, { request: request })
107108
}
109+
110+
searchOrgs(orgName: any, type: any) {
111+
const req = {
112+
request: {
113+
filters: {
114+
orgName,
115+
parentType: type,
116+
},
117+
limit: 500,
118+
},
119+
}
120+
return this.http.post(API_END_POINTS.SEARCH_ORG, req)
121+
}
122+
123+
updateOrganization(req: any): Observable<any> {
124+
return this.http.patch<any>(`${API_END_POINTS.UPDATE_ORGANIZATION}`, req)
125+
}
108126
}

0 commit comments

Comments
 (0)