Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOSIP-35240 resolved firstName, lastName preview issue #751

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@ <h3 [style.font-size]="fontSize.headingForUIN" style="color: #505050;">{{'person
<mat-checkbox [disabled]="!data.checked" id="mask{{data.attributeName}}" (click)="captureCheckboxValue($event, data,data.maskAttributeName)">{{data.maskRequiredLabel[langCode]}}</mat-checkbox>
</td>
<td *ngIf="data.formatRequired" style="width:60%">
<button [style.font-size]="fontSize.checkBoxText" disabled [disabled]="!data.checked" mat-button [matMenuTriggerFor]="basic">{{data.formatOptionLabel[langCode]}}<mat-icon>keyboard_arrow_down</mat-icon></button>
<button [style.font-size]="fontSize.checkBoxText" [disabled]="!data.checked" mat-button [matMenuTriggerFor]="basic">{{data.formatOptionLabel[langCode]}}<mat-icon>keyboard_arrow_down</mat-icon></button>
<mat-menu #basic="matMenu" class="each-lang-card" >
<ng-container *ngFor="let data1 of data.formatOption[langCode];">
<button id="{{data1.value}}Btn" mat-menu-item>
<div class="check-box-card" (click)="captureCheckboxValue($event, data,data1)">
<input class="check-box" type="checkbox" [checked]="data1.checked"
id="{{data1.value}}" />
<input class="check-box" type="checkbox" [checked]="data1.checked" id="{{data1.value}}" />
<label [style.font-size]="fontSize.checkBoxText">{{data1.label}}</label>
</div>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class PersonalisedcardComponent implements OnInit, OnDestroy {
formatLabels: any;
formatCheckBoxClicked: boolean = false;
isLoading: boolean = true;
selectedOprionsFormOptions: object = {};
selectedOptionsFromOptions: object = {};
sitealignment:string = localStorage.getItem('direction');

constructor(private autoLogout: AutoLogoutService, private interactionService: InteractionService,
Expand Down Expand Up @@ -151,6 +151,76 @@ export class PersonalisedcardComponent implements OnInit, OnDestroy {
});
}

createDefaultValue(data: any) {
let value = "";
if (this.userInfo[data.attributeName]) {
this.userInfo[data.attributeName].forEach(eachItem => {
if (eachItem.language === this.langCode) {
value = eachItem.value
}
});
} else {
value = this.createCheckedVal(data);
}
return value
}

// Method to create preview data with formates
createCheckedVal(data:any){
let finalvalue = "";

data.formatOption[this.langCode].forEach(item => {
if (item.value !== data.attributeName && item.checked) {
if (this.userInfo[item.value])
if (typeof this.userInfo[item.value] === "string") {
finalvalue += this.userInfo[item.value]
} else {
this.userInfo[item.value].forEach(eachVal => {
if (eachVal.language === this.langCode)
data.attributeName === 'fullAddress' ? finalvalue += eachVal.value + ", " : finalvalue += eachVal.value + " ";
});
}
}
})

return finalvalue.replace(/[, \s]+$/, "");
}

// Method to Uncheck default value checkbox
checkDefaultVal(data: any, $event:any) {
let unCheckedValues = 0;
let unCheckFullAddress = () => {
data.formatOption[this.langCode].forEach(item => {
if (item.value === data.attributeName) {
item['checked'] = false;
}
})
}

for (let item of data.formatOption[this.langCode]) {
if (!item.checked && item.value !== data.attributeName) {
unCheckFullAddress();
break;
} else {
item.checked = true;
}
}

for (let eachItem of data.formatOption[this.langCode]) {
if (!eachItem.checked) {
unCheckedValues += 1
}
}
if (unCheckedValues === data.formatOption[this.langCode].length) {
data.checked = false;
delete this.dataDisplay[data.attributeName];
data.formatOption[this.langCode].forEach(item => {
item.checked = true;
})
$event.closeMenu();
}
}

captureCheckboxValue($event: any, data: any, type: any) {
this.buildHTML = "";
if (type === "datacheck") {
Expand All @@ -166,39 +236,7 @@ export class PersonalisedcardComponent implements OnInit, OnDestroy {
}
} else {
if (data.formatRequired) {
if (data.attributeName === "fullAddress") {
this.fullAddress = ""
this.schema.forEach(item => {
if (item.attributeName === data.attributeName) {
this.formatLabels = item.formatOption[this.langCode]
}
})

this.formatLabels.forEach(item => {
if (this.userInfo[item.value] !== undefined) {
if (typeof this.userInfo[item.value] !== "string") {
this.userInfo[item.value].forEach(eachLang => {
if (eachLang.language === this.langCode) {
this.fullAddress = eachLang.value + ", " + this.fullAddress;
}
})
} else {
this.fullAddress = this.fullAddress + this.userInfo[item.value];
}
}
})

if (this.fullAddress.endsWith(', ')) {
this.fullAddress = this.fullAddress.replace(/^./, "");
};
value = this.fullAddress;
} else {
this.userInfo[data.attributeName].forEach(eachItem => {
if (eachItem.language === this.langCode) {
value = eachItem.value
}
});
}
value = this.createDefaultValue(data)
} else {
this.userInfo[data.attributeName].forEach(eachItem => {
if (eachItem.language === this.langCode) {
Expand All @@ -219,7 +257,7 @@ export class PersonalisedcardComponent implements OnInit, OnDestroy {
if (item.attributeName === data.attributeName) {
let newItem = { ...item, checked: !item.checked }
if (!newItem.checked && newItem['formatOption']) {
newItem['formatOption'][this.langCode] = this.selectedOprionsFormOptions[data.attributeName]
newItem['formatOption'][this.langCode] = this.selectedOptionsFromOptions[data.attributeName]
}
return newItem
} else {
Expand All @@ -238,16 +276,13 @@ export class PersonalisedcardComponent implements OnInit, OnDestroy {
this.dataDisplay[data.attributeName] = { "label": data.label[this.langCode], "attributeName": data['attributeName'], "isMasked": $event.checked, "value": value };
} else {
let value = "";
let allValue = "";
let self = this;
if (typeof this.userInfo[data.attributeName] === "string") {
data.formatOption[this.langCode].forEach(item => {
item.checked = !item.checked
if (item.checked) {
value = moment(this.userInfo[data.attributeName]).format(item["value"]);
}
})

} else {
this.schema = this.schema.map(item => {
if (data['attributeName'] === item['attributeName']) {
Expand All @@ -262,78 +297,14 @@ export class PersonalisedcardComponent implements OnInit, OnDestroy {
return item
})


if (data.attributeName === "fullAddress") {
let selectedValuesCount = 0;
if (type["value"] !== 'fullAddress') {
this.schema.map(eachItem => {
if (data['attributeName'] === eachItem['attributeName']) {
eachItem['formatOption'][this.langCode].forEach((item) => {
if (item.checked) {
if (self.userInfo[item.value] !== undefined) {
if (item.value === "postalCode") {
allValue = allValue + self.userInfo[item.value];
} else {
this.userInfo[item.value].forEach(eachLang => {
if (eachLang.language === this.langCode) {
allValue = allValue + eachLang.value + ", ";
}
})
}
}
}
return "";
});
}
});

let unCheckFullAddress = () => {
data.formatOption[this.langCode].forEach(item => {
if (item.value === "fullAddress") {
item['checked'] = false;
}
})
}

for (let item of data.formatOption[this.langCode]) {
if (!item.checked && item.value !== "fullAddress") {
unCheckFullAddress();
break;
} else {
item.checked = true;
}
}

allValue = allValue.replace(/,(\s+)?$/, "");
value = allValue;
} else {
value = this.fullAddress
data.formatOption[this.langCode].forEach(item => {
item.checked = true;
})
}

for (let eachItem of data.formatOption[this.langCode]) {
if (!eachItem.checked) {
selectedValuesCount += 1
}
}

if (selectedValuesCount === data.formatOption[this.langCode].length) {
data.checked = false;
delete this.dataDisplay[data.attributeName];
data.formatOption[this.langCode].forEach(item => {
item.checked = true;
})
$event.closeMenu();
}
} else {
data.checked = false;
delete this.dataDisplay[data.attributeName];
if (type.value === data.attributeName) {
value = this.createDefaultValue(data)
data.formatOption[this.langCode].forEach(item => {
item.checked = true;
item.checked = true
})
$event.closeMenu();
} else {
value = this.createCheckedVal(data);
this.checkDefaultVal(data, $event);
}
}
if (data.checked) {
Expand All @@ -355,7 +326,7 @@ export class PersonalisedcardComponent implements OnInit, OnDestroy {
let formatOptions = data['formatOption'][this.langCode].map(eachItem => {
return { ...eachItem }
})
this.selectedOprionsFormOptions[data['attributeName']] = formatOptions;
this.selectedOptionsFromOptions[data['attributeName']] = formatOptions;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ <h3 [style.font-size]="fontSize.headingForUIN" style="color: #050505;">{{'sharew
<tr style="word-break: break-word;">
<td rowspan='2' *ngIf="sharableAttributes['photo']"><img [src]="sharableAttributes['photo']['value']" alt='' width='70px' height='70px' /></td>
<td>
<span *ngIf="sharableAttributes['name']">
<label [style.font-size]="fontSize.breadcrumb" style="color: #666666;">{{sharableAttributes['name']['label']}}</label><br><span [style.font-size]="fontSize.paragraph" style="color: #000000; font-weight: 400;">{{sharableAttributes['name']['value']}}</span>
<span *ngIf="sharableAttributes['fullName']">
<label [style.font-size]="fontSize.breadcrumb" style="color: #666666;">{{sharableAttributes['fullName']['label']}}</label><br><span [style.font-size]="fontSize.paragraph" style="color: #000000; font-weight: 400;">{{sharableAttributes['fullName']['value']}}</span>
</span>
</td>
<td [ngStyle]="{'float': langCode === 'ara' ? 'left' : 'right' }"><img style="height: 50px; width: 50px;" alt="logo" src="/assets/MOSIP Vertical Black.png"/></td>
Expand Down
Loading
Loading