-
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.
* Use to toggle Open/Closed for PRs
- Loading branch information
Daniel Haselhan
committed
Mar 11, 2024
1 parent
e3f83fb
commit 94c4fb2
Showing
10 changed files
with
185 additions
and
14 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
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
27 changes: 27 additions & 0 deletions
27
...nd/src/app/shared/inline-editors/inline-button-toggle/inline-button-toggle.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,27 @@ | ||
<div class="inline-button-toggle"> | ||
<span class="left" *ngIf="!isEditing"> | ||
<a (click)="toggleEdit()" class="add-date" *ngIf="!selectedValue"> Select Option </a> | ||
<span *ngIf="selectedValue"> | ||
{{ selectedValue }} | ||
</span> | ||
<button *ngIf="selectedValue !== null" class="edit-button" mat-icon-button (click)="toggleEdit()"> | ||
<mat-icon class="edit-icon">edit</mat-icon> | ||
</button> | ||
</span> | ||
<div | ||
class="editing" | ||
[ngClass]="{ | ||
hidden: !isEditing | ||
}" | ||
> | ||
<form [formGroup]="form"> | ||
<mat-button-toggle-group [formControl]="selectFormControl"> | ||
<mat-button-toggle *ngFor="let option of options" [value]="option.value">{{ option.label }}</mat-button-toggle> | ||
</mat-button-toggle-group> | ||
</form> | ||
<div class="button-container"> | ||
<button mat-button (click)="toggleEdit()">CANCEL</button> | ||
<button mat-button class="save" (click)="onSave()">SAVE</button> | ||
</div> | ||
</div> | ||
</div> |
47 changes: 47 additions & 0 deletions
47
...nd/src/app/shared/inline-editors/inline-button-toggle/inline-button-toggle.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,47 @@ | ||
@use '../../../../styles/colors'; | ||
|
||
.editing.hidden { | ||
display: none; | ||
} | ||
|
||
.edit-button { | ||
height: 24px; | ||
width: 24px; | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.edit-icon { | ||
font-size: inherit; | ||
line-height: 22px; | ||
} | ||
|
||
.inline-button-toggle { | ||
max-width: 500px; | ||
padding-top: 4px; | ||
} | ||
|
||
.button-container { | ||
button:not(:last-child) { | ||
margin-right: 2px !important; | ||
} | ||
|
||
.save { | ||
color: colors.$primary-color; | ||
} | ||
} | ||
|
||
:host::ng-deep { | ||
.mat-form-field-wrapper { | ||
padding: 0 !important; | ||
margin: 0 !important; | ||
} | ||
|
||
button mat-icon { | ||
overflow: visible; | ||
} | ||
|
||
.mat-mdc-icon-button.mat-mdc-button-base { | ||
padding: 0 !important; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...src/app/shared/inline-editors/inline-button-toggle/inline-button-toggle.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,27 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; | ||
import { MatButtonToggleModule } from '@angular/material/button-toggle'; | ||
import { SharedModule } from '../../shared.module'; | ||
|
||
import { InlineButtonToggleComponent } from './inline-button-toggle.component'; | ||
|
||
describe('InlineButtonToggleComponent', () => { | ||
let component: InlineButtonToggleComponent; | ||
let fixture: ComponentFixture<InlineButtonToggleComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [SharedModule, FormsModule, ReactiveFormsModule, MatButtonToggleModule], | ||
declarations: [InlineButtonToggleComponent], | ||
providers: [], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(InlineButtonToggleComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
40 changes: 40 additions & 0 deletions
40
...tend/src/app/shared/inline-editors/inline-button-toggle/inline-button-toggle.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,40 @@ | ||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; | ||
import { FormBuilder, FormControl, FormGroup } from '@angular/forms'; | ||
|
||
@Component({ | ||
selector: 'app-inline-button-toggle[selectedValue][options]', | ||
templateUrl: './inline-button-toggle.component.html', | ||
styleUrls: ['./inline-button-toggle.component.scss'], | ||
}) | ||
export class InlineButtonToggleComponent implements OnInit { | ||
@Input() selectedValue?: string | null; | ||
@Input() options: { label: string; value: string }[] = []; | ||
|
||
@Output() save = new EventEmitter<string>(); | ||
|
||
selectFormControl = new FormControl(); | ||
|
||
form!: FormGroup; | ||
isEditing = false; | ||
|
||
constructor(private fb: FormBuilder) {} | ||
|
||
ngOnInit(): void { | ||
this.selectFormControl.setValue(this.selectedValue); | ||
this.form = this.fb.group({ | ||
selectFormControl: this.selectFormControl, | ||
}); | ||
} | ||
|
||
toggleEdit() { | ||
this.isEditing = !this.isEditing; | ||
this.form = this.fb.group({ | ||
selectedValue: this.selectedValue, | ||
}); | ||
} | ||
|
||
onSave() { | ||
this.save.emit(this.selectFormControl.value); | ||
this.isEditing = false; | ||
} | ||
} |
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