From 315b409789a62eb0c8230baff1bcafbfc0382bc0 Mon Sep 17 00:00:00 2001
From: Thomas Lenz <Thomas.Lenz@mni.thm.de>
Date: Sun, 8 Apr 2018 09:33:34 +0200
Subject: [PATCH] Add demo content to content-list

---
 .../content-list/content-list.component.ts    | 51 ++++++++++++++++++-
 .../content-carousel-page.component.ts        | 11 ++--
 src/app/services/http/content.service.ts      |  6 +++
 3 files changed, 60 insertions(+), 8 deletions(-)

diff --git a/src/app/components/fragments/content-list/content-list.component.ts b/src/app/components/fragments/content-list/content-list.component.ts
index b209b36a5..929dbe0da 100644
--- a/src/app/components/fragments/content-list/content-list.component.ts
+++ b/src/app/components/fragments/content-list/content-list.component.ts
@@ -2,6 +2,10 @@ import { Component, OnInit } from '@angular/core';
 import { ContentService } from '../../../services/http/content.service';
 import { Content } from '../../../models/content';
 import { ActivatedRoute } from '@angular/router';
+import { ContentChoice } from '../../../models/content-choice';
+import { ContentText } from '../../../models/content-text';
+import { AnswerOption } from '../../../models/answer-option';
+import { ContentType } from '../../../models/content-type.enum';
 
 @Component({
   selector: 'app-content-list',
@@ -9,7 +13,50 @@ import { ActivatedRoute } from '@angular/router';
   styleUrls: ['./content-list.component.scss']
 })
 export class ContentListComponent implements OnInit {
-  contents: Content[];
+  //  contents: Content[];
+  contents = [
+    new ContentChoice('0',
+      '1',
+      'roomId1',
+      'MultipleChoice Subject',
+      'MultipleChoice Body',
+      1,
+      [new AnswerOption('yes', ''), new AnswerOption('no', '')],
+      [],
+      true,
+      ContentType.CHOICE),
+    new ContentChoice('0',
+      '1',
+      'roomId2',
+      'SingleChoice Subject',
+      'SingleChoice Body',
+      1,
+      [new AnswerOption('may', ''), new AnswerOption('not', '')],
+      [],
+      false,
+      ContentType.BINARY),
+    new ContentText('1',
+      '1',
+      'roomId3',
+      'TextContent Subject',
+      'TextContent Body',
+      1),
+    new ContentChoice('0',
+      '1',
+      'roomId4',
+      'LikertContent Subject',
+      'LikertContent Body',
+      1,
+      [
+        new AnswerOption('Strongly agree', '0'),
+        new AnswerOption('Agree', '0'),
+        new AnswerOption('Neither agree nor disagree', '0'),
+        new AnswerOption('Disagree', '0' ),
+        new AnswerOption('Strongly disagree', '0') ],
+      [],
+      false,
+      ContentType.SCALE)
+  ];
 
   constructor(private contentService: ContentService,
               private route: ActivatedRoute) {
@@ -17,7 +64,7 @@ export class ContentListComponent implements OnInit {
 
   ngOnInit() {
     this.route.params.subscribe(params => {
-      this.getContents(params['roomId']);
+//      this.getContents(params['roomId']);
     });
   }
 
diff --git a/src/app/components/pages/content-carousel-page/content-carousel-page.component.ts b/src/app/components/pages/content-carousel-page/content-carousel-page.component.ts
index 3ba428262..c5a463782 100644
--- a/src/app/components/pages/content-carousel-page/content-carousel-page.component.ts
+++ b/src/app/components/pages/content-carousel-page/content-carousel-page.component.ts
@@ -14,7 +14,6 @@ import { ActivatedRoute } from '@angular/router';
 export class ContentCarouselPageComponent implements OnInit {
   ContentType: typeof ContentType = ContentType;
 
-  test = [1, 2];
 //  contents: Content[];
   contents = [
     new ContentChoice('0',
@@ -53,8 +52,8 @@ export class ContentCarouselPageComponent implements OnInit {
         new AnswerOption('Strongly agree', '0'),
         new AnswerOption('Agree', '0'),
         new AnswerOption('Neither agree nor disagree', '0'),
-        new AnswerOption('Disagree', '0' ),
-      new AnswerOption('Strongly disagree', '0') ],
+        new AnswerOption('Disagree', '0'),
+        new AnswerOption('Strongly disagree', '0')],
       [],
       false,
       ContentType.SCALE)
@@ -67,9 +66,9 @@ export class ContentCarouselPageComponent implements OnInit {
   ngOnInit() {
     this.route.params.subscribe(params => {
       // ToDo: Check api call
-/*      this.contentService.getContents(params['roomId']).subscribe(result => {
-        this.contents = result;
-      }); */
+      /*      this.contentService.getContents(params['roomId']).subscribe(result => {
+              this.contents = result;
+            }); */
     });
   }
 }
diff --git a/src/app/services/http/content.service.ts b/src/app/services/http/content.service.ts
index f41febbc1..2ffd5eba9 100644
--- a/src/app/services/http/content.service.ts
+++ b/src/app/services/http/content.service.ts
@@ -4,6 +4,7 @@ import { HttpClient, HttpHeaders } from '@angular/common/http';
 import { Observable } from 'rxjs/Observable';
 import { catchError, tap } from 'rxjs/operators';
 import { BaseHttpService } from './base-http.service';
+
 const httpOptions = {
   headers: new HttpHeaders({ 'Content-Type': 'application/json' })
 };
@@ -35,4 +36,9 @@ export class ContentService extends BaseHttpService {
       catchError(this.handleError<Content>(`getContent id=${contentId}`))
     );
   }
+
+  updateContent(content: Content) {
+    // ToDo: implement service, api call
+    console.log(content);
+  }
 }
-- 
GitLab