Commit 6b394e0b70f581b010d8cc3cc402fd62a55aa9fa
1 parent
7352b22a
Exists in
master
and in
26 other branches
Add component to edit comment paragraph discussions
Showing
9 changed files
with
106 additions
and
7 deletions
Show diff stats
src/app/article/article-default-view.component.ts
... | ... | @@ -43,7 +43,8 @@ export class ArticleViewComponent { |
43 | 43 | directiveName: string; |
44 | 44 | |
45 | 45 | ngOnInit() { |
46 | - let specificDirective = 'noosfero' + this.article.type; | |
46 | + let articleType = this.article.type.replace(/::/, ''); | |
47 | + let specificDirective = 'noosfero' + articleType; | |
47 | 48 | this.directiveName = "noosfero-default-article"; |
48 | 49 | if (this.$injector.has(specificDirective + 'Directive')) { |
49 | 50 | this.directiveName = specificDirective.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase(); | ... | ... |
src/app/article/cms/article-editor/article-editor.component.ts
... | ... | @@ -16,8 +16,7 @@ export class ArticleEditorComponent { |
16 | 16 | private $compile: ng.ICompileService) { } |
17 | 17 | |
18 | 18 | ngOnInit() { |
19 | - let articleType = this.article.type; | |
20 | - articleType = articleType.replace(/::/, ''); | |
19 | + let articleType = this.article.type.replace(/::/, ''); | |
21 | 20 | let specificDirective = `${articleType.charAt(0).toLowerCase()}${articleType.substring(1)}Editor`; |
22 | 21 | let directiveName = "article-basic-editor"; |
23 | 22 | if (this.$injector.has(specificDirective + 'Directive')) { | ... | ... |
src/lib/ng-noosfero-api/http/article.service.ts
... | ... | @@ -27,7 +27,13 @@ export class ArticleService extends RestangularService<noosfero.Article> { |
27 | 27 | 'Content-Type': 'application/json' |
28 | 28 | }; |
29 | 29 | let deferred = this.$q.defer<noosfero.RestResult<noosfero.Article>>(); |
30 | - let attributesToUpdate: any = { article: { name: article.name, body: article.body, published: article.published } }; | |
30 | + // TODO dynamically copy the selected attributes to update | |
31 | + let attributesToUpdate: any = { | |
32 | + article: { | |
33 | + name: article.name, body: article.body, published: article.published, | |
34 | + start_date: article['start_date'], end_date: article['end_date'] | |
35 | + } | |
36 | + }; | |
31 | 37 | let restRequest: ng.IPromise<noosfero.RestResult<noosfero.Article>> = this.getElement(article.id).customPOST(attributesToUpdate, null, null, headers); |
32 | 38 | restRequest.then(this.getHandleSuccessFunction(deferred)) |
33 | 39 | .catch(this.getHandleErrorFunction(deferred)); | ... | ... |
src/plugins/comment_paragraph/article/cms/discussion-editor/discussion-editor.component.ts
0 → 100644
... | ... | @@ -0,0 +1,39 @@ |
1 | +import {Component, Input, Inject} from 'ng-forward'; | |
2 | + | |
3 | +@Component({ | |
4 | + selector: 'comment-paragraph-plugin-discussion-editor', | |
5 | + templateUrl: "plugins/comment_paragraph/article/cms/discussion-editor/discussion-editor.html" | |
6 | +}) | |
7 | +@Inject("$scope") | |
8 | +export class DiscussionEditorComponent { | |
9 | + | |
10 | + @Input() article: noosfero.Article; | |
11 | + start_date: Date; | |
12 | + end_date: Date; | |
13 | + | |
14 | + constructor(private $scope: ng.IScope) { | |
15 | + this.convertDate('start_date'); | |
16 | + this.convertDate('end_date'); | |
17 | + } | |
18 | + | |
19 | + convertDate(attributeName: string) { | |
20 | + this.$scope.$watch(() => { | |
21 | + return this[attributeName]; | |
22 | + }, () => { | |
23 | + if (this[attributeName]) { | |
24 | + this.article[attributeName] = this[attributeName].toISOString(); | |
25 | + } | |
26 | + }); | |
27 | + } | |
28 | + | |
29 | + ngOnInit() { | |
30 | + if (this.article['start_date']) { | |
31 | + this.start_date = new Date(this.article['start_date']); | |
32 | + } else { | |
33 | + this.start_date = moment().toDate(); | |
34 | + } | |
35 | + if (this.article['end_date']) { | |
36 | + this.end_date = new Date(this.article['end_date']); | |
37 | + } | |
38 | + } | |
39 | +} | ... | ... |
src/plugins/comment_paragraph/article/cms/discussion-editor/discussion-editor.html
0 → 100644
... | ... | @@ -0,0 +1,35 @@ |
1 | +<form> | |
2 | + <div class="form-group"> | |
3 | + <label for="titleInput">{{"article.basic_editor.title" | translate}}</label> | |
4 | + <input type="text" class="form-control" id="titleInput" placeholder="{{'article.basic_editor.title' | translate}}" ng-model="ctrl.article.name"> | |
5 | + </div> | |
6 | + <div class="form-group"> | |
7 | + | |
8 | + <div class="form-inline"> | |
9 | + <span class="start-date discussion-date"> | |
10 | + <label for="startDateInput">{{"comment-paragraph-plugin.discussion.editor.start_date.label" | translate}}</label> | |
11 | + <input id="startDateInput" type="text" class="form-control" uib-datepicker-popup ng-model="ctrl.start_date" | |
12 | + is-open="startDateOpened" ng-required="true" close-text="Close" /> | |
13 | + <span class="input-group-btn date-popup-button"> | |
14 | + <button type="button" class="btn btn-default" ng-click="startDateOpened = true"> | |
15 | + <i class="fa fa-calendar fa-fw"></i> | |
16 | + </button> | |
17 | + </span> | |
18 | + </span> | |
19 | + <span class="end-date discussion-date"> | |
20 | + <label for="endDateInput">{{"comment-paragraph-plugin.discussion.editor.end_date.label" | translate}}</label> | |
21 | + <input id="endDateInput" type="text" class="form-control" uib-datepicker-popup ng-model="ctrl.end_date" | |
22 | + is-open="endDateOpened" ng-required="true" close-text="Close" /> | |
23 | + <span class="date-popup-button"> | |
24 | + <button type="button" class="btn btn-default" ng-click="endDateOpened = true"> | |
25 | + <i class="fa fa-calendar fa-fw"></i> | |
26 | + </button> | |
27 | + </span> | |
28 | + </span> | |
29 | + </div> | |
30 | + </div> | |
31 | + <div class="form-group"> | |
32 | + <label for="bodyInput">{{"article.basic_editor.body" | translate}}</label> | |
33 | + <html-editor [(value)]="ctrl.article.body"></html-editor> | |
34 | + </div> | |
35 | +</form> | ... | ... |
src/plugins/comment_paragraph/article/cms/discussion-editor/discussion.scss
0 → 100644
... | ... | @@ -0,0 +1,14 @@ |
1 | +comment-paragraph-plugin-discussion-editor { | |
2 | + .discussion-date { | |
3 | + [uib-datepicker-popup-wrap] { | |
4 | + display: inline-block; | |
5 | + } | |
6 | + .date-popup-button { | |
7 | + @extend .input-group-btn; | |
8 | + display: inline-block; | |
9 | + } | |
10 | + } | |
11 | + .end-date { | |
12 | + margin-left: 60px; | |
13 | + } | |
14 | +} | ... | ... |
src/plugins/comment_paragraph/index.ts
1 | 1 | import {AllowCommentComponent} from "./allow-comment/allow-comment.component"; |
2 | 2 | import {CommentParagraphArticleButtonHotspotComponent} from "./hotspot/comment-paragraph-article-button.component"; |
3 | 3 | import {CommentParagraphFormHotspotComponent} from "./hotspot/comment-paragraph-form.component"; |
4 | +import {DiscussionEditorComponent} from "./article/cms/discussion-editor/discussion-editor.component"; | |
4 | 5 | |
5 | -export let mainComponents: any = [AllowCommentComponent]; | |
6 | +export let mainComponents: any = [AllowCommentComponent, DiscussionEditorComponent]; | |
6 | 7 | export let hotspots: any = [CommentParagraphArticleButtonHotspotComponent, CommentParagraphFormHotspotComponent]; | ... | ... |
src/plugins/comment_paragraph/languages/en.json
src/plugins/comment_paragraph/languages/pt.json