Commit d00c6e8ca4933c16ee0cde7d6ecb26801528f6b1
Committed by
Victor Costa
1 parent
63a0a102
Exists in
master
and in
10 other branches
Added export comments button on comment paragraph plugin
Showing
7 changed files
with
85 additions
and
2 deletions
Show diff stats
src/app/index.ts
@@ -6,7 +6,7 @@ import {AuthEvents} from "./login/auth-events"; | @@ -6,7 +6,7 @@ import {AuthEvents} from "./login/auth-events"; | ||
6 | 6 | ||
7 | declare var moment: any; | 7 | declare var moment: any; |
8 | 8 | ||
9 | -//FIXME see a better way to declare template modules for dev mode | 9 | +// FIXME see a better way to declare template modules for dev mode |
10 | try { | 10 | try { |
11 | angular.module('noosfero.templates.app'); | 11 | angular.module('noosfero.templates.app'); |
12 | } catch (error) { | 12 | } catch (error) { |
src/plugins/comment_paragraph/hotspot/export-comment-button.component.spec.ts
0 → 100644
@@ -0,0 +1,52 @@ | @@ -0,0 +1,52 @@ | ||
1 | +import {ExportCommentButtonHotspotComponent} from "./export-comment-button.component"; | ||
2 | +import {ComponentTestHelper, createClass} from '../../../spec/component-test-helper'; | ||
3 | +import * as helpers from "../../../spec/helpers"; | ||
4 | +import {Provider} from 'ng-forward'; | ||
5 | +import {ComponentFixture} from 'ng-forward/cjs/testing/test-component-builder'; | ||
6 | + | ||
7 | +let htmlTemplate = '<export-comment-button-hotspot [article]="ctrl.article"></export-comment-button-hotspot>'; | ||
8 | + | ||
9 | +describe("Components", () => { | ||
10 | + describe("Export Comment Button Hotspot Component", () => { | ||
11 | + | ||
12 | + let serviceMock = jasmine.createSpyObj("CommentParagraphService", [ "getArticle" ]); | ||
13 | + | ||
14 | + let providers = [ new Provider('CommentParagraphService', { useValue: serviceMock }) ] | ||
15 | + .concat(helpers.provideFilters('translateFilter')); | ||
16 | + let helper: ComponentTestHelper<ExportCommentButtonHotspotComponent>; | ||
17 | + | ||
18 | + beforeEach(angular.mock.module("templates")); | ||
19 | + | ||
20 | + beforeEach((done) => { | ||
21 | + let cls = createClass({ | ||
22 | + template: htmlTemplate, | ||
23 | + directives: [ExportCommentButtonHotspotComponent], | ||
24 | + providers: providers, | ||
25 | + properties: { | ||
26 | + article: {} | ||
27 | + } | ||
28 | + }); | ||
29 | + helper = new ComponentTestHelper<ExportCommentButtonHotspotComponent>(cls, done); | ||
30 | + }); | ||
31 | + | ||
32 | + it('return true when comment paragraph is active', () => { | ||
33 | + helper.component.article = <noosfero.Article>{ setting: { comment_paragraph_plugin_activate: true } }; | ||
34 | + helper.detectChanges(); | ||
35 | + expect(helper.component.isActivated()).toBeTruthy(); | ||
36 | + expect(helper.all('.export-comment-button').length).toEqual(1); | ||
37 | + }); | ||
38 | + | ||
39 | + it('return false when comment paragraph is not active', () => { | ||
40 | + expect(helper.component.isActivated()).toBeFalsy(); | ||
41 | + expect(helper.all('.export-comment-button').length).toEqual(0); | ||
42 | + }); | ||
43 | + | ||
44 | + it('return false when article has no setting attribute', () => { | ||
45 | + helper.component.article = <noosfero.Article>{}; | ||
46 | + helper.detectChanges(); | ||
47 | + expect(helper.component.isActivated()).toBeFalsy(); | ||
48 | + expect(helper.all('.export-comment-button').length).toEqual(0); | ||
49 | + }); | ||
50 | + | ||
51 | + }); | ||
52 | +}); |
src/plugins/comment_paragraph/hotspot/export-comment-button.component.ts
0 → 100644
@@ -0,0 +1,23 @@ | @@ -0,0 +1,23 @@ | ||
1 | +import { Input, Inject, Component } from "ng-forward"; | ||
2 | +import {Hotspot} from "../../../app/hotspot/hotspot.decorator"; | ||
3 | +import {CommentParagraphService} from "../http/comment-paragraph.service"; | ||
4 | + | ||
5 | +@Component({ | ||
6 | + selector: "export-comment-button-hotspot", | ||
7 | + templateUrl: "plugins/comment_paragraph/hotspot/export-comment-button.html", | ||
8 | +}) | ||
9 | +@Inject(CommentParagraphService) | ||
10 | +@Hotspot("article_extra_toolbar_buttons") | ||
11 | +export class ExportCommentButtonHotspotComponent { | ||
12 | + | ||
13 | + @Input() article: noosfero.Article; | ||
14 | + exportCommentPath: any; | ||
15 | + | ||
16 | + constructor(private commentParagraphService: CommentParagraphService) { } | ||
17 | + | ||
18 | + isActivated() { | ||
19 | + this.exportCommentPath = ["/api/v1/articles/", this.article.id, "/comment_paragraph_plugin/export"].join(""); | ||
20 | + return this.article && this.article.setting && this.article.setting.comment_paragraph_plugin_activate; | ||
21 | + } | ||
22 | + | ||
23 | +} |
src/plugins/comment_paragraph/hotspot/export-comment-button.html
0 → 100644
src/plugins/comment_paragraph/index.ts
1 | import {AllowCommentComponent} from "./allow-comment/allow-comment.component"; | 1 | import {AllowCommentComponent} from "./allow-comment/allow-comment.component"; |
2 | +import {ExportCommentButtonHotspotComponent} from "./hotspot/export-comment-button.component"; | ||
2 | import {CommentParagraphFormHotspotComponent} from "./hotspot/comment-paragraph-form.component"; | 3 | import {CommentParagraphFormHotspotComponent} from "./hotspot/comment-paragraph-form.component"; |
3 | import {DiscussionEditorComponent} from "./article/cms/discussion-editor/discussion-editor.component"; | 4 | import {DiscussionEditorComponent} from "./article/cms/discussion-editor/discussion-editor.component"; |
4 | import {CommentParagraphArticleContentHotspotComponent} from "./hotspot/article-content/article-content.component"; | 5 | import {CommentParagraphArticleContentHotspotComponent} from "./hotspot/article-content/article-content.component"; |
5 | import {DiscussionBlockComponent} from "./block/discussion/discussion-block.component"; | 6 | import {DiscussionBlockComponent} from "./block/discussion/discussion-block.component"; |
6 | 7 | ||
7 | export let mainComponents: any = [AllowCommentComponent, DiscussionEditorComponent, DiscussionBlockComponent]; | 8 | export let mainComponents: any = [AllowCommentComponent, DiscussionEditorComponent, DiscussionBlockComponent]; |
8 | -export let hotspots: any = [CommentParagraphFormHotspotComponent, CommentParagraphArticleContentHotspotComponent]; | 9 | +export let hotspots: any = [ExportCommentButtonHotspotComponent, CommentParagraphFormHotspotComponent, CommentParagraphArticleContentHotspotComponent]; |
src/plugins/comment_paragraph/languages/en.json
1 | { | 1 | { |
2 | "comment-paragraph-plugin.title": "Paragraph Comments", | 2 | "comment-paragraph-plugin.title": "Paragraph Comments", |
3 | + "comment-paragraph-plugin.export": "Export Comments", | ||
3 | "comment-paragraph-plugin.discussion.editor.start_date.label": "From", | 4 | "comment-paragraph-plugin.discussion.editor.start_date.label": "From", |
4 | "comment-paragraph-plugin.discussion.editor.end_date.label": "To", | 5 | "comment-paragraph-plugin.discussion.editor.end_date.label": "To", |
5 | "comment-paragraph-plugin.discussion.header": "Open for comments", | 6 | "comment-paragraph-plugin.discussion.header": "Open for comments", |
src/plugins/comment_paragraph/languages/pt.json
1 | { | 1 | { |
2 | "comment-paragraph-plugin.title": "Comentários por Parágrafo", | 2 | "comment-paragraph-plugin.title": "Comentários por Parágrafo", |
3 | + "comment-paragraph-plugin.export": "Exportar Comentários", | ||
3 | "comment-paragraph-plugin.discussion.editor.start_date.label": "De", | 4 | "comment-paragraph-plugin.discussion.editor.start_date.label": "De", |
4 | "comment-paragraph-plugin.discussion.editor.end_date.label": "Até", | 5 | "comment-paragraph-plugin.discussion.editor.end_date.label": "Até", |
5 | "comment-paragraph-plugin.discussion.header": "Aberto para comentários", | 6 | "comment-paragraph-plugin.discussion.header": "Aberto para comentários", |