Skip to content
Snippets Groups Projects
Commit f130765f authored by pnogal's avatar pnogal Committed by Paulina Nogal
Browse files

Add maxLength when creating new plan or renaminf existing

parent 29d258d2
No related branches found
No related tags found
No related merge requests found
...@@ -119,6 +119,7 @@ export class DegreePlannerComponent implements OnInit, OnDestroy { ...@@ -119,6 +119,7 @@ export class DegreePlannerComponent implements OnInit, OnDestroy {
title: 'Add degree plan', title: 'Add degree plan',
confirmText: 'Save', confirmText: 'Save',
inputName: 'Plan name', inputName: 'Plan name',
maxLength: 100,
}, },
}) })
.afterClosed() .afterClosed()
...@@ -139,6 +140,7 @@ export class DegreePlannerComponent implements OnInit, OnDestroy { ...@@ -139,6 +140,7 @@ export class DegreePlannerComponent implements OnInit, OnDestroy {
title: 'Rename plan', title: 'Rename plan',
confirmText: 'Save', confirmText: 'Save',
inputName: 'Plan name', inputName: 'Plan name',
maxLength: 100,
}, },
}) })
.afterClosed() .afterClosed()
......
...@@ -60,6 +60,7 @@ export class SidenavMenuItemComponent implements OnDestroy { ...@@ -60,6 +60,7 @@ export class SidenavMenuItemComponent implements OnDestroy {
title: 'Add degree plan', title: 'Add degree plan',
confirmText: 'Save', confirmText: 'Save',
inputName: 'Plan name', inputName: 'Plan name',
maxLength: 100,
}, },
}) })
.afterClosed() .afterClosed()
......
...@@ -27,11 +27,17 @@ ...@@ -27,11 +27,17 @@
fxLayoutAlign="space-around none" fxLayoutAlign="space-around none"
style="padding: 12px 22px;"> style="padding: 12px 22px;">
<mat-form-field> <mat-form-field>
<input <textarea
cdkFocusInitial cdkFocusInitial
formControlName="value"
matInput matInput
[placeholder]="inputName" mat-autosize="true"
formControlName="value"/> resizeToFitContent
[placeholder]="inputName">
</textarea>
<mat-hint align="end">
{{ inputForm.value.value.length }} / {{ maxLength }}
</mat-hint>
</mat-form-field> </mat-form-field>
</form> </form>
</mat-dialog-content> </mat-dialog-content>
......
...@@ -10,6 +10,7 @@ import { ...@@ -10,6 +10,7 @@ import {
} from '@angular/forms'; } from '@angular/forms';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { Year } from '@app/core/models/year'; import { Year } from '@app/core/models/year';
import { NgSwitch } from '@angular/common';
@Component({ @Component({
selector: 'cse-prompt-dialog', selector: 'cse-prompt-dialog',
...@@ -24,6 +25,7 @@ export class PromptDialogComponent implements OnInit { ...@@ -24,6 +25,7 @@ export class PromptDialogComponent implements OnInit {
tooltip?: string; tooltip?: string;
cancelText: string; cancelText: string;
confirmText: string; confirmText: string;
maxLength: number;
confirmColor: string; confirmColor: string;
public termsByYear$: Observable<Year[]>; public termsByYear$: Observable<Year[]>;
...@@ -31,7 +33,6 @@ export class PromptDialogComponent implements OnInit { ...@@ -31,7 +33,6 @@ export class PromptDialogComponent implements OnInit {
initialValue: string; initialValue: string;
constructor( constructor(
private dialogRef: MatDialogRef<PromptDialogComponent>, private dialogRef: MatDialogRef<PromptDialogComponent>,
private fb: FormBuilder,
@Inject(MAT_DIALOG_DATA) data: any, @Inject(MAT_DIALOG_DATA) data: any,
) { ) {
const { const {
...@@ -41,6 +42,7 @@ export class PromptDialogComponent implements OnInit { ...@@ -41,6 +42,7 @@ export class PromptDialogComponent implements OnInit {
initialValue = '', initialValue = '',
placeholder, placeholder,
tooltip, tooltip,
maxLength,
cancelText = 'Cancel', cancelText = 'Cancel',
confirmText = 'Confirm', confirmText = 'Confirm',
confirmColor = 'primary', confirmColor = 'primary',
...@@ -53,6 +55,7 @@ export class PromptDialogComponent implements OnInit { ...@@ -53,6 +55,7 @@ export class PromptDialogComponent implements OnInit {
this.tooltip = tooltip; this.tooltip = tooltip;
this.cancelText = cancelText; this.cancelText = cancelText;
this.confirmText = confirmText; this.confirmText = confirmText;
this.maxLength = maxLength;
this.confirmColor = confirmColor; this.confirmColor = confirmColor;
this.initialValue = initialValue; this.initialValue = initialValue;
...@@ -63,8 +66,11 @@ export class PromptDialogComponent implements OnInit { ...@@ -63,8 +66,11 @@ export class PromptDialogComponent implements OnInit {
ngOnInit() { ngOnInit() {
// Deafults for input form // Deafults for input form
this.inputForm = this.fb.group({ this.inputForm = new FormGroup({
value: [this.initialValue, Validators.required], value: new FormControl(this.initialValue || '', [
Validators.maxLength(this.maxLength),
Validators.required,
]),
}); });
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment