WEB-638 fix: improve core utility logic and migrate from deprecated substr (#3062)

improve
This commit is contained in:
Shubham Kumar
2026-01-31 06:45:07 -06:00
committed by GitHub
parent ba47f04b62
commit 41a71cd269
8 changed files with 15 additions and 10 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ export class Commons {
let sortOrder = 1; let sortOrder = 1;
if (property[0] === '-') { if (property[0] === '-') {
sortOrder = -1; sortOrder = -1;
property = property.substr(1); property = property.substring(1);
} }
return (a: any, b: any) => { return (a: any, b: any) => {
const result = a[property] < b[property] ? -1 : a[property] > b[property] ? 1 : 0; const result = a[property] < b[property] ? -1 : a[property] > b[property] ? 1 : 0;
+4 -2
View File
@@ -29,7 +29,8 @@ export class Dates {
} }
public formatDateAsString(value: Date, dateFormat: string): string { public formatDateAsString(value: Date, dateFormat: string): string {
return moment(value).format(dateFormat); const momentFormat = dateFormat.replace(/y/g, 'Y').replace(/d/g, 'D').replace(/a/g, 'A');
return moment(value).format(momentFormat);
} }
public parseDate(value: any): Date { public parseDate(value: any): Date {
@@ -45,7 +46,8 @@ export class Dates {
} }
public convertToDate(value: any, format: string): Date { public convertToDate(value: any, format: string): Date {
return moment(value).toDate(); const momentFormat = format.replace(/y/g, 'Y').replace(/d/g, 'D').replace(/a/g, 'A');
return moment(value, momentFormat).toDate();
} }
get language() { get language() {
+2 -2
View File
@@ -16,10 +16,10 @@ import { environment } from '../../../environments/environment';
providedIn: 'root' providedIn: 'root'
}) })
export class PasswordsUtility { export class PasswordsUtility {
minPasswordLength: number = environment.minPasswordLength | 12; minPasswordLength: number = environment.minPasswordLength || 12;
public static PASSWORD_REGEX = public static PASSWORD_REGEX =
'^(?!.*(.)\\1)(?!.*\\s)(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^\\w\\s]).{' + '^(?!.*(.)\\1)(?!.*\\s)(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^\\w\\s]).{' +
(environment.minPasswordLength | 12) + (environment.minPasswordLength || 12) +
',50}$'; ',50}$';
public getPasswordValidators(): ValidatorFn[] { public getPasswordValidators(): ValidatorFn[] {
@@ -54,7 +54,7 @@ export class ChangePasswordDialogComponent implements OnInit {
private formBuilder = inject(UntypedFormBuilder); private formBuilder = inject(UntypedFormBuilder);
private passwordsUtility = inject(PasswordsUtility); private passwordsUtility = inject(PasswordsUtility);
minPasswordLength: number = environment.minPasswordLength | 12; minPasswordLength: number = environment.minPasswordLength || 12;
/** Change Password Form */ /** Change Password Form */
changePasswordForm: any; changePasswordForm: any;
@@ -95,7 +95,7 @@ export class AmazonS3Component implements OnInit {
const value = configuration.value; const value = configuration.value;
if (configuration.name === 's3_access_key' || configuration.name === 's3_secret_key') { if (configuration.name === 's3_access_key' || configuration.name === 's3_secret_key') {
return value return value
? value.replace(value.substr(1, value.length - 3), value.substr(1, value.length - 3).replace(/./g, '*')) ? value.replace(value.substring(1, value.length - 2), value.substring(1, value.length - 2).replace(/./g, '*'))
: ''; : '';
} }
return value; return value;
@@ -94,7 +94,10 @@ export class NotificationComponent implements OnInit {
getConfigurationValue(configuration: any): string { getConfigurationValue(configuration: any): string {
const value = configuration.value; const value = configuration.value;
if (configuration.name === 'server_key') { if (configuration.name === 'server_key') {
return value.replace(value.substr(1, value.length - 3), value.substr(1, value.length - 3).replace(/./g, '*')); return value.replace(
value.substring(1, value.length - 2),
value.substring(1, value.length - 2).replace(/./g, '*')
);
} }
return value; return value;
} }
@@ -110,7 +110,7 @@ export class ColumnDialogComponent implements OnInit {
return 'Dropdown'; return 'Dropdown';
} }
default: { default: {
return columnDisplayType[0] + columnDisplayType.substr(1).toLowerCase(); return columnDisplayType[0] + columnDisplayType.substring(1).toLowerCase();
} }
} }
} }
@@ -449,7 +449,7 @@ export class EditDataTableComponent implements OnInit {
return 'Dropdown'; return 'Dropdown';
} }
default: { default: {
return columnDisplayType[0] + columnDisplayType.substr(1).toLowerCase(); return columnDisplayType[0] + columnDisplayType.substring(1).toLowerCase();
} }
} }
} }