Commit 36e4d9d9e43a6891908db0c22b16d2644d3aa0c9
Exists in
master
and in
10 other branches
Merge branch 'export-comments' into 'master'
Export comments Incorporado o botão de exportar comentários. See merge request !40
Showing
7 changed files
with
91 additions
and
2 deletions
Show diff stats
src/app/index.ts
... | ... | @@ -6,7 +6,7 @@ import {AuthEvents} from "./login/auth-events"; |
6 | 6 | |
7 | 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 | 10 | try { |
11 | 11 | angular.module('noosfero.templates.app'); |
12 | 12 | } catch (error) { | ... | ... |
src/plugins/comment_paragraph/hotspot/export-comment-button.component.spec.ts
0 → 100644
... | ... | @@ -0,0 +1,58 @@ |
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 | +import {PermissionDirective} from '../../../app/shared/components/permission/permission.directive'; | |
7 | + | |
8 | +let htmlTemplate = '<export-comment-button-hotspot [article]="ctrl.article"></export-comment-button-hotspot>'; | |
9 | + | |
10 | +describe("Components", () => { | |
11 | + describe("Export Comment Button Hotspot Component", () => { | |
12 | + | |
13 | + let serviceMock = jasmine.createSpyObj("CommentParagraphService", ["getArticle"]); | |
14 | + | |
15 | + let providers = [new Provider('CommentParagraphService', { useValue: serviceMock })] | |
16 | + .concat(helpers.provideFilters('translateFilter')); | |
17 | + let helper: ComponentTestHelper<ExportCommentButtonHotspotComponent>; | |
18 | + | |
19 | + beforeEach(angular.mock.module("templates")); | |
20 | + | |
21 | + beforeEach((done) => { | |
22 | + let cls = createClass({ | |
23 | + template: htmlTemplate, | |
24 | + directives: [ExportCommentButtonHotspotComponent, PermissionDirective], | |
25 | + providers: providers, | |
26 | + properties: { | |
27 | + article: {} | |
28 | + } | |
29 | + }); | |
30 | + helper = new ComponentTestHelper<ExportCommentButtonHotspotComponent>(cls, done); | |
31 | + }); | |
32 | + | |
33 | + it('return true when comment paragraph is active', () => { | |
34 | + helper.component.article = <noosfero.Article>{ setting: { comment_paragraph_plugin_activate: true } }; | |
35 | + helper.detectChanges(); | |
36 | + expect(helper.component.isActivated()).toBeTruthy(); | |
37 | + expect(helper.all('.export-comment-button').length).toEqual(1); | |
38 | + }); | |
39 | + | |
40 | + it('return false when comment paragraph is not active', () => { | |
41 | + expect(helper.component.isActivated()).toBeFalsy(); | |
42 | + expect(helper.all('.export-comment-button').length).toEqual(0); | |
43 | + }); | |
44 | + | |
45 | + it('return false when article has no setting attribute', () => { | |
46 | + helper.component.article = <noosfero.Article>{}; | |
47 | + helper.detectChanges(); | |
48 | + expect(helper.component.isActivated()).toBeFalsy(); | |
49 | + expect(helper.all('.export-comment-button').length).toEqual(0); | |
50 | + }); | |
51 | + | |
52 | + it('not display export comment button when user does not have permission', () => { | |
53 | + helper.component.article = <noosfero.Article>{ setting: { comment_paragraph_plugin_activate: true } }; | |
54 | + helper.detectChanges(); | |
55 | + expect(helper.find('.export-comment-button').attr('style')).toEqual("display: none; "); | |
56 | + }); | |
57 | + }); | |
58 | +}); | ... | ... |
src/plugins/comment_paragraph/hotspot/export-comment-button.component.ts
0 → 100644
... | ... | @@ -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
... | ... | @@ -0,0 +1,5 @@ |
1 | +<a href='{{ctrl.exportCommentPath}}' target="_self" | |
2 | + class="btn btn-default btn-xs export-comment-button" ng-if="ctrl.isActivated()" | |
3 | + permission="ctrl.article.permissions" permission-action="allow_edit"> | |
4 | + <i class="fa fa-fw fa-download"></i> {{"comment-paragraph-plugin.export" | translate}} | |
5 | +</a> | ... | ... |
src/plugins/comment_paragraph/index.ts
1 | 1 | import {AllowCommentComponent} from "./allow-comment/allow-comment.component"; |
2 | +import {ExportCommentButtonHotspotComponent} from "./hotspot/export-comment-button.component"; | |
2 | 3 | import {CommentParagraphFormHotspotComponent} from "./hotspot/comment-paragraph-form.component"; |
3 | 4 | import {DiscussionEditorComponent} from "./article/cms/discussion-editor/discussion-editor.component"; |
4 | 5 | import {CommentParagraphArticleContentHotspotComponent} from "./hotspot/article-content/article-content.component"; |
5 | 6 | import {DiscussionBlockComponent} from "./block/discussion/discussion-block.component"; |
6 | 7 | |
7 | 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 | 2 | "comment-paragraph-plugin.title": "Paragraph Comments", |
3 | + "comment-paragraph-plugin.export": "Export Comments", | |
3 | 4 | "comment-paragraph-plugin.discussion.editor.start_date.label": "From", |
4 | 5 | "comment-paragraph-plugin.discussion.editor.end_date.label": "To", |
5 | 6 | "comment-paragraph-plugin.discussion.header": "Open for comments", | ... | ... |
src/plugins/comment_paragraph/languages/pt.json
1 | 1 | { |
2 | 2 | "comment-paragraph-plugin.title": "Comentários por Parágrafo", |
3 | + "comment-paragraph-plugin.export": "Exportar Comentários", | |
3 | 4 | "comment-paragraph-plugin.discussion.editor.start_date.label": "De", |
4 | 5 | "comment-paragraph-plugin.discussion.editor.end_date.label": "Até", |
5 | 6 | "comment-paragraph-plugin.discussion.header": "Aberto para comentários", | ... | ... |