mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
* disable add button when no valid ID is provided #1591 * fix test
This commit is contained in:
parent
f3c9ffab8d
commit
2f3aeb84a1
@ -13,7 +13,7 @@
|
||||
<input class="mdl-textfield__input tag-input" type="text" id="new-tag-text" (keypress)="cleanErrorMsg()" [(ngModel)]="newTagName"/>
|
||||
<label class="mdl-textfield__label" for="new-tag-text" > {{'TAG.LABEL.NEWTAG' | translate }}</label>
|
||||
<span class="mdl-textfield__error">{{errorMsg}}</span>
|
||||
<button id="add-tag" class="mdl-button mdl-js-button mdl-button--raised button" (click)="addTag()">
|
||||
<button id="add-tag" class="mdl-button mdl-js-button mdl-button--raised button" (click)="addTag()" [disabled]="disableAddTag">
|
||||
{{'TAG.BUTTON.ADD' | translate }}
|
||||
</button>
|
||||
</div>
|
||||
@ -33,7 +33,7 @@
|
||||
<input class="mdl-textfield__input tag-input" type="text" id="new-tag-text" (keypress)="cleanErrorMsg()" [(ngModel)]="newTagName"/>
|
||||
<label class="mdl-textfield__label" for="new-tag-text" > {{'TAG.LABEL.NEWTAG' | translate }}</label>
|
||||
<span *ngIf="errorMsg" class="mdl-textfield__error">{{errorMsg}}</span>
|
||||
<button id="add-tag" class="mdl-button mdl-js-button mdl-button--raised button" (click)="addTag()">
|
||||
<button id="add-tag" class="mdl-button mdl-js-button mdl-button--raised button" (click)="addTag()" [disabled]="disableAddTag">
|
||||
{{'TAG.BUTTON.ADD' | translate }}
|
||||
</button>
|
||||
</div>
|
||||
|
@ -146,6 +146,9 @@ describe('Test ng2-alfresco-tag Tag actions list', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
component.resultsEmitter.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
|
||||
let addButton: any = element.querySelector('#add-tag');
|
||||
addButton.click();
|
||||
|
||||
@ -154,6 +157,16 @@ describe('Test ng2-alfresco-tag Tag actions list', () => {
|
||||
});
|
||||
});
|
||||
|
||||
component.ngOnChanges();
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: dataTag
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('The input box should be cleared after add tag', (done) => {
|
||||
component.nodeId = 'fake-node-id';
|
||||
component.newTagName = 'fake-tag-name';
|
||||
@ -165,6 +178,9 @@ describe('Test ng2-alfresco-tag Tag actions list', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
component.resultsEmitter.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
|
||||
let addButton: any = element.querySelector('#add-tag');
|
||||
addButton.click();
|
||||
|
||||
@ -172,5 +188,61 @@ describe('Test ng2-alfresco-tag Tag actions list', () => {
|
||||
status: 200
|
||||
});
|
||||
});
|
||||
|
||||
component.ngOnChanges();
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: dataTag
|
||||
});
|
||||
});
|
||||
|
||||
it('Add tag should be disabled by default', (done) => {
|
||||
component.nodeId = 'fake-node-id';
|
||||
component.newTagName = 'fake-tag-name';
|
||||
|
||||
let addButton: any = element.querySelector('#add-tag');
|
||||
expect(addButton.disabled).toEqual(true);
|
||||
done();
|
||||
});
|
||||
|
||||
it('Add tag should be disabled if the node id is not a correct node', (done) => {
|
||||
component.nodeId = 'fake-node-id';
|
||||
component.newTagName = 'fake-tag-name';
|
||||
|
||||
component.resultsEmitter.subscribe(() => {
|
||||
let addButton: any = element.querySelector('#add-tag');
|
||||
expect(addButton.disabled).toEqual(true);
|
||||
done();
|
||||
});
|
||||
|
||||
component.ngOnChanges();
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 404
|
||||
});
|
||||
});
|
||||
|
||||
it('Add tag should be enable if the node id is a correct node', (done) => {
|
||||
component.nodeId = 'fake-node-id';
|
||||
component.newTagName = 'fake-tag-name';
|
||||
|
||||
component.resultsEmitter.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
|
||||
let addButton: any = element.querySelector('#add-tag');
|
||||
expect(addButton.disabled).toEqual(false);
|
||||
done();
|
||||
});
|
||||
|
||||
component.ngOnChanges();
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: dataTag
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -52,6 +52,8 @@ export class TagActionsComponent {
|
||||
|
||||
errorMsg: string;
|
||||
|
||||
disableAddTag: boolean = true;
|
||||
|
||||
constructor(private tagService: TagService, private translateService: AlfrescoTranslationService) {
|
||||
if (translateService) {
|
||||
translateService.addTranslationFolder('ng2-alfresco-tag', 'node_modules/ng2-alfresco-tag/src');
|
||||
@ -65,6 +67,11 @@ export class TagActionsComponent {
|
||||
refreshTag() {
|
||||
this.tagService.getTagsByNodeId(this.nodeId).subscribe((data) => {
|
||||
this.tagsEntries = data.list.entries;
|
||||
this.disableAddTag = false;
|
||||
this.resultsEmitter.emit(this.tagsEntries);
|
||||
}, () => {
|
||||
this.tagsEntries = null;
|
||||
this.disableAddTag = true;
|
||||
this.resultsEmitter.emit(this.tagsEntries);
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user