[ADF-2640] remove option configurable (#3772)

* add optional delete button in tag node list

* add demo

* fix lint
This commit is contained in:
Eugenio Romano
2018-09-12 10:05:03 +01:00
committed by GitHub
parent cc396e2a11
commit 7ccbeee017
6 changed files with 53 additions and 2 deletions

View File

@@ -1,7 +1,7 @@
<mat-chip-list>
<mat-chip class="adf-tag-chips adf-primary-background-color" *ngFor="let currentEntry of tagsEntries; let idx = index">
<span id="tag_name_{{idx}}">{{currentEntry.entry.tag}}</span>
<button class="adf-tag-chips-delete" id="tag_chips_delete_{{currentEntry.entry.tag}}" type="button" (click)="removeTag(currentEntry.entry.id)">
<button *ngIf="showDelete" class="adf-tag-chips-delete" id="tag_chips_delete_{{currentEntry.entry.tag}}" type="button" (click)="removeTag(currentEntry.entry.id)">
<mat-icon class="adf-tag-chips-delete-icon adf-primary-contrast-text-color" matChipRemove>cancel</mat-icon>
</button>
</mat-chip>

View File

@@ -103,5 +103,35 @@ describe('TagNodeList', () => {
component.ngOnChanges();
});
it('Should not show the delete tag button if showDelete is false', (done) => {
component.nodeId = 'fake-node-id';
component.showDelete = false;
component.results.subscribe(() => {
fixture.detectChanges();
let deleteButton: any = element.querySelector('#tag_chips_delete_test1');
expect(deleteButton).toBeNull();
done();
});
component.ngOnChanges();
});
it('Should show the delete tag button if showDelete is true', (done) => {
component.nodeId = 'fake-node-id';
component.showDelete = true;
component.results.subscribe(() => {
fixture.detectChanges();
let deleteButton: any = element.querySelector('#tag_chips_delete_test1');
expect(deleteButton).not.toBeNull();
done();
});
component.ngOnChanges();
});
});
});

View File

@@ -34,6 +34,10 @@ export class TagNodeListComponent implements OnChanges {
@Input()
nodeId: string;
/** Show delete button */
@Input()
showDelete = true;
tagsEntries: any;
/** Emitted when a tag is selected. */