Skip to content

Commit

Permalink
Merge pull request #101 from Sohith-code/cbrelease-4.8.20-custom-regi…
Browse files Browse the repository at this point in the history
…stration-sohith

Organization update api added
  • Loading branch information
vishnubansaltarento authored Nov 25, 2024
2 parents d107387 + c228eb7 commit ddf53dd
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,20 @@
<div class="px-5 pt-6">
<ng-container *ngIf="openMode !== 'createNew'">
<div class="flex items-end gap-6 mb-10">
<ng-container *ngIf="rowData?.logo">
<div class="flex justify-center items-center log-frame">
<img class="log" [src]="rowData?.logo" alt="log">
<div class="flex justify-center items-center log-frame relative rounded">
<input type="file" name="edit-orgLogo" id="edit-orgLogo" class="hidden" (change)="uploadLogo($event)"
accept=".png, .jpeg, .jpg">
<ng-container *ngIf="rowData?.logo">
<img class="log" [src]="selectedLogo" alt="log">
<ng-container *ngIf="!rowData?.logo">
<div class="">Logo</div>
</ng-container>
</ng-container>
<div class="edit-logo" onclick="document.getElementById('edit-orgLogo').click()">
<mat-icon>edit</mat-icon>
</div>
</div>

</ng-container>
<div>
<div class="organisationLable">
Organisation
Expand All @@ -39,20 +47,22 @@
</mat-form-field>
</div>

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

<div [ngClass]="{'active-radio-button': getCategory === 'state'}">
<mat-radio-button color="primary" value="state">
State
</mat-radio-button>
</div>
<div [ngClass]="{'active-radio-button': getCategory === 'center'}">
<mat-radio-button color="primary" value="center">
Center
</mat-radio-button>
</div>
</mat-radio-group>
<div [ngClass]="{'active-radio-button': getCategory === 'state'}">
<mat-radio-button color="primary" value="state">
State
</mat-radio-button>
</div>
<div [ngClass]="{'active-radio-button': getCategory === 'ministry'}">
<mat-radio-button color="primary" value="ministry">
Center
</mat-radio-button>
</div>
</mat-radio-group>
</ng-container>

<ng-container *ngIf="getCategory === 'state'">
<div class="grayBox p-4 mt-5 flex flex-column gap-1 organisation-form mat-field-rounded">
Expand All @@ -63,7 +73,8 @@
<mat-form-field class="w-full">
<input type="text" placeholder="Type to search" aria-label="Type to search" matInput
(input)="filterStates($event.target.value)" formControlName="state" [matAutocomplete]="auto">
<mat-autocomplete #auto="matAutocomplete" [displayWith]="displayFn">
<mat-autocomplete #auto="matAutocomplete" [displayWith]="displayFn"
(optionSelected)="onSelectStateMinistry($event.option.value)">
<ng-container *ngFor="let option of filteredStates">
<mat-option [value]="option">{{ option.orgName }}</mat-option>
</ng-container>
Expand All @@ -72,7 +83,7 @@
</mat-form-field>
</div>
</ng-container>
<ng-container *ngIf="getCategory === 'center'">
<ng-container *ngIf="getCategory === 'ministry'">
<div class="grayBox p-4 mt-5 flex flex-column gap-1 organisation-form mat-field-rounded">
<div class="flex items-center gap-1 required">
<span class="lable">Ministry</span>
Expand All @@ -81,7 +92,8 @@
<mat-form-field class="w-full">
<input type="text" placeholder="Type to search" aria-label="Type to search" matInput
(input)="filterMinistry($event.target.value)" formControlName="ministry" [matAutocomplete]="auto">
<mat-autocomplete #auto="matAutocomplete" [displayWith]="displayFn">
<mat-autocomplete #auto="matAutocomplete" [displayWith]="displayFn"
(optionSelected)="onSelectStateMinistry($event.option.value)">
<ng-container *ngFor="let option of filteredMinistry">
<mat-option [value]="option">{{ option.orgName }}</mat-option>
</ng-container>
Expand Down Expand Up @@ -129,18 +141,18 @@
</ng-container>
<ng-container *ngIf="openMode === 'editMode'">
<div class="flex gap-8 mt-4">
<div class="w-full flex flex-col gap-2">
<!-- <div class="w-full flex flex-col gap-2">
<div class="viewModeLable">Created By</div>
<div class="viewModeValue">{{rowData?.createdBy}}</div>
</div>
</div> -->
<div class="w-full flex flex-col gap-2">
<div class="viewModeLable">Created Date and Time</div>
<div class="viewModeValue">{{rowData?.createdOn}}</div>
</div>
</div>
</ng-container>
<ng-container *ngIf="getCategory">
<div class="flex flex-column gap-1 w-full mt-4">
<div class="flex flex-column gap-1 w-full mt-8">
<div class="flex items-center gap-1 required">
<span class="lable">Description</span>
</div>
Expand Down Expand Up @@ -202,7 +214,7 @@
<div class="right-sidenav-footer flex items-center justify-end gap-4 items-center px-5 pt-3 pb-5 bg-white">
<ng-container *ngIf="openMode !== 'viewMode'">
<button mat-button class="cancelButton" (click)="closeNaveBar()">Cancel</button>
<button mat-flat-button class="mat-btn-flat" [disabled]="isLoading || this.organisationForm.valid"
<button mat-flat-button class="mat-btn-flat" [disabled]="isLoading || this.organisationForm.invalid"
(click)="onSubmitCreateOrganization()">{{openMode
=== 'editMode' ? 'Update' : 'Add'}}</button>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,18 @@
margin-top: 2px !important;
}
}

.edit-logo {
position: absolute;
top: -8px;
right: -8px;
cursor: pointer;

mat-icon {
font-size: 14px;
height: 14px;
width: 14px;
color: #1b4ca1;

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class CreateOrganisationComponent implements OnInit, OnDestroy {
isLoading = false
filteredStates: any[] = []
filteredMinistry: any[] = []

heirarchyObject: any
constructor(
private formBuilder: FormBuilder,
private snackBar: MatSnackBar,
Expand All @@ -55,13 +55,18 @@ export class CreateOrganisationComponent implements OnInit, OnDestroy {
ngOnInit(): void {
this.loggedInUserId = _.get(this.activatedRoute, 'snapshot.parent.data.configService.userProfile.userId')
this.initialization()
if (this.openMode === 'editMode') {
this.getOrganization(this.rowData.organisation, this.rowData.type.toLowerCase())
}
}

ngOnDestroy(): void {
this.removeOverflowHidden()
}

initialization() {
console.log(this.rowData)

if (this.dropdownList) {
this.statesList = _.get(this.dropdownList, 'statesList', [])
this.filteredStates = [...this.statesList]
Expand Down Expand Up @@ -113,7 +118,7 @@ export class CreateOrganisationComponent implements OnInit, OnDestroy {
this.organisationForm.controls.ministry.setValue('')
this.organisationForm.controls.ministry.clearValidators()
this.organisationForm.controls.ministry.updateValueAndValidity()
} else if (val === 'center') {
} else if (val === 'ministry') {
this.organisationForm.controls.ministry.setValidators([Validators.required])
this.organisationForm.controls.ministry.updateValueAndValidity()
this.organisationForm.controls.state.setValue('')
Expand All @@ -140,17 +145,17 @@ export class CreateOrganisationComponent implements OnInit, OnDestroy {

onSubmitCreateOrganization() {
const payload = {
"orgName": this.controls['organisationName'].value,
"channel": this.controls['organisationName'].value,
"organisationType": "",
"organisationSubType": "",
"isTenant": true,
"requestedBy": this.loggedInUserId,

"logo": this.selectedLogo,
"description": this.controls['description'].value,
"parentMapId": "",
"sbRootOrgId": "",
orgName: this.controls['organisationName'].value,
channel: this.controls['organisationName'].value,
organisationType: this.heirarchyObject?.sbOrgType || "",
organisationSubType: this.heirarchyObject?.sbOrgSubType || "",
isTenant: true,
requestedBy: this.loggedInUserId,

logo: this.selectedLogo,
description: this.controls['description'].value,
parentMapId: this.heirarchyObject?.parentMapId || "",
sbRootOrgId: this.heirarchyObject?.parentMapId || "",
}

if (this.controls['category'].value === "state") {
Expand Down Expand Up @@ -191,11 +196,19 @@ export class CreateOrganisationComponent implements OnInit, OnDestroy {
}
})
}
private updateOrganization(payload: any): void {
private updateOrganization(request: any): void {
this.loaderService.changeLoad.next(true)
this.isLoading = true
const payload = {
orgName: request.orgName,
channel: request.channel,
organisationSubType: this.heirarchyObject.sbOrgSubType,
orgId: this.rowData.id,
logo: request.logo,
description: request.description
}

this.createMDOService.updateStateOrMinistry(payload).subscribe({
this.createMDOService.updateOrganization(payload).subscribe({
next: (response: any) => {
if (response.result) {
this.organizationCreated.emit(payload)
Expand Down Expand Up @@ -247,4 +260,22 @@ export class CreateOrganisationComponent implements OnInit, OnDestroy {
document.body.classList.remove('overflow-hidden')
}

getOrganization(orgName: string, type: string) {
this.createMDOService.searchOrgs(orgName, type).subscribe({
next: (response: any) => {
const organization = response.result.response.find(
(org: any) => org.orgName === orgName
)
if (organization) {
this.heirarchyObject = organization
}
},
})
}

onSelectStateMinistry(org: any) {
this.getOrganization(org.orgName, this.controls['category'].value)

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ export class UIDirectoryTableComponent implements OnInit, AfterViewInit, OnChang
this.openCreateNavBar = true
this.openMode = 'editMode'
this.rowData = data
this.toggleOverlay(true)
}

linkGeneratedEmit(event: any): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const API_END_POINTS = {
GET_ORGS_OF_DEPT: '/apis/public/v8/org/v1/list',
CREATE_STATE_OR_MINISTRY: '/apis/proxies/v8/org/ext/v1/create',
UPDATE_STATE_OR_MINISTRY: '/apis/proxies/v8/org/ext/v1/update',

SEARCH_ORG: '/api/org/ext/v2/signup/search',
UPDATE_ORGANIZATION: '/apis/proxies/v8/org/ext/v1/update',
}

@Injectable({
Expand Down Expand Up @@ -105,4 +106,21 @@ export class CreateMDOService {
createOrganization(request: any) {
return this.http.post<any>(`${API_END_POINTS.CREATE_STATE_OR_MINISTRY}`, { request: request })
}

searchOrgs(orgName: any, type: any) {
const req = {
request: {
filters: {
orgName,
parentType: type,
},
limit: 500,
},
}
return this.http.post(API_END_POINTS.SEARCH_ORG, req)
}

updateOrganization(req: any): Observable<any> {
return this.http.patch<any>(`${API_END_POINTS.UPDATE_ORGANIZATION}`, req)
}
}

0 comments on commit ddf53dd

Please sign in to comment.