mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
committed by
Mario Romano
parent
2a257f7b62
commit
20b3835f85
@@ -7,13 +7,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.tag-input {
|
.tag-input {
|
||||||
|
margin-right: 11px;
|
||||||
float: left;
|
float: left;
|
||||||
margin-left: 11px!important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tag-label {
|
|
||||||
left: 10px!important;
|
|
||||||
top: 12px!important;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-container-input{
|
.tag-container-input{
|
||||||
@@ -26,3 +21,7 @@
|
|||||||
.tag-button{
|
.tag-button{
|
||||||
float:left
|
float:left
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mdl-textfield__error {
|
||||||
|
visibility: visible !important;
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,13 +9,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<div class="mdl-textfield mdl-js-textfield tag-container-input">
|
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
|
||||||
<input class="mdl-textfield__input tag-input" type="text" id="new-tag-text" [(ngModel)]="newTagName"/>
|
<input class="mdl-textfield__input tag-input" type="text" id="new-tag-text" (click)="cleanErrorMsg()" [(ngModel)]="newTagName"/>
|
||||||
<label class="mdl-textfield__label tag-label" for="new-tag-text">New Tag...</label>
|
<label class="mdl-textfield__label" for="new-tag-text" > {{'TAG.LABEL.NEWTAG' | translate }}</label>
|
||||||
</div>
|
<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()">
|
||||||
Add tag
|
{{'TAG.BUTTON.ADD' | translate }}
|
||||||
</button>
|
</button>
|
||||||
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -28,12 +29,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<div class="mdl-textfield mdl-js-textfield tag-container-input">
|
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
|
||||||
<input class="mdl-textfield__input tag-input" type="text" id="new-tag-text" [(ngModel)]="newTagName"/>
|
<input class="mdl-textfield__input tag-input" type="text" id="new-tag-text" (click)="cleanErrorMsg()" [(ngModel)]="newTagName"/>
|
||||||
<label class="mdl-textfield__label tag-label" for="new-tag-text">New Tag...</label>
|
<label class="mdl-textfield__label" for="new-tag-text" > {{'TAG.LABEL.NEWTAG' | translate }}</label>
|
||||||
</div>
|
<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()">
|
||||||
Add tag
|
{{'TAG.BUTTON.ADD' | translate }}
|
||||||
</button>
|
</button>
|
||||||
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -153,5 +153,24 @@ describe('Test ng2-alfresco-tag Tag actions list', () => {
|
|||||||
status: 200
|
status: 200
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('The input box should be cleared after add tag', (done) => {
|
||||||
|
component.nodeId = 'fake-node-id';
|
||||||
|
component.newTagName = 'fake-tag-name';
|
||||||
|
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
component.addEmitter.subscribe(() => {
|
||||||
|
expect(component.newTagName).toBe('');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
let addButton: any = element.querySelector('#add-tag');
|
||||||
|
addButton.click();
|
||||||
|
|
||||||
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
|
status: 200
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
||||||
import { TagService } from './../services/tag.service';
|
import { TagService } from './../services/tag.service';
|
||||||
|
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -49,14 +50,15 @@ export class TagActionsComponent {
|
|||||||
|
|
||||||
tagsEntries: any;
|
tagsEntries: any;
|
||||||
|
|
||||||
/**
|
errorMsg: string;
|
||||||
* Constructor
|
|
||||||
* @param authService
|
constructor(private tagService: TagService, private translateService: AlfrescoTranslationService) {
|
||||||
*/
|
if (translateService) {
|
||||||
constructor(private tagService: TagService) {
|
translateService.addTranslationFolder('ng2-alfresco-tag', 'node_modules/ng2-alfresco-tag/src');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes) {
|
ngOnChanges() {
|
||||||
return this.refreshTag();
|
return this.refreshTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,12 +70,31 @@ export class TagActionsComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addTag() {
|
addTag() {
|
||||||
this.tagService.addTag(this.nodeId, this.newTagName).subscribe((res) => {
|
if (this.searchTag(this.newTagName)) {
|
||||||
|
this.translateService.get('TAG.MESSAGES.EXIST').subscribe((error) => {
|
||||||
|
this.errorMsg = error;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.tagService.addTag(this.nodeId, this.newTagName).subscribe(() => {
|
||||||
|
this.newTagName = '';
|
||||||
this.refreshTag();
|
this.refreshTag();
|
||||||
this.addEmitter.emit(this.nodeId);
|
this.addEmitter.emit(this.nodeId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
searchTag(searchTagName: string) {
|
||||||
|
if (this.tagsEntries) {
|
||||||
|
return this.tagsEntries.find((currentTag) => {
|
||||||
|
return (searchTagName === currentTag.entry.tag);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanErrorMsg() {
|
||||||
|
this.errorMsg = '';
|
||||||
|
}
|
||||||
|
|
||||||
removeTag(tag: string) {
|
removeTag(tag: string) {
|
||||||
this.tagService.removeTag(this.nodeId, tag).subscribe(() => {
|
this.tagService.removeTag(this.nodeId, tag).subscribe(() => {
|
||||||
this.refreshTag();
|
this.refreshTag();
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export class TagList {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param authService
|
* @param tagService
|
||||||
*/
|
*/
|
||||||
constructor(private tagService: TagService) {
|
constructor(private tagService: TagService) {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,12 +43,12 @@ export class TagNodeList {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param authService
|
* @param tagService
|
||||||
*/
|
*/
|
||||||
constructor(private tagService: TagService) {
|
constructor(private tagService: TagService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes) {
|
ngOnChanges() {
|
||||||
return this.refreshTag();
|
return this.refreshTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"TAG": {
|
||||||
|
"LABEL": {
|
||||||
|
"NEWTAG": "New Tag"
|
||||||
|
},
|
||||||
|
"MESSAGES": {
|
||||||
|
"EXIST":"Tag already exist"
|
||||||
|
},
|
||||||
|
"BUTTON": {
|
||||||
|
"ADD": "Add Tag"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"TAG": {
|
||||||
|
"LABEL": {
|
||||||
|
"NEWTAG": "Nuovo Tag"
|
||||||
|
},
|
||||||
|
"MESSAGES": {
|
||||||
|
"EXIST":"Tag già presente"
|
||||||
|
},
|
||||||
|
"BUTTON": {
|
||||||
|
"ADD": "Aggiungi Tag"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,17 +20,11 @@ import { Observable } from 'rxjs/Rx';
|
|||||||
import { AlfrescoApiService, LogService } from 'ng2-alfresco-core';
|
import { AlfrescoApiService, LogService } from 'ng2-alfresco-core';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {TagService} .
|
* @returns {TagService}
|
||||||
*/
|
*/
|
||||||
declare let __moduleName: string;
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class TagService {
|
export class TagService {
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
* @param apiService
|
|
||||||
*/
|
|
||||||
constructor(private apiService: AlfrescoApiService,
|
constructor(private apiService: AlfrescoApiService,
|
||||||
private logService: LogService) {
|
private logService: LogService) {
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user