Skip to content

Commit

Permalink
Merge pull request #175 from KB-iGOT/cbrelease-4.8.20
Browse files Browse the repository at this point in the history
Cbrelease 4.8.20
  • Loading branch information
vishnubansaltarento authored Feb 10, 2025
2 parents ec4474c + 9f6656c commit 163c280
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@

</ng-container>

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

Expand All @@ -82,7 +82,7 @@
</mat-radio-group>
</ng-container>

<ng-container *ngIf="getCategory === 'state'">
<ng-container *ngIf="getCategory === 'state' && !disableStateBlock">
<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">State</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,20 @@ export class CreateOrganisationComponent implements OnInit, OnDestroy {
uploadedLogoResponse!: IUploadedLogoresponse
organizationNameList: string[] = []
ORG_NAME_PATTERN = /^[a-zA-Z0-9 ().,@\-\$\/\\:\[\]!\s]*$/
rootOrgId: any

untilDestroyed$ = new Subject<void>();
isMatcompleteOpened = false;
isMatcompleteOpened = false
isStateLogin = false
disableStateBlock = false
EXCLUDED_MINISRIES: string[] = []
stateName: string = ''
constructor(
private formBuilder: FormBuilder,
private snackBar: MatSnackBar,
private createMDOService: CreateMDOService,
private activatedRoute: ActivatedRoute,
private loaderService: LoaderService
private loaderService: LoaderService,
) {

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

this.organizationNameList = this.orgList.map(org => org.organisation.trim().toLowerCase())
this.checkState()
}
checkState() {
this.statesList = _.get(this.dropdownList, 'statesList', [])
const userOrgName = _.get(this.activatedRoute?.snapshot.parent?.data, 'configService.unMappedUser.rootOrg', null)

if (userOrgName && userOrgName.isState) {
this.isStateLogin = userOrgName.isState
this.stateName = userOrgName.channel
const findOrgDetails = (org: string) => {
const result = _.find(this.statesList, { orgName: org })
return result ? { orgName: result.orgName, mapId: result.mapId } : null
}
const orgDetails = findOrgDetails(this.stateName)
if (orgDetails && orgDetails?.mapId && orgDetails?.orgName) {
// Setting form values for organization
this.organisationForm.controls['category'].setValue('state')
this.organisationForm.controls['state'].setValue(orgDetails.orgName)
// Fetching organization details
this.getOrganization(this.stateName, 'state')
this.disableStateBlock = true
}
}
}


ngOnDestroy(): void {
this.removeOverflowHidden()
Expand Down Expand Up @@ -190,24 +218,37 @@ export class CreateOrganisationComponent implements OnInit, OnDestroy {
}

onSubmitCreateOrganization() {
const payload = {
orgName: this.controls['organisationName'].value,
channel: this.controls['organisationName'].value,
const userProfile = _.get(this.activatedRoute, 'snapshot.parent.data.configService.userProfile')
this.rootOrgId = userProfile.rootOrgId
let payload: any = {
orgName: this.controls['organisationName']?.value || "",
channel: this.controls['organisationName']?.value || "",
organisationType: "mdo",
organisationSubType: "board",
isTenant: true,
requestedBy: this.loggedInUserId,

logo: this.uploadedLogoResponse?.qrcodepath || "",
description: this.controls['description'].value,
description: this.controls['description']?.value || "",
parentMapId: "",
sbRootOrgId: this.heirarchyObject?.sbRootOrgId || "",
sbRootOrgId: this.rootOrgId

}
if (this.controls['category'].value === 'state') {
payload.parentMapId = this.controls['state'].value.mapId
// if (this.heirarchyObject && this.heirarchyObject.sbRootOrgId) {
// payload['sbRootOrgId'] = this.heirarchyObject.sbRootOrgId
// }
if (this.controls['category']?.value === 'state') {
const orgDetails = _.find(this.statesList, { orgName: this.stateName })
if (orgDetails) {
payload.parentMapId = orgDetails.mapId || "" // Assign mapId from orgDetails
} else if (this.controls['state']?.value?.mapId) {
payload.parentMapId = this.controls['state'].value.mapId // Fallback to state control mapId
} else {
return // Exit function in case of error
}
} else if (this.controls['ministry']?.value?.mapId) {
payload.parentMapId = this.controls['ministry'].value.mapId // Assign ministry mapId
} else {
payload.parentMapId = this.controls['ministry'].value.mapId

return // Exit function in case of error
}

if (this.openMode === 'editMode') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export class UsersComponent implements OnInit, AfterViewInit, OnDestroy {
sortState: 'asc',
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class DirectoryViewComponent implements OnInit {
pagination = { limit: 20, offset: 0 }
totalCount = 0
userRoles: any
allowedCreateRoles = ['DASHBOARD_ADMIN', 'SPV_ADMIN', 'SPV_PUBLISHER']
allowedCreateRoles = ['DASHBOARD_ADMIN', 'SPV_ADMIN', 'SPV_PUBLISHER', 'STATE_ADMIN']
constructor(
public dialog: MatDialog,
private route: ActivatedRoute,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,18 @@
<mat-form-field appearance="outline" class="margin-top-xs">
<input id="eventTitle" matInput #eventTitle formControlName="eventTitle"
placeholder="Type here" aria-label="Event Title input" class="form-input"
(paste)="omit_special_char($event)" (keypress)="omit_special_char($event)"
maxlength="250" />
<mat-error [hidden]="false"
aria-label="Event title Error|Explains event title is required "
*ngIf="createEventForm?.controls['eventTitle']?.touched && createEventForm?.controls['eventTitle'].errors?.required">
Event title is mandatory
</mat-error>
<mat-error
*ngIf="createEventForm?.controls['eventTitle']?.touched && createEventForm?.controls['eventTitle']?.errors?.['pattern']"
[hidden]="false">
Invalid input! Please enter only letters, numbers, spaces, apostrophes ('), commas
(,), and colons (:)
</mat-error>
<mat-hint>{{eventTitle.value.length}}/250 characters</mat-hint>
</mat-form-field>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export class CreateEventComponent implements OnInit {
toastSuccess: any
pictureObj: any
myreg = /^(https?|http):\/\/[^\s/$.?#].[^\s]*$/
eventTitleRegex = /^[a-zA-Z0-9\s',:]*$/

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

Expand Down Expand Up @@ -163,7 +164,10 @@ export class CreateEventComponent implements OnInit {
}
this.createEventForm = new UntypedFormGroup({
eventPicture: new UntypedFormControl('', [Validators.required]),
eventTitle: new UntypedFormControl('', [Validators.required]),
eventTitle: new UntypedFormControl('', [
Validators.required,
Validators.pattern(this.eventTitleRegex) // Add your pattern here
]),
// summary: new FormControl('', [Validators.required]),
description: new UntypedFormControl('', [Validators.required, preventHtmlAndJs()]),
agenda: new UntypedFormControl('', [preventHtmlAndJs()]),
Expand Down Expand Up @@ -607,10 +611,6 @@ export class CreateEventComponent implements OnInit {
})
}

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

resetDateField() {
const control = this.createEventForm.get('eventDate')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,18 @@
<mat-form-field appearance="outline" class="margin-top-xs">
<input id="eventTitle" matInput #eventTitle formControlName="eventTitle"
placeholder="Type here" aria-label="Event Title input" class="form-input"
(keypress)="omit_special_char($event)" maxlength="500" />
maxlength="500" />
<mat-error [hidden]="false"
aria-label="Event title Error|Explains event title is required "
*ngIf="createEventForm?.controls['eventTitle']?.touched && createEventForm?.controls['eventTitle'].errors?.required">
Event title is mandatory
</mat-error>
<mat-error
*ngIf="createEventForm?.controls['eventTitle']?.touched && createEventForm?.controls['eventTitle']?.errors?.['pattern']"
[hidden]="false">
Invalid input! Please enter only letters, numbers, spaces, apostrophes ('), commas
(,), and colons (:)
</mat-error>
<mat-hint>{{eventTitle.value.length}}/250 characters</mat-hint>
</mat-form-field>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export class EditEventComponent implements OnInit {
toastSuccess: any
pictureObj: any
myreg = /^(https?|http):\/\/[^\s/$.?#].[^\s]*$/
eventTitleRegex = /^[a-zA-Z0-9\s',:]*$/
// myreg = /(^|\s)((https?:\/\/)?[\w-]+(\.[\w-]+)+\.?(:\d+)?(\/\S*)?)/gi
// myreg = /^(http[s]?:\/\/){0,1}(www\.){0,1}[a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,5}[\.]{0,1}/

Expand Down Expand Up @@ -152,7 +153,10 @@ export class EditEventComponent implements OnInit {

this.createEventForm = new UntypedFormGroup({
eventPicture: new UntypedFormControl('', [Validators.required]),
eventTitle: new UntypedFormControl('', [Validators.required]),
eventTitle: new UntypedFormControl('', [
Validators.required,
Validators.pattern(this.eventTitleRegex) // Add your pattern here
]),
// summary: new FormControl('', []),
description: new UntypedFormControl('', [Validators.required, preventHtmlAndJs()]),
agenda: new UntypedFormControl('', [preventHtmlAndJs()]),
Expand Down Expand Up @@ -632,9 +636,4 @@ export class EditEventComponent implements OnInit {
this.router.navigate([`/app/home/events`])
})
}

omit_special_char(event: any) {
const k = event.charCode
return ((k > 64 && k < 91) || (k > 96 && k < 123) || k === 8 || k === 32 || (k >= 48 && k <= 57))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ export class DirectoryService {
isTenant: true,
status: 1,
},
sort_by: {
createdDate: "desc",
},
query: queryText,
limit: pagination.limit || 20,
offset: pagination.offset || 0,
Expand Down

0 comments on commit 163c280

Please sign in to comment.