This repository has been archived by the owner on Apr 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clone Settings complete reimbursable export settings (#285)
- Loading branch information
1 parent
170b61e
commit 0ea9bb9
Showing
83 changed files
with
4,707 additions
and
504 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
|
||
import { MatLegacyDialogModule as MatDialogModule } from '@angular/material/legacy-dialog'; | ||
import { EmailMultiSelectComponent } from './email-multi-select/email-multi-select.component'; | ||
|
||
|
||
@NgModule({ | ||
declarations: [], | ||
declarations: [ | ||
EmailMultiSelectComponent | ||
], | ||
imports: [ | ||
CommonModule | ||
CommonModule, | ||
MatDialogModule | ||
] | ||
}) | ||
export class CoreModule { } |
57 changes: 57 additions & 0 deletions
57
src/app/core/email-multi-select/email-multi-select.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<div [formGroup]="form"> | ||
<mat-form-field floatLabel="always" appearance="outline" class="configuration--form-field"> | ||
<mat-select [placeholder]="placeholder" [formControlName]="formControllerName" | ||
[compareWith]="helperService.compareObjects" multiple> | ||
<app-simple-text-search [placeholder]="'Search by Name'" [page]="SimpleSearchPage.CONFIGURATION" | ||
[searchType]="SimpleSearchType.SELECT_FIELD" [form]="form"></app-simple-text-search> | ||
<mat-select-trigger fxLayout="row" fxLayoutAlign="space-between center"> | ||
<div fxLayout="row"> | ||
<div fxLayout="row" fxLayoutAlign="space-between center" | ||
class="email-multi-select--selected-email"> | ||
<div class="email-multi-select--display-email"> | ||
{{form.value.emails ? form.value.emails[0] : ''}} | ||
</div> | ||
<div fxLayout="column" class="email-multi-select--vertical"></div> | ||
<div class="mat-icon-close" (click)="delete($event, form.value.emails[0])"> | ||
<img src="assets/images/svgs/actions/close.svg"> | ||
</div> | ||
</div> | ||
<div *ngIf="form.value.emails?.length > 1" class="example-additional-selection"> | ||
<div class="email-multi-select--email-number"> | ||
+{{form.value.emails.length - 1}} | ||
</div> | ||
</div> | ||
</div> | ||
<div *ngIf="form.value.emails?.length > 1" [ngClass]="[isCloneSettings ? 'email-multi-select--delele-all-icon-clone-settings' : 'email-multi-select--delele-all-icon']" | ||
(click)="delete($event, form.value.emails[0], true)"> | ||
<img src="assets/images/svgs/actions/close.svg"> | ||
</div> | ||
</mat-select-trigger> | ||
<div *ngFor="let option of options | search : form.value.searchOption"> | ||
<p (click)="$event.stopPropagation()" *ngIf="option.name === 'No result found' " | ||
class="align-center italic email-multi-select--no-result">No result | ||
found</p> | ||
<mat-option *ngIf="option.name !== 'No result found' " [matTooltip]="option.email" | ||
[matTooltipDisabled]="option.email.length <= 40" matTooltipPosition="above" matTooltipClass="above" | ||
(click)="helperService.clearSearchText(form)" [value]="option.email" class="multiline-mat-option" | ||
fxLayout="row" fxLayoutAlign="start"> | ||
<div *ngIf="option.name !== 'No result found' "> | ||
<div class="email-multi-select--head-name "> | ||
{{option.name}} | ||
</div> | ||
<div class="email-multi-select--bottom-name"> | ||
{{option.email}} | ||
</div> | ||
</div> | ||
<img *ngIf="(form.value[formControllerName] | json) === ({name: option.name, email: option.email} | json) && (option.name !== 'No result found')" | ||
src="assets/images/svgs/general/tick-pink.svg" class="selected-value-check-mark"> | ||
</mat-option> | ||
</div> | ||
|
||
</mat-select> | ||
<div class="mat-select-arrow-closed"></div> | ||
</mat-form-field> | ||
<app-mandatory-error-message | ||
*ngIf="isFieldMandatory && form.controls[formControllerName].touched && !form.controls[formControllerName].valid && !form.controls[formControllerName].disabled" | ||
[listName]="mandatoryErrorListName" [customErrorMessage]="customErrorMessage"></app-mandatory-error-message> | ||
</div> |
111 changes: 111 additions & 0 deletions
111
src/app/core/email-multi-select/email-multi-select.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
.email-multi-select { | ||
&--email-number { | ||
margin-top: 5px; | ||
} | ||
|
||
&--delele-all-icon { | ||
margin-right: 5px; | ||
color: #5a5d72; | ||
} | ||
|
||
&--delele-all-icon-clone-settings { | ||
margin-right: 25px; | ||
color: #5a5d72; | ||
} | ||
|
||
&--delele-all-icon img { | ||
height: 10px; | ||
width: 10px; | ||
} | ||
|
||
&--delele-all-icon-clone-settings img { | ||
height: 10px; | ||
width: 10px; | ||
} | ||
|
||
&--selected-email { | ||
background-color: #ffffff; | ||
border: 1px solid #dfdfe2; | ||
border-radius: 12px; | ||
padding: 10px; | ||
height: 15px; | ||
font-size: 12px; | ||
margin-top: 2px; | ||
} | ||
|
||
&--vertical { | ||
border-left: 1px solid #dfdfe2; | ||
height: 20px; | ||
margin-left: 10px; | ||
} | ||
|
||
&--display-email { | ||
display: block; | ||
max-width: 160px; | ||
overflow: hidden; | ||
white-space: nowrap; | ||
text-overflow: ellipsis; | ||
} | ||
|
||
&--bottom-name { | ||
font-size: 12px; | ||
line-height: 15px; | ||
color: #A9ACBC; | ||
} | ||
|
||
&--head-name { | ||
font-size: 14px; | ||
line-height: 18px; | ||
color: #414562; | ||
flex: none; | ||
order: 1; | ||
flex-grow: 0; | ||
} | ||
|
||
&--no-result { | ||
padding: 8px 16px; | ||
margin: 10px; | ||
} | ||
} | ||
|
||
.configuration { | ||
&--field-section { | ||
padding: 0px 32px; | ||
} | ||
} | ||
|
||
p { | ||
margin: 0; | ||
} | ||
|
||
.mat-icon-close { | ||
color: #a9acbc; | ||
padding-left: 5px; | ||
padding-top: 5px; | ||
} | ||
|
||
.mat-icon-close img { | ||
height: 10px; | ||
width: 10px; | ||
} | ||
|
||
.mat-primary .mat-option.mat-selected:not(.mat-option-disabled) { | ||
color: #e91e63; | ||
} | ||
|
||
.multiline-mat-option.mat-option { | ||
white-space: normal; | ||
line-height: normal; | ||
height: auto !important; | ||
font-size: none !important; | ||
} | ||
|
||
.mat-option { | ||
padding-top: 8px; | ||
padding-bottom: 8px; | ||
margin: 10px; | ||
} | ||
|
||
.example-additional-selection { | ||
margin-left: 10px; | ||
} |
61 changes: 61 additions & 0 deletions
61
src/app/core/email-multi-select/email-multi-select.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { EmailMultiSelectComponent } from './email-multi-select.component'; | ||
import { NoopAnimationsModule } from '@angular/platform-browser/animations'; | ||
import { Router } from '@angular/router'; | ||
import { SearchPipe } from 'src/app/shared/pipes/search.pipe'; | ||
import { FormBuilder } from '@angular/forms'; | ||
import { MatLegacyDialogModule as MatDialogModule } from '@angular/material/legacy-dialog'; | ||
|
||
describe('EmailMultiSelectComponent', () => { | ||
let component: EmailMultiSelectComponent; | ||
let fixture: ComponentFixture<EmailMultiSelectComponent>; | ||
const routerSpy = { navigate: jasmine.createSpy('navigate'), url: '/path' }; | ||
let router: Router; | ||
let formBuilder: FormBuilder; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [MatDialogModule, NoopAnimationsModule], | ||
declarations: [ EmailMultiSelectComponent, SearchPipe ], | ||
providers: [ | ||
FormBuilder, | ||
{ provide: Router, useValue: routerSpy } | ||
] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(EmailMultiSelectComponent); | ||
component = fixture.componentInstance; | ||
formBuilder = TestBed.inject(FormBuilder); | ||
const form = formBuilder.group({ | ||
searchOption: [], | ||
emails: [['[email protected]', '[email protected]']], | ||
employeeMapping: [['EMPLOYEE']] | ||
}); | ||
component.form = form; | ||
const adminEmails: any[] = [{name: 'fyle', email: '[email protected]'}, {name: 'dhaara', email: '[email protected]'}]; | ||
component.options = adminEmails; | ||
component.formControllerName = 'employeeMapping'; | ||
component.isFieldMandatory = true; | ||
component.placeholder = 'Select representation'; | ||
|
||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('delete function check', () => { | ||
const event = new Event("click", undefined); | ||
expect(component.delete(event, '[email protected]')).toBeUndefined(); | ||
fixture.detectChanges(); | ||
expect(component.form.controls.emails.value).toEqual(['[email protected]']); | ||
expect(component.delete(event, '[email protected]', true)).toBeUndefined(); | ||
fixture.detectChanges(); | ||
expect(component.form.controls.emails.value).toBeNull(); | ||
}); | ||
}); |
53 changes: 53 additions & 0 deletions
53
src/app/core/email-multi-select/email-multi-select.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { Component, Input, OnInit } from '@angular/core'; | ||
import { FormGroup } from '@angular/forms'; | ||
import { AdvancedSettingFormOption } from 'src/app/core/models/configuration/advanced-setting.model'; | ||
import { ExportSettingFormOption } from 'src/app/core/models/configuration/export-setting.model'; | ||
import { SimpleSearchPage, SimpleSearchType } from 'src/app/core/models/enum/enum.model'; | ||
import { HelperService } from 'src/app/core/services/core/helper.service'; | ||
|
||
@Component({ | ||
selector: 'app-email-multi-select', | ||
templateUrl: './email-multi-select.component.html', | ||
styleUrls: ['./email-multi-select.component.scss'] | ||
}) | ||
export class EmailMultiSelectComponent implements OnInit { | ||
|
||
@Input() form: FormGroup; | ||
|
||
@Input() options: ExportSettingFormOption[] | AdvancedSettingFormOption[] | any[]; | ||
|
||
@Input() placeholder: string; | ||
|
||
@Input() formControllerName: string; | ||
|
||
@Input() isFieldMandatory: boolean; | ||
|
||
@Input() mandatoryErrorListName: string; | ||
|
||
@Input() customErrorMessage: string; | ||
|
||
@Input() isCloneSettings: boolean; | ||
|
||
SimpleSearchPage = SimpleSearchPage; | ||
|
||
SimpleSearchType = SimpleSearchType; | ||
|
||
constructor( | ||
public helperService: HelperService | ||
) { } | ||
|
||
delete(event: Event, email: string, deleteAll: boolean = false) { | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
if (deleteAll) { | ||
this.form.controls.emails.patchValue(null); | ||
} else { | ||
const emails = this.form.value.emails.filter((value: string) => value !== email); | ||
this.form.controls.emails.patchValue(emails); | ||
} | ||
} | ||
|
||
ngOnInit(): void { | ||
} | ||
|
||
} |
Oops, something went wrong.