-
-
+
+
+
+ {{errorMsg}}
+
-
diff --git a/ng2-components/ng2-alfresco-tag/src/components/tag-actions.component.spec.ts b/ng2-components/ng2-alfresco-tag/src/components/tag-actions.component.spec.ts
index cf0a1c9210..5c203504d7 100644
--- a/ng2-components/ng2-alfresco-tag/src/components/tag-actions.component.spec.ts
+++ b/ng2-components/ng2-alfresco-tag/src/components/tag-actions.component.spec.ts
@@ -153,5 +153,24 @@ describe('Test ng2-alfresco-tag Tag actions list', () => {
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
+ });
+ });
});
});
diff --git a/ng2-components/ng2-alfresco-tag/src/components/tag-actions.component.ts b/ng2-components/ng2-alfresco-tag/src/components/tag-actions.component.ts
index be67f17407..65880a2f33 100644
--- a/ng2-components/ng2-alfresco-tag/src/components/tag-actions.component.ts
+++ b/ng2-components/ng2-alfresco-tag/src/components/tag-actions.component.ts
@@ -17,6 +17,7 @@
import { Component, Input, Output, EventEmitter } from '@angular/core';
import { TagService } from './../services/tag.service';
+import { AlfrescoTranslationService } from 'ng2-alfresco-core';
/**
*
@@ -49,14 +50,15 @@ export class TagActionsComponent {
tagsEntries: any;
- /**
- * Constructor
- * @param authService
- */
- constructor(private tagService: TagService) {
+ errorMsg: string;
+
+ constructor(private tagService: TagService, private translateService: AlfrescoTranslationService) {
+ if (translateService) {
+ translateService.addTranslationFolder('ng2-alfresco-tag', 'node_modules/ng2-alfresco-tag/src');
+ }
}
- ngOnChanges(changes) {
+ ngOnChanges() {
return this.refreshTag();
}
@@ -68,12 +70,31 @@ export class TagActionsComponent {
}
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.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) {
this.tagService.removeTag(this.nodeId, tag).subscribe(() => {
this.refreshTag();
diff --git a/ng2-components/ng2-alfresco-tag/src/components/tag-list.component.ts b/ng2-components/ng2-alfresco-tag/src/components/tag-list.component.ts
index 7337f019df..3afe4187f6 100644
--- a/ng2-components/ng2-alfresco-tag/src/components/tag-list.component.ts
+++ b/ng2-components/ng2-alfresco-tag/src/components/tag-list.component.ts
@@ -39,7 +39,7 @@ export class TagList {
/**
* Constructor
- * @param authService
+ * @param tagService
*/
constructor(private tagService: TagService) {
}
diff --git a/ng2-components/ng2-alfresco-tag/src/components/tag-node-list.component.ts b/ng2-components/ng2-alfresco-tag/src/components/tag-node-list.component.ts
index a0f7fe134e..84d16b8c97 100644
--- a/ng2-components/ng2-alfresco-tag/src/components/tag-node-list.component.ts
+++ b/ng2-components/ng2-alfresco-tag/src/components/tag-node-list.component.ts
@@ -43,12 +43,12 @@ export class TagNodeList {
/**
* Constructor
- * @param authService
+ * @param tagService
*/
constructor(private tagService: TagService) {
}
- ngOnChanges(changes) {
+ ngOnChanges() {
return this.refreshTag();
}
diff --git a/ng2-components/ng2-alfresco-tag/src/i18n/en.json b/ng2-components/ng2-alfresco-tag/src/i18n/en.json
new file mode 100644
index 0000000000..3e21bd4646
--- /dev/null
+++ b/ng2-components/ng2-alfresco-tag/src/i18n/en.json
@@ -0,0 +1,13 @@
+{
+ "TAG": {
+ "LABEL": {
+ "NEWTAG": "New Tag"
+ },
+ "MESSAGES": {
+ "EXIST":"Tag already exist"
+ },
+ "BUTTON": {
+ "ADD": "Add Tag"
+ }
+ }
+}
diff --git a/ng2-components/ng2-alfresco-tag/src/i18n/it.json b/ng2-components/ng2-alfresco-tag/src/i18n/it.json
new file mode 100644
index 0000000000..6e3be152cb
--- /dev/null
+++ b/ng2-components/ng2-alfresco-tag/src/i18n/it.json
@@ -0,0 +1,13 @@
+{
+ "TAG": {
+ "LABEL": {
+ "NEWTAG": "Nuovo Tag"
+ },
+ "MESSAGES": {
+ "EXIST":"Tag giĆ presente"
+ },
+ "BUTTON": {
+ "ADD": "Aggiungi Tag"
+ }
+ }
+}
diff --git a/ng2-components/ng2-alfresco-tag/src/services/tag.service.ts b/ng2-components/ng2-alfresco-tag/src/services/tag.service.ts
index 72e77d221e..6027115b11 100644
--- a/ng2-components/ng2-alfresco-tag/src/services/tag.service.ts
+++ b/ng2-components/ng2-alfresco-tag/src/services/tag.service.ts
@@ -20,17 +20,11 @@ import { Observable } from 'rxjs/Rx';
import { AlfrescoApiService, LogService } from 'ng2-alfresco-core';
/**
- * @returns {TagService} .
+ * @returns {TagService}
*/
-declare let __moduleName: string;
-
@Injectable()
export class TagService {
- /**
- * Constructor
- * @param apiService
- */
constructor(private apiService: AlfrescoApiService,
private logService: LogService) {
}