Blame view

src/pages/Dashboard/CourseDiscussionForum.vue 25.9 KB
fe15ee8b4   Amber Dev   added course chap...
1
  <template>
6f7cf8cf5   Amber Dev   added discussion ...
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
    <div class="body-color">
      <!-- LOADER -->
      <div class="loader" v-if="showLoader">
        <v-progress-circular indeterminate color="white"></v-progress-circular>
      </div>
  
      <!-- SNACKBAR -->
      <v-snackbar
        :timeout="timeout"
        :top="y === 'top'"
        :right="x === 'right'"
        :vertical="mode === 'vertical'"
        v-model="snackbar"
        :color="snackbarColor"
      >
        {{ text }}
        <v-spacer></v-spacer>
        <v-btn flat text @click="snackbar = false">X</v-btn>
      </v-snackbar>
  
      <!-- DIALOG TO ADD COURSE DISCUSSION FORUM -->
      <v-dialog v-model="addForumDialog" max-width="500" persistent>
        <v-card flat class="card-style pa-2" dark>
          <v-layout>
            <v-flex xs12>
              <label class="title text-xs-center">Add Forum</label>
              <v-icon size="24" class="right" @click="addForumDialog = false">cancel</v-icon>
            </v-flex>
          </v-layout>
          <v-container fluid>
            <v-layout align-center>
              <v-flex xs12>
                <v-flex xs12 sm12>
                  <v-form ref="form" v-model="valid" lazy-validation>
                    <v-layout>
                      <v-flex
                        xs12
                        class="text-xs-center text-sm-center text-md-center text-lg-center"
                      >
                        <v-avatar size="100px" v-if="!imageUrl">
                          <img src="/static/icon/user.png" />
                        </v-avatar>
                        <input
                          type="file"
                          style="display: none"
                          ref="image"
                          accept="image/*"
                          @change="onFilePicked"
                        />
                        <img
                          :src="imageData.imageUrl"
                          height="150"
                          width="150"
                          v-if="imageUrl"
                          style="border-radius:50%; width:200px"
                        />
                      </v-flex>
                    </v-layout>
  
                    <v-layout wrap>
                      <!-- SUBJECT -->
                      <v-flex xs12 sm12>
                        <v-layout>
                          <v-flex xs4 sm4 class="pt-4 subheading">
                            <label class="right hidden-xs-only hidden-sm-only">Subject:</label>
                            <label class="right hidden-lg-only hidden-md-only hidden-xl-only">Subject:</label>
                          </v-flex>
                          <v-flex xs8 sm8 class="ml-3">
                            <v-text-field
                              v-model="addForumParams.subject"
                              placeholder="subject"
                              type="text"
                              :rules="cantBeEmpty"
                              required
                            ></v-text-field>
                          </v-flex>
                        </v-layout>
                      </v-flex>
                      <!-- DESCRIPTION -->
                      <v-flex xs12 sm12>
                        <v-layout>
                          <v-flex xs4 sm4 class="pt-4 subheading">
                            <label class="right hidden-xs-only hidden-sm-only">Description:</label>
                            <label
                              class="right hidden-lg-only hidden-md-only hidden-xl-only"
                            >Description:</label>
                          </v-flex>
                          <v-flex xs8 sm8 class="ml-3">
                            <v-text-field
                              v-model="addForumParams.description"
                              placeholder="Description"
                              type="text"
                              :rules="cantBeEmpty"
                              required
                            ></v-text-field>
                          </v-flex>
                        </v-layout>
                      </v-flex>
                      <!-- UPLOAD IMAGE -->
                      <v-flex xs12 sm12>
                        <v-layout>
                          <v-flex xs4 class="pt-4 subheading">
                            <label class="right hidden-xs-only hidden-sm-only">Upload Image:</label>
                            <label class="right hidden-lg-only hidden-md-only hidden-xl-only">Upload :</label>
                          </v-flex>
                          <v-flex xs8 class="ml-3">
                            <v-text-field
                              label="Select Image"
                              @click="pickFile"
                              v-model="imageName"
                              append-icon="attach_file"
                            ></v-text-field>
                          </v-flex>
                        </v-layout>
                      </v-flex>
                    </v-layout>
                    <v-layout>
                      <v-flex xs12 sm12>
                        <v-layout class="right">
                          <v-btn @click="submit" round dark :loading="loading" class="add-button">Add</v-btn>
                        </v-layout>
                      </v-flex>
                    </v-layout>
                  </v-form>
                </v-flex>
              </v-flex>
            </v-layout>
          </v-container>
        </v-card>
      </v-dialog>
  
      <v-container grid-list-xl class="pt-0">
f87ff3ba5   Amber Dev   cleared bugs
134
135
        <v-layout row wrap class="mt-1">
          <v-flex xs12 sm12 md9>
6f7cf8cf5   Amber Dev   added discussion ...
136
137
138
139
140
141
            <v-layout column>
              <!-- HEADING -->
              <v-flex>
                <div class="title side-bar-color font-weight-bold">Course Discussion Forum</div>
                <div class="subheading grey--text lighten-1">General news and announcements</div>
              </v-flex>
fe15ee8b4   Amber Dev   added course chap...
142

6f7cf8cf5   Amber Dev   added discussion ...
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
              <!-- ADD DISCUSSION FORUM BUTTON -->
              <v-flex>
                <div>
                  <v-btn
                    fab
                    dark
                    class="open-dialog-button hidden-xl-only hidden-md-only hidden-lg-only"
                    small
                    @click="addForumDialog = true"
                  >
                    <v-icon dark>add</v-icon>
                  </v-btn>
                  <v-btn
                    round
                    class="open-dialog-button hidden-sm-only hidden-xs-only"
                    dark
                    @click="addForumDialog = true"
                  >
                    <v-icon class="white--text pr-1" size="20">add</v-icon>Add A New Discussion Topic
                  </v-btn>
                </div>
              </v-flex>
7977f606e   Amber Dev   unknown change
165
166
  
              <!-- DATA TABLE -->
0a5256600   Amber Dev   added events
167
168
169
170
171
172
              <v-flex>
                <v-data-table
                  :headers="courseDiscussionHeaders"
                  :items="courseDiscussionItems"
                  :pagination.sync="pagination"
                  :search="search"
a8bd267e9   Amber Dev   added course disc...
173
                  item-key="_id"
0a5256600   Amber Dev   added events
174
175
                >
                  <template slot="items" slot-scope="props">
a8bd267e9   Amber Dev   added course disc...
176
177
                    <tr
                      class="tr"
c6602f75d   Amber Dev   working on live d...
178
                      style="cursor: pointer;"
a8bd267e9   Amber Dev   added course disc...
179
180
181
182
183
184
185
186
                      @click="props.expanded = !props.expanded;courseDiscussionId = props.item._id;getDiscussionesThread(props.item._id)"
                    >
                      <td class="text-xs-center td td-row">
                        <v-avatar size="40">
                          <img :src="props.item.attachementUrl" v-if="props.item.attachementUrl" />
                          <img src="/static/icon/user.png" v-else-if="!props.item.attachementUrl" />
                        </v-avatar>
                      </td>
f87ff3ba5   Amber Dev   cleared bugs
187
                      <td class="td td-row text-xs-center">{{ props.item.subject}}</td>
0a5256600   Amber Dev   added events
188
                      <td class="td td-row text-xs-center">{{ props.item.studentId.name }}</td>
f87ff3ba5   Amber Dev   cleared bugs
189
190
                      <td class="td td-row text-xs-center">-</td>
                      <td class="td td-row text-xs-center">{{ props.item.forumThread.length }}</td>
0a5256600   Amber Dev   added events
191
192
                    </tr>
                  </template>
e91641fe5   Amber Dev   solved bugs
193
                  <!-- REPLY FUNCTIONALITY -->
a8bd267e9   Amber Dev   added course disc...
194
195
                  <template slot="expand" slot-scope="props">
                    <v-layout>
6cafeef21   Amber Dev   solved bugs lst
196
                      <!-- TOPIC HEADING -->
a8bd267e9   Amber Dev   added course disc...
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
                      <v-flex xs12 v-for="(courseDiscussionData,i) in courseDiscussionData" :key="i">
                        <v-card class="elevation-0 grey lighten-3 pa-2" flat>
                          <v-list two-line subheader>
                            <v-list-tile>
                              <v-list-tile-avatar>
                                <v-avatar size="46">
                                  <img
                                    :src="courseDiscussionData.attachementUrl"
                                    v-if="courseDiscussionData.attachementUrl"
                                  />
                                  <img
                                    src="/static/icon/user.png"
                                    v-else-if="!courseDiscussionData.attachementUrl"
                                  />
                                </v-avatar>
                              </v-list-tile-avatar>
                              <v-list-tile-content>
                                <v-list-tile-title>{{ courseDiscussionData.subject }}</v-list-tile-title>
                                <v-list-tile-sub-title>
                                  By
                                  <span class="info--text">{{ courseDiscussionData.studentId.name }}</span>
                                  - {{dates(courseDiscussionData.created ) }}
                                </v-list-tile-sub-title>
                              </v-list-tile-content>
                              <v-list-tile-action>
                                <div>
                                  <v-btn
                                    flat
                                    round
                                    dark
                                    class="reply-btn"
                                    @click="showReplyBox = true"
                                  >Reply</v-btn>
                                </div>
                              </v-list-tile-action>
                            </v-list-tile>
                          </v-list>
                        </v-card>
                        <v-flex xs12 class="mt-4" v-show="showReplyBox">
                          <v-textarea
                            name="input-7-1"
                            solo
                            label="Label Text"
                            multi-line
                            v-model="replyDescription"
                          ></v-textarea>
                          <v-btn
                            round
                            dark
                            class="open-dialog-button"
                            flat
                            @click="showReplyBox = false"
                          >Cancel</v-btn>
                          <v-btn
                            round
                            dark
                            :loading="loading"
                            class="reply-btn"
                            @click="replyThreadDiscussion(props.item)"
                          >Submit</v-btn>
                        </v-flex>
e91641fe5   Amber Dev   solved bugs
258
259
260
  
                        <!-- REPLY THREAD -->
                        <v-layout
8ac91bfcd   Amber Dev   added changes to ...
261
                          :class="['mt-4','pl-5','mx-auto',replyThread.teacherId?'justify-start':'justify-end']"
e91641fe5   Amber Dev   solved bugs
262
                          v-for="(replyThread,i) in courseDiscussionData.forumThread.slice().reverse()"
a8bd267e9   Amber Dev   added course disc...
263
264
                          :key="i"
                        >
e91641fe5   Amber Dev   solved bugs
265
                          <v-flex xs12 md7>
8ac91bfcd   Amber Dev   added changes to ...
266
267
                            <v-card class="elevation-0 grey lighten-1" flat>
                              <v-list two-line subheader class="grey lighten-1 pa-1">
e91641fe5   Amber Dev   solved bugs
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
                                <v-list-tile>
                                  <v-list-tile-avatar>
                                    <v-avatar size="46">
                                      <img
                                        :src="courseDiscussionData.attachementUrl"
                                        v-if="courseDiscussionData.attachementUrl"
                                      />
                                      <img
                                        src="/static/icon/user.png"
                                        v-else-if="!courseDiscussionData.attachementUrl"
                                      />
                                    </v-avatar>
                                  </v-list-tile-avatar>
                                  <v-list-tile-content>
                                    <v-list-tile-title>Re: {{ courseDiscussionData.subject }}</v-list-tile-title>
                                    <v-list-tile-sub-title>
                                      By
                                      <span
                                        class="info--text"
                                        v-if="replyThread.studentId"
                                      >{{ replyThread.studentId.name }}</span>
                                      <span
                                        class="info--text"
                                        v-if="replyThread.teacherId"
                                      >{{ replyThread.teacherId.name }}</span>
                                      - {{dates(replyThread.created ) }}
                                    </v-list-tile-sub-title>
                                  </v-list-tile-content>
                                </v-list-tile>
                              </v-list>
                              <v-list class="pa-2 reply-desc">
a8bd267e9   Amber Dev   added course disc...
299
                                <v-list-tile-content>
e91641fe5   Amber Dev   solved bugs
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
                                  <v-list-tile-title
                                    v-show="replyThread.showDescriptionReplyThread"
                                  >{{ replyThread.description }}</v-list-tile-title>
                                  <v-flex
                                    xs12
                                    sm12
                                    md4
                                    v-show="replyThread.showUpdateReplyThread == true"
                                  >
                                    <v-text-field v-model="replyThread.description"></v-text-field>
                                    <v-btn
                                      flat
                                      round
                                      dark
                                      class="reply-btn right"
                                      @click="updateRelpyThreadDiscussion(replyThread,props.item)"
                                    >Save</v-btn>
                                  </v-flex>
a8bd267e9   Amber Dev   added course disc...
318
                                </v-list-tile-content>
e91641fe5   Amber Dev   solved bugs
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
                              </v-list>
                              <v-list class="grey lighten-4 pa-0">
                                <v-list-tile-action>
                                  <v-spacer></v-spacer>
                                  <div
                                    v-if="replyThread.studentId && replyThread.studentId._id == localStorage.getItem('parentStudentId')"
                                  >
                                    <v-btn
                                      flat
                                      round
                                      dark
                                      class="reply-btn"
                                      @click="deleteRelpyThreadDiscussion(replyThread._id,props.item._id)"
                                    >Delete</v-btn>
                                    <v-btn
                                      flat
                                      round
                                      dark
                                      class="reply-btn mr-4"
                                      @click="showUpdateReplyThreadDiscussion(replyThread)"
                                    >Edit</v-btn>
                                  </div>
                                </v-list-tile-action>
                              </v-list>
                            </v-card>
                          </v-flex>
                        </v-layout>
a8bd267e9   Amber Dev   added course disc...
346
347
348
                      </v-flex>
                    </v-layout>
                  </template>
0a5256600   Amber Dev   added events
349
350
351
352
353
354
355
356
                  <v-alert
                    slot="no-results"
                    :value="true"
                    color="error"
                    icon="warning"
                  >Your search for "{{ search }}" found no results.</v-alert>
                </v-data-table>
              </v-flex>
6f7cf8cf5   Amber Dev   added discussion ...
357
            </v-layout>
fe15ee8b4   Amber Dev   added course chap...
358
359
360
361
362
          </v-flex>
  
          <v-spacer></v-spacer>
  
          <!-- COURSES - positioned to the right of the page -->
f87ff3ba5   Amber Dev   cleared bugs
363
          <v-flex xs12 sm12 md3>
fe15ee8b4   Amber Dev   added course chap...
364
365
366
367
368
            <v-card class="elevation-0 card-border" height="100%">
              <v-container class="pt-0">
                <div class="side-bar-color font-weight-bold title">Courses</div>
  
                <div v-for="(course,index) in courseData">
6f7cf8cf5   Amber Dev   added discussion ...
369
370
371
372
373
374
375
376
377
                  <v-btn
                    flat
                    class="subheading text-xs-start justify-left"
                    style="cursor: pointer;"
                    block
                    @click="routeToCourseDetails(course._id)"
                  >
                    <div style="width: 100%;text-align: left;">
                      <v-icon style="color: red;padding-bottom: 3px;" size="15">play_arrow</v-icon>
0a5256600   Amber Dev   added events
378
                      {{course.courseName}}
6f7cf8cf5   Amber Dev   added discussion ...
379
380
                    </div>
                  </v-btn>
fe15ee8b4   Amber Dev   added course chap...
381
382
383
384
385
386
                </div>
              </v-container>
            </v-card>
          </v-flex>
        </v-layout>
      </v-container>
fe15ee8b4   Amber Dev   added course chap...
387
388
    </div>
  </template>
6f7cf8cf5   Amber Dev   added discussion ...
389
390
391
  <script>
  import AllApiCalls from "@/Services/AllApiCalls.js";
  import http from "@/Services/http.js";
a8bd267e9   Amber Dev   added course disc...
392
  import moment from "moment";
6f7cf8cf5   Amber Dev   added discussion ...
393
394
395
396
  export default {
    mixins: [AllApiCalls],
    data() {
      return {
0bb8c9148   Amber Dev   solved bugs in di...
397
        localStorage: localStorage,
6f7cf8cf5   Amber Dev   added discussion ...
398
399
400
401
402
403
404
        valid: true,
        addForumDialog: false,
        addForumParams: {},
        // UPLOAD IMAGE
        imageName: "",
        imageUrl: "",
        imageFile: "",
0a5256600   Amber Dev   added events
405
406
407
408
409
        imageData: {},
  
        // DATA TABLE
        search: "",
        pagination: {
860da881d   Shikha Mishra   comment all consoles
410
          rowsPerPage: 10,
0a5256600   Amber Dev   added events
411
412
413
        },
        courseDiscussionHeaders: [
          {
a8bd267e9   Amber Dev   added course disc...
414
415
416
            text: "Image",
            value: "attachementUrl",
            sortable: false,
860da881d   Shikha Mishra   comment all consoles
417
            align: "center",
a8bd267e9   Amber Dev   added course disc...
418
419
          },
          {
0a5256600   Amber Dev   added events
420
            text: "Discussion",
f87ff3ba5   Amber Dev   cleared bugs
421
            align: "center",
0a5256600   Amber Dev   added events
422
            sortable: false,
860da881d   Shikha Mishra   comment all consoles
423
            value: "",
0a5256600   Amber Dev   added events
424
425
426
427
428
          },
          {
            text: "Started",
            value: "",
            sortable: false,
860da881d   Shikha Mishra   comment all consoles
429
            align: "center",
0a5256600   Amber Dev   added events
430
431
          },
          { text: "Last Pot", value: "", sortable: false, align: "center" },
860da881d   Shikha Mishra   comment all consoles
432
          { text: "Replies", value: "", sortable: false, align: "center" },
0a5256600   Amber Dev   added events
433
        ],
a8bd267e9   Amber Dev   added course disc...
434
435
436
437
438
439
440
441
        courseDiscussionItems: [],
  
        // COURSE DISCUSSION REPLTY FUNCTIONALITY
        courseDiscussionId: "",
        showReplyBox: false,
        courseDiscussionData: [],
        replyDescription: "",
        loginId: "",
860da881d   Shikha Mishra   comment all consoles
442
        editedIndex: -1,
6f7cf8cf5   Amber Dev   added discussion ...
443
444
445
      };
    },
    methods: {
860da881d   Shikha Mishra   comment all consoles
446
      dates: function (date) {
a8bd267e9   Amber Dev   added course disc...
447
448
        return moment(date).format("MMMM DD, YYYY hh:mm A");
      },
6f7cf8cf5   Amber Dev   added discussion ...
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
      /* UPLOAD IMAGE */
      pickFile() {
        this.$refs.image.click();
      },
  
      onFilePicked(e) {
        // console.log(e)
        const files = e.target.files;
        this.imageData.upload = e.target.files[0];
        if (files[0] !== undefined) {
          this.imageName = files[0].name;
          if (this.imageName.lastIndexOf(".") <= 0) {
            return;
          }
          const fr = new FileReader();
          fr.readAsDataURL(files[0]);
          fr.addEventListener("load", () => {
            this.imageUrl = fr.result;
            this.imageFile = files[0]; // this is an image file that can be sent to server...
            this.imageData.imageUrl = URL.createObjectURL(this.imageFile);
          });
        } else {
          this.imageName = "";
          this.imageFile = "";
          this.imageUrl = "";
        }
      },
3f7b85167   Amber Dev   added announcements
476
      async submit() {
6f7cf8cf5   Amber Dev   added discussion ...
477
478
479
480
481
482
483
484
485
486
487
        if (this.$refs.form.validate()) {
          this.addForumParams.classId = localStorage.getItem("parentClassId");
          this.addForumParams.courseId = this.$route.query.courseId;
          this.addForumParams.studentId = localStorage.getItem("parentStudentId");
  
          if (this.imageUrl) {
            var str = this.imageUrl;
            const [baseUrl, imageUrl] = str.split(/,/);
            this.addForumParams.upload = imageUrl;
          }
          this.loading = true;
f87ff3ba5   Amber Dev   cleared bugs
488
          await http()
6f7cf8cf5   Amber Dev   added discussion ...
489
            .post("/createCourseDiscussion", this.addForumParams)
860da881d   Shikha Mishra   comment all consoles
490
            .then((response) => {
6f7cf8cf5   Amber Dev   added discussion ...
491
492
493
494
495
496
              this.snackbar = true;
              this.text = "Discussion added successfully";
              this.snackbarColor = "green";
              this.addForumDialog = false;
              this.clear();
              this.loading = false;
860da881d   Shikha Mishra   comment all consoles
497
              // console.log("response of createCourseDiscussion - ", response);
6f7cf8cf5   Amber Dev   added discussion ...
498
            })
860da881d   Shikha Mishra   comment all consoles
499
            .catch((error) => {
6f7cf8cf5   Amber Dev   added discussion ...
500
501
              this.snackbar = true;
              this.text = error.response.data.message;
f8968b6fb   Amber Dev   pull from master
502
              this.snackbarColor = "error";
6f7cf8cf5   Amber Dev   added discussion ...
503
504
              this.loading = false;
            });
f87ff3ba5   Amber Dev   cleared bugs
505

3f7b85167   Amber Dev   added announcements
506
507
508
          /* getCourseDiscussionesList - to populate the data table */
          await this.getCourseDiscussionesList({
            courseId: this.$route.query.courseId,
860da881d   Shikha Mishra   comment all consoles
509
            classId: localStorage.getItem("parentClassId"),
3f7b85167   Amber Dev   added announcements
510
511
          });
          this.addForumDialog = false;
6f7cf8cf5   Amber Dev   added discussion ...
512
513
514
515
516
517
518
519
520
521
522
523
524
525
        }
      },
      clear() {
        this.$refs.form.reset();
        this.imageUrl = "";
      },
      async routeToCourseDetails(courseId) {
        /* getParticularCourseDetail- To get courseDetail - defined in GetApis.js*/
        let response = await this.getParticularCourseDetail(courseId);
  
        /* If the response is null then dont route */
        if (response.data.data.length > 0) {
          this.$router.push({
            name: "Course Details",
860da881d   Shikha Mishra   comment all consoles
526
            query: { courseId: courseId },
6f7cf8cf5   Amber Dev   added discussion ...
527
528
529
530
          });
        } else {
          this.seeSnackbar("No Data Available", "warning");
        }
a8bd267e9   Amber Dev   added course disc...
531
532
533
534
535
536
537
538
539
540
      },
  
      // COURSE DISCUSSION REPLY FUNCTIONALITY
  
      getDiscussionesThread() {
        // console.log("id", this.getSelectedData.courseId);
        this.showLoader = true;
        http()
          .get("/getParticularCourseDiscussion", {
            params: {
860da881d   Shikha Mishra   comment all consoles
541
542
              courseDiscussionId: this.courseDiscussionId,
            },
a8bd267e9   Amber Dev   added course disc...
543
          })
860da881d   Shikha Mishra   comment all consoles
544
          .then((response) => {
a8bd267e9   Amber Dev   added course disc...
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
            //   console.log("response", response.data.data);
            this.courseDiscussionData = response.data.data;
            for (let i = 0; i < this.courseDiscussionData.length; i++) {
              for (
                let j = 0;
                j < this.courseDiscussionData[i].forumThread.length;
                j++
              ) {
                this.courseDiscussionData[i].forumThread[
                  j
                ].showUpdateReplyThread = false;
                this.courseDiscussionData[i].forumThread[
                  j
                ].showDescriptionReplyThread = true;
              }
            }
            this.showLoader = false;
            this.showReplyBox = false;
          })
860da881d   Shikha Mishra   comment all consoles
564
565
          .catch((error) => {
            //   console.log("err====>", error);
a8bd267e9   Amber Dev   added course disc...
566
            this.showLoader = false;
860da881d   Shikha Mishra   comment all consoles
567
568
569
            this.snackbar = true;
            this.color = "error";
            this.text = error.response.data.message;
a8bd267e9   Amber Dev   added course disc...
570
571
572
573
574
575
          });
      },
      replyThreadDiscussion(selected) {
        this.showLoader = true;
        var payloadData = {
          courseDiscussionId: selected._id,
0bb8c9148   Amber Dev   solved bugs in di...
576
          studentId: localStorage.getItem("parentStudentId"),
860da881d   Shikha Mishra   comment all consoles
577
          description: this.replyDescription,
a8bd267e9   Amber Dev   added course disc...
578
579
580
        };
        http()
          .put("/replyForumThread", payloadData)
860da881d   Shikha Mishra   comment all consoles
581
          .then((response) => {
a8bd267e9   Amber Dev   added course disc...
582
583
584
585
            //   console.log("response", response.data.data);
            this.showLoader = false;
            this.getDiscussionesThread();
          })
860da881d   Shikha Mishra   comment all consoles
586
          .catch((error) => {
a8bd267e9   Amber Dev   added course disc...
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
            this.showLoader = false;
          });
      },
      showUpdateReplyThreadDiscussion(item) {
        this.editedIndex = this.courseDiscussionData.indexOf(item);
        var editedItem = Object.assign({}, item);
        var arrayOfcourseDiscussionData = [];
        for (let i = 0; i < this.courseDiscussionData.length; i++) {
          for (
            let j = 0;
            j < this.courseDiscussionData[i].forumThread.length;
            j++
          ) {
            if (
              editedItem._id == this.courseDiscussionData[i].forumThread[j]._id
            ) {
              this.courseDiscussionData[i].forumThread[
                j
              ].showUpdateReplyThread = true;
              this.courseDiscussionData[i].forumThread[
                j
              ].showDescriptionReplyThread = false;
            }
          }
          arrayOfcourseDiscussionData.push(this.courseDiscussionData[i]);
        }
        this.courseDiscussionData = arrayOfcourseDiscussionData;
      },
      updateRelpyThreadDiscussion(replyThread, selected) {
        this.showLoader = true;
        var payloadData = {
          forumThreadId: replyThread._id,
          courseDiscussionId: selected._id,
0bb8c9148   Amber Dev   solved bugs in di...
620
          studentId: localStorage.getItem("parentStudentId"),
860da881d   Shikha Mishra   comment all consoles
621
          description: replyThread.description,
a8bd267e9   Amber Dev   added course disc...
622
623
624
        };
        http()
          .put("/updateForumThread", payloadData)
860da881d   Shikha Mishra   comment all consoles
625
          .then((response) => {
a8bd267e9   Amber Dev   added course disc...
626
627
628
            this.showLoader = false;
            this.getDiscussionesThread();
          })
860da881d   Shikha Mishra   comment all consoles
629
          .catch((error) => {
a8bd267e9   Amber Dev   added course disc...
630
631
632
633
634
635
636
            this.showLoader = false;
          });
      },
      deleteRelpyThreadDiscussion(id, courseDiscussionId) {
        this.showLoader = true;
        var payloadData = {
          forumThreadId: id,
860da881d   Shikha Mishra   comment all consoles
637
          courseDiscussionId: courseDiscussionId,
a8bd267e9   Amber Dev   added course disc...
638
639
640
641
642
643
        };
        http()
          .put(
            "/deleteForumThread",
            confirm("Are you sure you want to delete this?") && payloadData
          )
860da881d   Shikha Mishra   comment all consoles
644
          .then((response) => {
a8bd267e9   Amber Dev   added course disc...
645
646
647
            this.showLoader = false;
            this.getDiscussionesThread();
          })
860da881d   Shikha Mishra   comment all consoles
648
          .catch((error) => {
a8bd267e9   Amber Dev   added course disc...
649
650
            this.showLoader = false;
          });
860da881d   Shikha Mishra   comment all consoles
651
      },
6f7cf8cf5   Amber Dev   added discussion ...
652
653
    },
    async created() {
a8bd267e9   Amber Dev   added course disc...
654
      this.loginId = this.$store.state.id;
6f7cf8cf5   Amber Dev   added discussion ...
655
656
657
      /* getStudentCourses - to get courseData - defined in GetApis.js*/
      await this.getStudentCourses({
        classId: localStorage.getItem("parentClassId"),
860da881d   Shikha Mishra   comment all consoles
658
        studentId: localStorage.getItem("parentStudentId"),
6f7cf8cf5   Amber Dev   added discussion ...
659
      });
0a5256600   Amber Dev   added events
660
661
662
663
  
      /* getCourseDiscussionesList - to populate the data table */
      await this.getCourseDiscussionesList({
        courseId: this.$route.query.courseId,
860da881d   Shikha Mishra   comment all consoles
664
        classId: localStorage.getItem("parentClassId"),
0a5256600   Amber Dev   added events
665
      });
860da881d   Shikha Mishra   comment all consoles
666
    },
6f7cf8cf5   Amber Dev   added discussion ...
667
668
  };
  </script>
fe15ee8b4   Amber Dev   added course chap...
669
670
671
672
673
674
675
676
677
  <style scoped>
  .side-bar-color {
    color: #827bfa !important;
    /* border-top-right-radius: 74px !important; */
  }
  .card-border {
    border: 1px #bdbdbd solid;
    border-radius: 3px;
  }
a8bd267e9   Amber Dev   added course disc...
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
  .reply-desc {
    border: 1px solid #f2f2f2;
  }
  .open-dialog-button {
    background: #827bfa !important;
    border-color: #827bfa !important;
    text-transform: none !important;
  }
  
  .reply-btn {
    background: #feb83c !important;
    border-color: #feb83c !important;
    text-transform: none !important;
    -webkit-box-shadow: none !important;
    box-shadow: none !important;
  }
fe15ee8b4   Amber Dev   added course chap...
694
  </style>