🐛 fix recursion in input erase button

This commit is contained in:
Baptiste Lemoine 2020-01-21 12:30:53 +01:00
parent a68cbdcc0a
commit 195259bb72
6 changed files with 825 additions and 1023 deletions

View File

@ -5,7 +5,7 @@
"ng": "ng", "ng": "ng",
"start": "ng serve", "start": "ng serve",
"serve": "ng serve", "serve": "ng serve",
"build": "ng build", "build": "ng build --crossOrigin=anonymous --aot=false",
"build:demo": "ng build --crossOrigin=anonymous --extractCss=true --baseHref=https://framadate-api.cipherbliss.com --aot=true --progress=true --statsJson=true", "build:demo": "ng build --crossOrigin=anonymous --extractCss=true --baseHref=https://framadate-api.cipherbliss.com --aot=true --progress=true --statsJson=true",
"test": "ng test", "test": "ng test",
"lint": "ng lint", "lint": "ng lint",

View File

@ -10,6 +10,13 @@ export interface DateOption {
literal: string; literal: string;
} }
const baseConfigValues = {
pollType: "classic",
title: "",
description: "",
myName: "",
myEmail: "",
};
/** /**
* configuration of the poll, add new fields at will * configuration of the poll, add new fields at will
@ -52,4 +59,11 @@ export class PollConfig {
constructor() { constructor() {
} }
resetConfig() {
const self = this;
Object.keys(baseConfigValues).forEach((key) => {
self[key] = baseConfigValues[key];
})
}
} }

View File

@ -9,6 +9,11 @@
> >
{{"creation.want"|translate}} {{"creation.want"|translate}}
</span > </span >
<button
(click)='config.resetConfig()'
class='btn btn--warning' >
Reset all
</button >
<select <select
[(ngModel)]="config.pollType" [(ngModel)]="config.pollType"
autofocus="autofocus" autofocus="autofocus"

View File

@ -1,6 +1,6 @@
<button <button
class="erase btn btn--warning" class="erase btn btn--warning"
[disabled]='!inputModel' *ngIf='inputModel.length'
(click)="eraseInput()" > (click)="eraseInput()" >
<i class="fa fa-times" ></i > <i class="fa fa-times" ></i >
</button > </button >

View File

@ -6,15 +6,9 @@ import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
styleUrls: ['./erasable-input.component.scss'] styleUrls: ['./erasable-input.component.scss']
}) })
export class ErasableInputComponent implements OnInit { export class ErasableInputComponent implements OnInit {
@Output() inputModelChange = new EventEmitter(); @Output() inputModelChange = new EventEmitter();
@Input() get inputModel() { @Input() inputModel;
return this.inputModel;
}
set inputModel(val) {
}
constructor() { constructor() {
} }
@ -23,7 +17,7 @@ export class ErasableInputComponent implements OnInit {
} }
eraseInput() { eraseInput() {
this.inputModel = ''; //
this.inputModelChange.emit(''); this.inputModelChange.emit('');
} }

1815
yarn.lock

File diff suppressed because it is too large Load Diff