Skip to content

Commit 163c280

Browse files
Merge pull request #175 from KB-iGOT/cbrelease-4.8.20
Cbrelease 4.8.20
2 parents ec4474c + 9f6656c commit 163c280

File tree

9 files changed

+80
-32
lines changed

9 files changed

+80
-32
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565

6666
</ng-container>
6767

68-
<ng-container *ngIf="this.openMode !== 'editMode'">
68+
<ng-container *ngIf="this.openMode !== 'editMode' && !disableStateBlock">
6969
<mat-radio-group aria-labelledby="example-radio-group-label" class="flex gap-12 organisation-form mt-3"
7070
formControlName="category">
7171

@@ -82,7 +82,7 @@
8282
</mat-radio-group>
8383
</ng-container>
8484

85-
<ng-container *ngIf="getCategory === 'state'">
85+
<ng-container *ngIf="getCategory === 'state' && !disableStateBlock">
8686
<div class="grayBox p-4 mt-5 flex flex-column gap-1 organisation-form mat-field-rounded">
8787
<div class="flex items-center gap-1 required">
8888
<span class="lable">State</span>

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

Lines changed: 53 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,20 @@ export class CreateOrganisationComponent implements OnInit, OnDestroy {
4444
uploadedLogoResponse!: IUploadedLogoresponse
4545
organizationNameList: string[] = []
4646
ORG_NAME_PATTERN = /^[a-zA-Z0-9 ().,@\-\$\/\\:\[\]!\s]*$/
47+
rootOrgId: any
4748

4849
untilDestroyed$ = new Subject<void>();
49-
isMatcompleteOpened = false;
50+
isMatcompleteOpened = false
51+
isStateLogin = false
52+
disableStateBlock = false
5053
EXCLUDED_MINISRIES: string[] = []
54+
stateName: string = ''
5155
constructor(
5256
private formBuilder: FormBuilder,
5357
private snackBar: MatSnackBar,
5458
private createMDOService: CreateMDOService,
5559
private activatedRoute: ActivatedRoute,
56-
private loaderService: LoaderService
60+
private loaderService: LoaderService,
5761
) {
5862

5963
this.addOverflowHidden()
@@ -70,7 +74,31 @@ export class CreateOrganisationComponent implements OnInit, OnDestroy {
7074
}
7175

7276
this.organizationNameList = this.orgList.map(org => org.organisation.trim().toLowerCase())
77+
this.checkState()
7378
}
79+
checkState() {
80+
this.statesList = _.get(this.dropdownList, 'statesList', [])
81+
const userOrgName = _.get(this.activatedRoute?.snapshot.parent?.data, 'configService.unMappedUser.rootOrg', null)
82+
83+
if (userOrgName && userOrgName.isState) {
84+
this.isStateLogin = userOrgName.isState
85+
this.stateName = userOrgName.channel
86+
const findOrgDetails = (org: string) => {
87+
const result = _.find(this.statesList, { orgName: org })
88+
return result ? { orgName: result.orgName, mapId: result.mapId } : null
89+
}
90+
const orgDetails = findOrgDetails(this.stateName)
91+
if (orgDetails && orgDetails?.mapId && orgDetails?.orgName) {
92+
// Setting form values for organization
93+
this.organisationForm.controls['category'].setValue('state')
94+
this.organisationForm.controls['state'].setValue(orgDetails.orgName)
95+
// Fetching organization details
96+
this.getOrganization(this.stateName, 'state')
97+
this.disableStateBlock = true
98+
}
99+
}
100+
}
101+
74102

75103
ngOnDestroy(): void {
76104
this.removeOverflowHidden()
@@ -190,24 +218,37 @@ export class CreateOrganisationComponent implements OnInit, OnDestroy {
190218
}
191219

192220
onSubmitCreateOrganization() {
193-
const payload = {
194-
orgName: this.controls['organisationName'].value,
195-
channel: this.controls['organisationName'].value,
221+
const userProfile = _.get(this.activatedRoute, 'snapshot.parent.data.configService.userProfile')
222+
this.rootOrgId = userProfile.rootOrgId
223+
let payload: any = {
224+
orgName: this.controls['organisationName']?.value || "",
225+
channel: this.controls['organisationName']?.value || "",
196226
organisationType: "mdo",
197227
organisationSubType: "board",
198228
isTenant: true,
199229
requestedBy: this.loggedInUserId,
200-
201230
logo: this.uploadedLogoResponse?.qrcodepath || "",
202-
description: this.controls['description'].value,
231+
description: this.controls['description']?.value || "",
203232
parentMapId: "",
204-
sbRootOrgId: this.heirarchyObject?.sbRootOrgId || "",
233+
sbRootOrgId: this.rootOrgId
234+
205235
}
206-
if (this.controls['category'].value === 'state') {
207-
payload.parentMapId = this.controls['state'].value.mapId
236+
// if (this.heirarchyObject && this.heirarchyObject.sbRootOrgId) {
237+
// payload['sbRootOrgId'] = this.heirarchyObject.sbRootOrgId
238+
// }
239+
if (this.controls['category']?.value === 'state') {
240+
const orgDetails = _.find(this.statesList, { orgName: this.stateName })
241+
if (orgDetails) {
242+
payload.parentMapId = orgDetails.mapId || "" // Assign mapId from orgDetails
243+
} else if (this.controls['state']?.value?.mapId) {
244+
payload.parentMapId = this.controls['state'].value.mapId // Fallback to state control mapId
245+
} else {
246+
return // Exit function in case of error
247+
}
248+
} else if (this.controls['ministry']?.value?.mapId) {
249+
payload.parentMapId = this.controls['ministry'].value.mapId // Assign ministry mapId
208250
} else {
209-
payload.parentMapId = this.controls['ministry'].value.mapId
210-
251+
return // Exit function in case of error
211252
}
212253

213254
if (this.openMode === 'editMode') {

project/ws/app/src/lib/routes/create-mdo/routes/users/users.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export class UsersComponent implements OnInit, AfterViewInit, OnDestroy {
136136
sortState: 'asc',
137137
}
138138

139-
if (this.currentDept === 'mdo') {
139+
if (this.currentDept === 'organisation') {
140140
this.tabledata['actions'] = [{ name: 'Edit', label: 'Edit info', optional: true, icon: 'remove_red_eye', type: 'button' }]
141141
}
142142

project/ws/app/src/lib/routes/home/routes/directory/directroy.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class DirectoryViewComponent implements OnInit {
3838
pagination = { limit: 20, offset: 0 }
3939
totalCount = 0
4040
userRoles: any
41-
allowedCreateRoles = ['DASHBOARD_ADMIN', 'SPV_ADMIN', 'SPV_PUBLISHER']
41+
allowedCreateRoles = ['DASHBOARD_ADMIN', 'SPV_ADMIN', 'SPV_PUBLISHER', 'STATE_ADMIN']
4242
constructor(
4343
public dialog: MatDialog,
4444
private route: ActivatedRoute,

project/ws/app/src/lib/routes/home/routes/events/create-event/create-event.component.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,18 @@
101101
<mat-form-field appearance="outline" class="margin-top-xs">
102102
<input id="eventTitle" matInput #eventTitle formControlName="eventTitle"
103103
placeholder="Type here" aria-label="Event Title input" class="form-input"
104-
(paste)="omit_special_char($event)" (keypress)="omit_special_char($event)"
105104
maxlength="250" />
106105
<mat-error [hidden]="false"
107106
aria-label="Event title Error|Explains event title is required "
108107
*ngIf="createEventForm?.controls['eventTitle']?.touched && createEventForm?.controls['eventTitle'].errors?.required">
109108
Event title is mandatory
110109
</mat-error>
110+
<mat-error
111+
*ngIf="createEventForm?.controls['eventTitle']?.touched && createEventForm?.controls['eventTitle']?.errors?.['pattern']"
112+
[hidden]="false">
113+
Invalid input! Please enter only letters, numbers, spaces, apostrophes ('), commas
114+
(,), and colons (:)
115+
</mat-error>
111116
<mat-hint>{{eventTitle.value.length}}/250 characters</mat-hint>
112117
</mat-form-field>
113118
</div>

project/ws/app/src/lib/routes/home/routes/events/create-event/create-event.component.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export class CreateEventComponent implements OnInit {
6767
toastSuccess: any
6868
pictureObj: any
6969
myreg = /^(https?|http):\/\/[^\s/$.?#].[^\s]*$/
70+
eventTitleRegex = /^[a-zA-Z0-9\s',:]*$/
7071

7172
// myreg = /^(http|https:\/\/){0,1}(www\.){0,1}[a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,5}[\.]{0,1}/
7273

@@ -163,7 +164,10 @@ export class CreateEventComponent implements OnInit {
163164
}
164165
this.createEventForm = new UntypedFormGroup({
165166
eventPicture: new UntypedFormControl('', [Validators.required]),
166-
eventTitle: new UntypedFormControl('', [Validators.required]),
167+
eventTitle: new UntypedFormControl('', [
168+
Validators.required,
169+
Validators.pattern(this.eventTitleRegex) // Add your pattern here
170+
]),
167171
// summary: new FormControl('', [Validators.required]),
168172
description: new UntypedFormControl('', [Validators.required, preventHtmlAndJs()]),
169173
agenda: new UntypedFormControl('', [preventHtmlAndJs()]),
@@ -607,10 +611,6 @@ export class CreateEventComponent implements OnInit {
607611
})
608612
}
609613

610-
omit_special_char(event: any) {
611-
const k = event.charCode
612-
return ((k > 64 && k < 91) || (k > 96 && k < 123) || k === 8 || k === 32 || (k >= 48 && k <= 57))
613-
}
614614

615615
resetDateField() {
616616
const control = this.createEventForm.get('eventDate')

project/ws/app/src/lib/routes/home/routes/events/edit-event/edit-event.component.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,18 @@
106106
<mat-form-field appearance="outline" class="margin-top-xs">
107107
<input id="eventTitle" matInput #eventTitle formControlName="eventTitle"
108108
placeholder="Type here" aria-label="Event Title input" class="form-input"
109-
(keypress)="omit_special_char($event)" maxlength="500" />
109+
maxlength="500" />
110110
<mat-error [hidden]="false"
111111
aria-label="Event title Error|Explains event title is required "
112112
*ngIf="createEventForm?.controls['eventTitle']?.touched && createEventForm?.controls['eventTitle'].errors?.required">
113113
Event title is mandatory
114114
</mat-error>
115+
<mat-error
116+
*ngIf="createEventForm?.controls['eventTitle']?.touched && createEventForm?.controls['eventTitle']?.errors?.['pattern']"
117+
[hidden]="false">
118+
Invalid input! Please enter only letters, numbers, spaces, apostrophes ('), commas
119+
(,), and colons (:)
120+
</mat-error>
115121
<mat-hint>{{eventTitle.value.length}}/250 characters</mat-hint>
116122
</mat-form-field>
117123
</div>

project/ws/app/src/lib/routes/home/routes/events/edit-event/edit-event.component.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export class EditEventComponent implements OnInit {
6363
toastSuccess: any
6464
pictureObj: any
6565
myreg = /^(https?|http):\/\/[^\s/$.?#].[^\s]*$/
66+
eventTitleRegex = /^[a-zA-Z0-9\s',:]*$/
6667
// myreg = /(^|\s)((https?:\/\/)?[\w-]+(\.[\w-]+)+\.?(:\d+)?(\/\S*)?)/gi
6768
// myreg = /^(http[s]?:\/\/){0,1}(www\.){0,1}[a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,5}[\.]{0,1}/
6869

@@ -152,7 +153,10 @@ export class EditEventComponent implements OnInit {
152153

153154
this.createEventForm = new UntypedFormGroup({
154155
eventPicture: new UntypedFormControl('', [Validators.required]),
155-
eventTitle: new UntypedFormControl('', [Validators.required]),
156+
eventTitle: new UntypedFormControl('', [
157+
Validators.required,
158+
Validators.pattern(this.eventTitleRegex) // Add your pattern here
159+
]),
156160
// summary: new FormControl('', []),
157161
description: new UntypedFormControl('', [Validators.required, preventHtmlAndJs()]),
158162
agenda: new UntypedFormControl('', [preventHtmlAndJs()]),
@@ -632,9 +636,4 @@ export class EditEventComponent implements OnInit {
632636
this.router.navigate([`/app/home/events`])
633637
})
634638
}
635-
636-
omit_special_char(event: any) {
637-
const k = event.charCode
638-
return ((k > 64 && k < 91) || (k > 96 && k < 123) || k === 8 || k === 32 || (k >= 48 && k <= 57))
639-
}
640639
}

project/ws/app/src/lib/routes/home/services/directory.services.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ export class DirectoryService {
3939
isTenant: true,
4040
status: 1,
4141
},
42-
sort_by: {
43-
createdDate: "desc",
44-
},
4542
query: queryText,
4643
limit: pagination.limit || 20,
4744
offset: pagination.offset || 0,

0 commit comments

Comments
 (0)