Blame view

src/pages/Course/courseDetail.vue 34.8 KB
11d037abe   Neeraj Sharma   commit code
1
2
  <template>
    <v-container fluid class="body-color">
6c8f4ba9a   Neeraj Sharma   commit course all...
3
      <!-- ****** Edit Chapter detail  ****** -->
11d037abe   Neeraj Sharma   commit code
4
5
6
7
      <v-dialog v-model="editCourseDetailDialog" max-width="1000px" scrollable>
        <v-card class="card-style pa-2" dark>
          <v-layout>
            <v-flex xs12>
6c8f4ba9a   Neeraj Sharma   commit course all...
8
              <label class="title text-xs-center">Edit Chapter</label>
11d037abe   Neeraj Sharma   commit code
9
10
11
12
13
14
15
16
              <v-icon size="24" class="right" @click="editCourseDetailDialog = false">cancel</v-icon>
            </v-flex>
          </v-layout>
          <v-card-text>
            <v-layout wrap>
              <v-flex xs12 sm12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
6c8f4ba9a   Neeraj Sharma   commit course all...
17
18
19
20
21
22
23
24
25
26
27
                    <label class="right">Select Class:</label>
                  </v-flex>
                  <v-flex xs8 sm6 class="ml-3">
                    <v-select
                      small
                      :items="addclass"
                      label="Select Class"
                      v-model="editedCourse.classId"
                      item-text="classNum"
                      item-value="_id"
                      name="Select Class"
6ef520020   Neeraj Sharma   implement all fun...
28
                      @change="getCourses(editedCourse.classId)"
6c8f4ba9a   Neeraj Sharma   commit course all...
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
                      class="mr-2"
                      required
                    ></v-select>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12 sm12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Select Course:</label>
                  </v-flex>
                  <v-flex xs8 sm6 class="ml-3">
                    <v-select
                      :items="courseData"
                      label="Select Course"
                      v-model="editedCourse.courseId"
0a5256600   Amber Dev   added events
45
                      item-text="courseName"
6c8f4ba9a   Neeraj Sharma   commit course all...
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
                      item-value="_id"
                      required
                      class="ml-2"
                    ></v-select>
                  </v-flex>
                </v-layout>
              </v-flex>
            </v-layout>
            <v-layout>
              <v-flex xs12 sm12 md11 lg11>
                <v-card-actions class="hidden-xs-only hidden-sm-only">
                  <v-spacer></v-spacer>
                  <v-btn round dark @click="save" :loading="editLoading" class="add-button mr-4">Save</v-btn>
                </v-card-actions>
                <v-card-actions class="hidden-md-only hidden-lg-only hidden-xl-only">
                  <v-spacer></v-spacer>
                  <v-btn round dark @click="save" :loading="editLoading" class="add-button">Save</v-btn>
                  <v-spacer></v-spacer>
                </v-card-actions>
              </v-flex>
            </v-layout>
          </v-card-text>
        </v-card>
      </v-dialog>
      <!-- ****** Edit Chapter detail  ****** -->
      <v-dialog v-model="editChapterDetailDialog" max-width="1000px" scrollable>
        <v-card class="card-style pa-2" dark>
          <v-layout>
            <v-flex xs12>
              <label class="title text-xs-center">Edit Chapter</label>
              <v-icon size="24" class="right" @click="editChapterDetailDialog = false">cancel</v-icon>
            </v-flex>
          </v-layout>
          <v-card-text>
            <v-layout wrap>
              <v-flex xs12 sm12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
11d037abe   Neeraj Sharma   commit code
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
                    <label class="right">Chapter Name:</label>
                  </v-flex>
                  <v-flex xs8 sm6 class="ml-3">
                    <v-text-field
                      v-model="editChapter.chapterName"
                      placeholder="fill your Title"
                      type="text"
                      required
                    ></v-text-field>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12 sm12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Description:</label>
                  </v-flex>
                  <v-flex xs8 sm6 class="ml-3">
                    <v-text-field
                      placeholder="fill your Description"
                      v-model="editChapter.description"
                      type="text"
                      required
                    ></v-text-field>
                  </v-flex>
                </v-layout>
              </v-flex>
            </v-layout>
            <v-flex xs12 v-if="editChapter.chapterPoints !=[]">
              <v-layout
                wrap
                v-for="(editChapterPoint,index) in editChapter.chapterPoints"
                :key="index"
              >
                <v-flex xs12 sm12 md4 class="pt-4 subheading">
                  <label class="right hidden-xs-only hidden-sm-only">Chapter Points:</label>
                  <label class="hidden-md-only hidden-lg-only hidden-xl-only">Chapter Points:</label>
                </v-flex>
                <v-layout>
                  <v-flex xs10 sm10 sm5 md9 class="ml-3">
                    <v-text-field :value="editChapterPoint" type="text" required></v-text-field>
                  </v-flex>
                  <v-flex xs2 class="pt-4">
6c8f4ba9a   Neeraj Sharma   commit course all...
127
128
                    <v-icon @click="deleteUrl(index)">cancel</v-icon>
                    <!-- <v-icon @click="update()">add_circle</v-icon> -->
11d037abe   Neeraj Sharma   commit code
129
130
131
132
                  </v-flex>
                </v-layout>
              </v-layout>
            </v-flex>
6c8f4ba9a   Neeraj Sharma   commit course all...
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
            <v-flex xs12>
              <div v-for="(updateImage,index) in updates" :key="index">
                <v-layout wrap>
                  <v-flex xs12 sm12 md4 class="pt-4 subheading">
                    <label class="right hidden-xs-only hidden-sm-only">Chapter Points:</label>
                    <label class="hidden-md-only hidden-lg-only hidden-xl-only">Chapter Points:</label>
                  </v-flex>
                  <v-layout>
                    <v-flex xs10 sm12 md9 class="ml-3">
                      <v-text-field
                        v-model="updateImage.value"
                        placeholder="Upload new Chapter Points"
                        required
                      ></v-text-field>
                    </v-flex>
                    <v-flex xs2 class="pt-4">
                      <v-icon @click="deleteUpdate(index)" v-if="index !=0">cancel</v-icon>
                      <v-icon @click="update">add_circle</v-icon>
                    </v-flex>
                  </v-layout>
                </v-layout>
              </div>
            </v-flex>
11d037abe   Neeraj Sharma   commit code
156
157
158
159
            <v-layout>
              <v-flex xs12 sm12 md11 lg11>
                <v-card-actions class="hidden-xs-only hidden-sm-only">
                  <v-spacer></v-spacer>
6c8f4ba9a   Neeraj Sharma   commit course all...
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
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
258
                  <v-btn
                    round
                    dark
                    @click="saveChapter"
                    :loading="editLoading"
                    class="add-button mr-4"
                  >Save</v-btn>
                </v-card-actions>
                <v-card-actions class="hidden-md-only hidden-lg-only hidden-xl-only">
                  <v-spacer></v-spacer>
                  <v-btn
                    round
                    dark
                    @click="saveChapter"
                    :loading="editLoading"
                    class="add-button"
                  >Save</v-btn>
                  <v-spacer></v-spacer>
                </v-card-actions>
              </v-flex>
            </v-layout>
          </v-card-text>
        </v-card>
      </v-dialog>
      <!-- ****** Add  Chapter detail  ****** -->
      <v-dialog v-model="addChapterDialog" max-width="1000px" scrollable>
        <v-card class="card-style pa-2" dark>
          <v-layout>
            <v-flex xs12>
              <label class="title text-xs-center">Add Chapter Detail</label>
              <v-icon size="24" class="right" @click="addChapterDialog = false">cancel</v-icon>
            </v-flex>
          </v-layout>
          <v-card-text>
            <v-layout wrap>
              <v-flex xs12 sm12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Chapter Name:</label>
                  </v-flex>
                  <v-flex xs8 sm6 class="ml-3">
                    <v-text-field
                      v-model="addChapterItem.chapterName"
                      placeholder="fill your Title"
                      type="text"
                      required
                    ></v-text-field>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12 sm12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Description:</label>
                  </v-flex>
                  <v-flex xs8 sm6 class="ml-3">
                    <v-text-field
                      placeholder="fill your Description"
                      v-model="addChapterItem.description"
                      type="text"
                      required
                    ></v-text-field>
                  </v-flex>
                </v-layout>
              </v-flex>
            </v-layout>
            <v-flex xs12>
              <div v-for="(chapterPoints,index) in findsChapterPoint" :key="index">
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Chapter Points:</label>
                  </v-flex>
                  <v-flex xs8 sm8 md6 class="ml-3">
                    <v-text-field
                      placeholder="fill your Chapter Points"
                      v-model="chapterPoints.value"
                      type="text"
                      name="link"
                      required
                    ></v-text-field>
                  </v-flex>
                  <v-flex xs2 class="pt-4">
                    <v-icon @click="deleteChapterPoint(index)" v-if="index !=0 ">cancel</v-icon>
                    <v-icon @click="addChapterPoint()">add_circle</v-icon>
                  </v-flex>
                </v-layout>
              </div>
            </v-flex>
            <v-layout>
              <v-flex xs12 sm12 md11 lg11>
                <v-card-actions class="hidden-xs-only hidden-sm-only">
                  <v-spacer></v-spacer>
                  <v-btn
                    round
                    dark
                    @click="submitChapter"
                    :loading="editLoading"
                    class="add-button mr-4"
                  >Submit</v-btn>
11d037abe   Neeraj Sharma   commit code
259
260
261
262
263
264
265
266
267
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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
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
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
                </v-card-actions>
                <v-card-actions class="hidden-md-only hidden-lg-only hidden-xl-only">
                  <v-spacer></v-spacer>
                  <v-btn round dark @click="save" :loading="editLoading" class="add-button">Save</v-btn>
                  <v-spacer></v-spacer>
                </v-card-actions>
              </v-flex>
            </v-layout>
          </v-card-text>
        </v-card>
      </v-dialog>
  
      <!-- ****** PROFILE Gallery ******  -->
  
      <v-dialog v-model="viewProfileGallery" max-width="1000" scrollable>
        <v-card flat class="card-style pa-3" dark>
          <v-layout>
            <v-flex xs12>
              <label class="title text-xs-center">View Course Detail</label>
              <v-icon size="24" class="right" @click="closeProfileGallery">cancel</v-icon>
            </v-flex>
          </v-layout>
          <v-card-text>
            <v-container grid-list-md>
              <v-layout wrap>
                <v-flex xs12>
                  <v-layout>
                    <v-flex xs4 sm6>
                      <h5 class="right my-1">
                        <b>Chapter Name:</b>
                      </h5>
                    </v-flex>
                    <v-flex sm6 xs8>
                      <h5 class="my-1">{{ editedItem.chapterName }}</h5>
                    </v-flex>
                  </v-layout>
                  <v-layout>
                    <v-flex xs4 sm6>
                      <h5 class="right my-1">
                        <b>Description:</b>
                      </h5>
                    </v-flex>
                    <v-flex sm6 xs8>
                      <h5 class="my-1">{{ editedItem.description }}</h5>
                    </v-flex>
                  </v-layout>
                  <v-layout>
                    <v-flex xs5 sm6>
                      <h5 class="right my-1">
                        <b>You Tube Link Url:</b>
                      </h5>
                    </v-flex>
                    <v-flex sm6 xs8>
                      <h5 class="my-1">
                        <ul v-for="chapterPoint in editedItem.chapterPoints" :key="chapterPoint">
                          <li>{{ chapterPoint}}</li>
                        </ul>
                      </h5>
                    </v-flex>
                  </v-layout>
                </v-flex>
              </v-layout>
            </v-container>
          </v-card-text>
        </v-card>
      </v-dialog>
  
      <!-- ****** Course Detail TABLE ****** -->
  
      <v-toolbar color="transparent" flat>
        <v-btn
          fab
          dark
          class="open-dialog-button hidden-xl-only hidden-md-only hidden-lg-only"
          small
          @click="addCourseDetailDialog = true"
        >
          <v-icon dark>add</v-icon>
        </v-btn>
        <v-btn
          round
          class="open-dialog-button hidden-sm-only hidden-xs-only"
          dark
          @click="addCourseDetailDialog = true"
        >
          <v-icon class="white--text pr-1" size="20">add</v-icon>Add Course Detail
        </v-btn>
        <v-flex xs12 sm4 md2>
          <v-select
            small
            :items="addclass"
            label="Select Class"
            v-model="getCourse.classId"
            item-text="classNum"
            item-value="_id"
            name="Select Class"
            @change="getCourses(getCourse.classId)"
            class="mr-2"
            required
          ></v-select>
        </v-flex>
        <v-flex xs12 sm4 md2>
          <v-select
            :items="courseData"
            label="Select Course"
            v-model="getCourse.courseId"
0a5256600   Amber Dev   added events
365
            item-text="courseName"
11d037abe   Neeraj Sharma   commit code
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
            item-value="_id"
            required
            class="ml-2"
            @change="getCourseDetailsList(getCourse.courseId)"
          ></v-select>
        </v-flex>
        <v-spacer></v-spacer>
        <v-card-title class="body-1" v-show="show">
          <v-btn icon large flat @click="displaySearch">
            <v-avatar size="27">
              <img src="/static/icon/search.png" alt="icon" />
            </v-avatar>
          </v-btn>
        </v-card-title>
        <v-flex xs8 sm8 md3 lg2 v-show="showSearch">
          <v-layout>
            <v-text-field v-model="search" label="Search" prepend-inner-icon="search" color="primary"></v-text-field>
            <v-icon @click="closeSearch" color="error">close</v-icon>
          </v-layout>
        </v-flex>
      </v-toolbar>
      <v-data-table
        :headers="headers"
        :items="CourseDetailsList"
        :pagination.sync="pagination"
        :search="search"
        item-key="_id"
      >
        <template slot="items" slot-scope="props">
6c8f4ba9a   Neeraj Sharma   commit course all...
395
          <tr class="tr" @click="courseTableRow(props.item._id)">
11d037abe   Neeraj Sharma   commit code
396
397
            <td class="td td-row">{{ props.index + 1}}</td>
            <td class="td td-row text-xs-center">{{ props.item.classId.classNum }}</td>
0a5256600   Amber Dev   added events
398
            <td class="td td-row text-xs-center">{{ props.item.courseId.courseName }}</td>
11d037abe   Neeraj Sharma   commit code
399
            <td class="td td-row text-xs-center">
a8bd267e9   Amber Dev   added course disc...
400
              <div style="vertical-align: top;">
6c8f4ba9a   Neeraj Sharma   commit course all...
401
402
403
                <v-tooltip top>
                  <v-icon
                    slot="activator"
a8bd267e9   Amber Dev   added course disc...
404
                    style="cursor:pointer;font-size:22px;position: relative;top: -4px; "
6c8f4ba9a   Neeraj Sharma   commit course all...
405
406
407
408
409
410
                    class="mr-3"
                    @click="addChapters(props.item)"
                  >add_circle_outline</v-icon>
                  <span>Add</span>
                </v-tooltip>
                <v-tooltip top>
11d037abe   Neeraj Sharma   commit code
411
412
413
414
                  <img
                    slot="activator"
                    style="cursor:pointer; width:25px; height:25px; "
                    class="mr-3"
6c8f4ba9a   Neeraj Sharma   commit course all...
415
                    @click="props.expanded = !props.expanded"
11d037abe   Neeraj Sharma   commit code
416
417
418
419
420
421
422
423
424
425
426
427
428
                    src="/static/icon/view.png"
                  />
                  <span>View</span>
                </v-tooltip>
                <v-tooltip top>
                  <img
                    slot="activator"
                    style="cursor:pointer; width:20px; height:18px; "
                    class="mr-3"
                    @click="editItem(props.item)"
                    src="/static/icon/edit.png"
                  />
                  <span>Edit</span>
6c8f4ba9a   Neeraj Sharma   commit course all...
429
                </v-tooltip>
11d037abe   Neeraj Sharma   commit code
430
431
432
433
434
435
436
437
438
439
                <v-tooltip top>
                  <img
                    slot="activator"
                    style="cursor:pointer; width:20px; height:20px; "
                    class="mr-3"
                    @click="deleteItem(props.item)"
                    src="/static/icon/delete.png"
                  />
                  <span>Delete</span>
                </v-tooltip>
a8bd267e9   Amber Dev   added course disc...
440
              </div>
11d037abe   Neeraj Sharma   commit code
441
442
443
            </td>
          </tr>
        </template>
7d2cd2462   Neeraj Sharma   fixed bugs
444
        <template slot="expand">
11d037abe   Neeraj Sharma   commit code
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
          <v-data-table :items="chapters" hide-actions item-key="chapterName" style="width: auto;">
            <template slot="items" slot-scope="props">
              <tr class="tr" @click="props.expanded = !props.expanded">
                <td class="td td-row">{{ props.index + 1}}</td>
                <td class="text-xs-center td td-row">{{ props.item.chapterName}}</td>
                <td class="text-xs-center td td-row">{{ props.item.description }}</td>
                <td class="text-xs-center td td-row">
                  <v-tooltip top>
                    <img
                      slot="activator"
                      style="cursor:pointer; width:25px; height:25px; "
                      class="mr-3"
                      @click="profile(props.item)"
                      src="/static/icon/view.png"
                    />
                    <span>View</span>
                  </v-tooltip>
                  <v-tooltip top>
                    <img
                      slot="activator"
                      style="cursor:pointer; width:20px; height:18px; "
                      class="mr-3"
                      @click="editChapterItem(props.item)"
                      src="/static/icon/edit.png"
                    />
                    <span>Edit</span>
                  </v-tooltip>
11d037abe   Neeraj Sharma   commit code
472
                  <v-tooltip top>
6c8f4ba9a   Neeraj Sharma   commit course all...
473
                    <img
11d037abe   Neeraj Sharma   commit code
474
                      slot="activator"
6c8f4ba9a   Neeraj Sharma   commit course all...
475
476
477
478
479
480
                      style="cursor:pointer; width:20px; height:20px; "
                      class="mr-3"
                      @click="deleteChapters(props.item)"
                      src="/static/icon/delete.png"
                    />
                    <span>Delete Chapter</span>
11d037abe   Neeraj Sharma   commit code
481
482
                  </v-tooltip>
                </td>
6c8f4ba9a   Neeraj Sharma   commit course all...
483
              </tr>
11d037abe   Neeraj Sharma   commit code
484
            </template>
11d037abe   Neeraj Sharma   commit code
485
486
487
488
489
490
491
492
493
494
495
          </v-data-table>
        </template>
  
        <v-alert
          slot="no-results"
          :value="true"
          color="error"
          icon="warning"
        >Your search for "{{ search }}" found no results.</v-alert>
      </v-data-table>
      <!-- ****** ADD Course Detail  ****** -->
a8bd267e9   Amber Dev   added course disc...
496
      <v-dialog v-model="addCourseDetailDialog" max-width="600px" persistent>
11d037abe   Neeraj Sharma   commit code
497
498
499
500
        <v-card flat class="card-style pa-2" dark>
          <v-layout>
            <v-flex xs12>
              <label class="title text-xs-center">Add Course Details</label>
a8bd267e9   Amber Dev   added course disc...
501
              <v-icon size="24" class="right" @click="addCourseDetailDialog = false; clear();">cancel</v-icon>
11d037abe   Neeraj Sharma   commit code
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
            </v-flex>
          </v-layout>
          <v-form ref="form" v-model="valid" lazy-validation>
            <v-container fluid>
              <v-flex xs12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right hidden-xs-only hidden-sm-only">Select Class:</label>
                    <label class="right hidden-lg-only hidden-md-only hidden-xl-only">Class:</label>
                  </v-flex>
                  <v-flex xs8 sm8 md7 class="ml-3">
                    <v-select
                      :items="addclass"
                      label="Select Class"
                      v-model="addCourseDetail.classId"
                      item-text="classNum"
                      item-value="_id"
                      name="Select Class"
                      :rules="clsssRules"
                      @change="getCourses(addCourseDetail.classId)"
                      required
                    ></v-select>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right hidden-xs-only hidden-sm-only">Select Course:</label>
                    <label class="right hidden-lg-only hidden-md-only hidden-xl-only">Course:</label>
                  </v-flex>
                  <v-flex xs8 sm8 md7 class="ml-3">
                    <v-select
                      :items="courseData"
                      label="Select Course"
                      v-model="addCourseDetail.courseId"
0a5256600   Amber Dev   added events
538
                      item-text="courseName"
11d037abe   Neeraj Sharma   commit code
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
                      item-value="_id"
                      :rules="courseRules"
                      required
                    ></v-select>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Chapter Name:</label>
                  </v-flex>
                  <v-flex xs8 sm8 md7 class="ml-3">
                    <v-text-field
                      v-model="addCourseDetail.chapterName"
                      placeholder="fill your Title"
                      name="name"
                      type="text"
                      :rules="chapterNameRules"
                      required
                    ></v-text-field>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Description:</label>
                  </v-flex>
                  <v-flex xs8 sm8 md7 class="ml-3">
                    <v-text-field
                      placeholder="fill your Description"
                      :rules="descriptionRules"
                      v-model="addCourseDetail.description"
                      type="text"
                      name="email"
                      required
                    ></v-text-field>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-layout>
                <v-flex xs12>
                  <div v-for="(chapterPoints,index) in finds" :key="index">
                    <v-layout>
                      <v-flex xs4 class="pt-4 subheading">
                        <label class="right">Chapter Points:</label>
                      </v-flex>
                      <v-flex xs8 sm8 md6 class="ml-3">
                        <v-text-field
                          placeholder="fill your Chapter Points"
                          v-model="chapterPoints.value"
                          type="text"
11d037abe   Neeraj Sharma   commit code
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
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
                          required
                        ></v-text-field>
                      </v-flex>
                      <v-flex xs2 class="pt-4">
                        <v-icon @click="deleteFind(index)" v-if="index !=0 ">cancel</v-icon>
                        <v-icon @click="addFind">add_circle</v-icon>
                      </v-flex>
                    </v-layout>
                  </div>
                </v-flex>
              </v-layout>
              <v-layout>
                <v-flex xs12 sm12>
                  <v-layout class="right">
                    <v-btn @click="clear" round dark class="clear-button">Clear</v-btn>
                    <v-btn @click="submit" round dark :loading="loading" class="add-button">Add</v-btn>
                  </v-layout>
                </v-flex>
              </v-layout>
            </v-container>
          </v-form>
        </v-card>
      </v-dialog>
      <v-snackbar
        :timeout="timeout"
        :top="y === 'top'"
        :right="x === 'right'"
        :vertical="mode === 'vertical'"
        v-model="snackbar"
        :color="color"
      >{{ text }}</v-snackbar>
      <div class="loader" v-if="showLoader">
        <v-progress-circular indeterminate color="white"></v-progress-circular>
      </div>
    </v-container>
  </template>
  
  <script>
  import http from "@/Services/http.js";
  
  export default {
    data: () => ({
      snackbar: false,
      y: "top",
      x: "right",
      mode: "",
      timeout: 3000,
      text: "",
      loading: false,
      color: "",
      date: null,
      search: "",
      show: true,
      addCourseDetailDialog: false,
      showSearch: false,
      showLoader: false,
      editCourseDetailDialog: false,
6c8f4ba9a   Neeraj Sharma   commit course all...
649
      editChapterDetailDialog: false,
11d037abe   Neeraj Sharma   commit code
650
651
652
653
654
655
656
657
      viewProfileGallery: false,
      valid: true,
      editLoading: false,
      addclass: [],
      courseData: [],
      addSection: [],
      getCourse: {},
      finds: [{ value: "" }],
6c8f4ba9a   Neeraj Sharma   commit course all...
658
659
      findsChapterPoint: [{ value: "" }],
      updates: [{ value: "" }],
11d037abe   Neeraj Sharma   commit code
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
      youTubeLink: {},
      addCourseDetail: {
        chapters: [
          {
            chapterName: "",
            description: "",
            chapterPoints: []
          }
        ]
      },
      chapters: [],
      pagination: {
        rowsPerPage: 10
      },
      editFiles: [],
      files: [],
      courseData: [],
      token: "",
6c8f4ba9a   Neeraj Sharma   commit course all...
678
      courseId: "",
11d037abe   Neeraj Sharma   commit code
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
      clsssRules: [v => !!v || " Class is required"],
      courseRules: [v => !!v || " Course is required"],
      chapterNameRules: [v => !!v || " Tilte is required"],
      descriptionRules: [v => !!v || " Description is required"],
      headers: [
        {
          align: "",
          text: "No",
          sortable: false,
          value: "index"
        },
        {
          text: "Class Name",
          value: "classNum",
          sortable: false,
          align: "center"
        },
        {
          text: "Course Name",
          value: "courseName",
          sortable: false,
          align: "center"
        },
        { text: "Action", value: "", sortable: false, align: "center" }
      ],
      CourseDetailsList: [],
      editedIndex: -1,
      editedItem: {},
6c8f4ba9a   Neeraj Sharma   commit course all...
707
      editedCourse: {},
11d037abe   Neeraj Sharma   commit code
708
      editChapter: {},
6c8f4ba9a   Neeraj Sharma   commit course all...
709
710
      index: "",
      addChapterItem: {},
7d2cd2462   Neeraj Sharma   fixed bugs
711
      addChapterItemObj: {},
6c8f4ba9a   Neeraj Sharma   commit course all...
712
      addChapterDialog: false
11d037abe   Neeraj Sharma   commit code
713
714
715
716
717
718
719
720
721
722
723
    }),
    methods: {
      getCourses(classId) {
        this.showLoader = true;
        http()
          .get("/getCourseesList", {
            params: {
              classId: classId
            }
          })
          .then(response => {
6c8f4ba9a   Neeraj Sharma   commit course all...
724
            this.editChapter.courseId = "";
11d037abe   Neeraj Sharma   commit code
725
            this.courseData = response.data.data;
7d2cd2462   Neeraj Sharma   fixed bugs
726
            // console.log("this.courseData", this.courseData);
11d037abe   Neeraj Sharma   commit code
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
            this.showLoader = false;
          })
          .catch(err => {
            console.log("err====>", err);
            this.showLoader = false;
          });
      },
      getCourseDetailsList() {
        this.showLoader = true;
        http()
          .get("/getParticularCourseDetail", {
            params: {
              courseId: this.getCourse.courseId
            }
          })
          .then(response => {
            this.CourseDetailsList = response.data.data;
7d2cd2462   Neeraj Sharma   fixed bugs
744
745
746
            if (response.data.data[0]) {
              this.chapters = response.data.data[0].chapters;
            }
6c8f4ba9a   Neeraj Sharma   commit course all...
747
            // console.log("response.data.data", this.CourseDetailsList);
11d037abe   Neeraj Sharma   commit code
748
749
750
751
752
753
754
755
756
757
758
759
            this.showLoader = false;
          })
          .catch(error => {
            // console.log("err====>", err);
            this.showLoader = false;
            if (error.response.status === 401) {
              this.$router.replace({ path: "/" });
              this.$store.dispatch("setToken", null);
              this.$store.dispatch("Id", null);
            }
          });
      },
6c8f4ba9a   Neeraj Sharma   commit course all...
760
761
762
763
764
      courseTableRow(id) {
        // console.log("click7", id);
        this.courseId = id;
      },
      addChapters(item) {
6c8f4ba9a   Neeraj Sharma   commit course all...
765
        this.editedIndex = this.CourseDetailsList.indexOf(item);
7d2cd2462   Neeraj Sharma   fixed bugs
766
767
        this.addChapterItemObj = Object.assign({}, item);
        this.addChapterItem.courseDetailId = this.addChapterItemObj._id;
6c8f4ba9a   Neeraj Sharma   commit course all...
768
        this.addChapterDialog = true;
6c8f4ba9a   Neeraj Sharma   commit course all...
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
      },
      submitChapter() {
        this.addChapterItem.chapterPoints = [];
        for (let i = 0; i < this.findsChapterPoint.length; i++) {
          this.addChapterItem.chapterPoints.push(this.findsChapterPoint[i].value);
        }
        // console.log("this.addChapterItem", this.addChapterItem);
        this.loading = true;
        http()
          .put("/addChapters", this.addChapterItem)
          .then(response => {
            this.addChapterDialog = false;
            this.loading = false;
            this.snackbar = true;
            this.text = response.data.message;
            this.color = "green";
7d2cd2462   Neeraj Sharma   fixed bugs
785
786
            this.addChapterItem = {};
            this.removeChapterPoint();
6c8f4ba9a   Neeraj Sharma   commit course all...
787
            this.getCourseDetailsList();
6c8f4ba9a   Neeraj Sharma   commit course all...
788
789
790
791
792
793
794
795
          })
          .catch(error => {
            this.snackbar = true;
            this.text = error.response.data.message;
            this.color = "error";
            this.loading = false;
          });
      },
11d037abe   Neeraj Sharma   commit code
796
797
798
799
800
      profile(item) {
        this.editedIndex = this.chapters.indexOf(item);
        this.editedItem = Object.assign({}, item);
        this.viewProfileGallery = true;
      },
6c8f4ba9a   Neeraj Sharma   commit course all...
801
802
803
      editItem(item) {
        this.editedIndex = this.CourseDetailsList.indexOf(item);
        this.editedCourse = Object.assign({}, item);
6c8f4ba9a   Neeraj Sharma   commit course all...
804
805
        this.editCourseDetailDialog = true;
      },
11d037abe   Neeraj Sharma   commit code
806
807
808
      editChapterItem(item) {
        this.editedIndex = this.chapters.indexOf(item);
        this.editChapter = Object.assign({}, item);
6c8f4ba9a   Neeraj Sharma   commit course all...
809
        this.editChapterDetailDialog = true;
11d037abe   Neeraj Sharma   commit code
810
811
812
      },
      deleteItem(item) {
        let deleteGallery = {
6c8f4ba9a   Neeraj Sharma   commit course all...
813
          courseDetailId: item._id
11d037abe   Neeraj Sharma   commit code
814
815
816
        };
        http()
          .delete(
6c8f4ba9a   Neeraj Sharma   commit course all...
817
            "/deleteCourseDetail",
11d037abe   Neeraj Sharma   commit code
818
819
820
821
822
823
824
825
826
            confirm("Are you sure you want to delete this?") && {
              params: deleteGallery,
              headers: {
                Authorization: "Bearer " + this.token
              }
            }
          )
          .then(response => {
            this.snackbar = true;
6c8f4ba9a   Neeraj Sharma   commit course all...
827
            this.text = "Successfully delete Course Details";
11d037abe   Neeraj Sharma   commit code
828
829
830
831
832
833
834
835
836
837
            this.color = "green";
            this.getCourseDetailsList();
          })
          .catch(error => {
            // console.log(error);
            this.snackbar = true;
            this.text = error.response.data.message;
            this.color = "error";
          });
      },
6c8f4ba9a   Neeraj Sharma   commit course all...
838
839
840
841
842
      deleteChapters(item) {
        // console.log("item", item);
        let deleteChapters = {
          courseDetailId: this.courseId,
          chapterId: item._id
11d037abe   Neeraj Sharma   commit code
843
844
        };
        http()
6c8f4ba9a   Neeraj Sharma   commit course all...
845
846
847
848
          .put(
            "/deleteChapters",
            confirm("Are you sure you want to delete this?") && deleteChapters
          )
11d037abe   Neeraj Sharma   commit code
849
850
          .then(response => {
            this.snackbar = true;
6c8f4ba9a   Neeraj Sharma   commit course all...
851
            this.text = "Successfully delete Chapters";
11d037abe   Neeraj Sharma   commit code
852
853
            this.color = "green";
            this.getCourseDetailsList();
11d037abe   Neeraj Sharma   commit code
854
855
          })
          .catch(error => {
6c8f4ba9a   Neeraj Sharma   commit course all...
856
            // console.log(error);
11d037abe   Neeraj Sharma   commit code
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
            this.snackbar = true;
            this.text = error.response.data.message;
            this.color = "error";
          });
      },
      close() {
        this.editCourseDetailDialog = false;
      },
      closeProfileGallery() {
        this.viewProfileGallery = false;
      },
      submit() {
        let chapters = [];
        var chapterPoints = [];
        for (let i = 0; i < this.finds.length; i++) {
          chapterPoints.push(this.finds[i].value);
          // console.log("this.finds[i].value", this.finds[i].value);
          chapters = [
            {
              chapterName: this.addCourseDetail.chapterName,
              description: this.addCourseDetail.description,
              chapterPoints: chapterPoints
            }
          ];
        }
        if (this.$refs.form.validate()) {
          // console.log("this.addCourseDetail", this.addCourseDetail);
          var courseDetailsData = {
            classId: this.addCourseDetail.classId,
            courseId: this.addCourseDetail.courseId,
            chapters: chapters
          };
          this.loading = true;
          http()
            .post("/createCourseDetail", courseDetailsData)
            .then(response => {
              this.addCourseDetailDialog = false;
              this.loading = false;
              this.snackbar = true;
              this.text = response.data.message;
              this.color = "green";
              this.clear();
7d2cd2462   Neeraj Sharma   fixed bugs
899
              this.removeAddFind();
11d037abe   Neeraj Sharma   commit code
900
901
902
903
904
905
906
907
908
909
910
            })
            .catch(error => {
              this.snackbar = true;
              this.text = error.response.data.message;
              this.color = "error";
              this.loading = false;
            });
        }
      },
      clear() {
        this.$refs.form.reset();
11d037abe   Neeraj Sharma   commit code
911
      },
6c8f4ba9a   Neeraj Sharma   commit course all...
912
913
      saveChapter() {
        this.editedItem.courseDetailId = this.editedItem._id;
7d2cd2462   Neeraj Sharma   fixed bugs
914
        console.log("this.updates", this.updates);
11d037abe   Neeraj Sharma   commit code
915
        for (let i = 0; i < this.updates.length; i++) {
7d2cd2462   Neeraj Sharma   fixed bugs
916
917
918
919
920
921
          if (this.updates[i].value != "") {
            var chapterPoints = [];
            chapterPoints.push(this.updates[i].value);
          } else {
            chapterPoints = this.editChapter.chapterPoints;
          }
11d037abe   Neeraj Sharma   commit code
922
        }
6c8f4ba9a   Neeraj Sharma   commit course all...
923
924
925
926
927
        var updateData = {
          courseDetailId: this.courseId,
          chapterId: this.editChapter._id,
          chapterName: this.editChapter.chapterName,
          description: this.editChapter.description,
7d2cd2462   Neeraj Sharma   fixed bugs
928
          chapterPoints: chapterPoints
6c8f4ba9a   Neeraj Sharma   commit course all...
929
        };
11d037abe   Neeraj Sharma   commit code
930
931
        this.editLoading = true;
        http()
6c8f4ba9a   Neeraj Sharma   commit course all...
932
          .put("/updateChapters", updateData)
11d037abe   Neeraj Sharma   commit code
933
          .then(response => {
7d2cd2462   Neeraj Sharma   fixed bugs
934
            this.editChapterDetailDialog = false;
11d037abe   Neeraj Sharma   commit code
935
936
937
938
            this.snackbar = true;
            this.text = response.data.message;
            this.color = "green";
            this.editLoading = false;
7d2cd2462   Neeraj Sharma   fixed bugs
939
940
            this.removeUpdatePoints();
            this.getCourseDetailsList();
11d037abe   Neeraj Sharma   commit code
941
942
943
944
945
946
947
948
          })
          .catch(error => {
            this.editLoading = false;
            this.snackbar = true;
            this.text = error.response.data.message;
            this.color = "error";
          });
      },
6c8f4ba9a   Neeraj Sharma   commit course all...
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
      save() {
        // console.log("utykgigiu", this.editedCourse);
        var updateData = {
          courseDetailId: this.editedCourse._id,
          courseId: this.editedCourse.courseId,
          classId: this.editedCourse.classId
        };
        this.editLoading = true;
        http()
          .put("/updateCourseDetail", updateData)
          .then(response => {
            this.getCourseDetailsList();
            this.editCourseDetailDialog = false;
            this.snackbar = true;
            this.text = response.data.message;
            this.color = "green";
            this.editLoading = false;
            // this.editChapterPointName = "";
            this.editFiles = [];
          })
          .catch(error => {
            this.editLoading = false;
            this.snackbar = true;
            this.text = error.response.data.message;
            this.color = "error";
          });
      },
11d037abe   Neeraj Sharma   commit code
976
977
978
979
980
981
982
983
984
985
986
987
      getAllClasses() {
        http()
          .get("/getClassesList", {
            headers: { Authorization: "Bearer " + this.token }
          })
          .then(response => {
            this.addclass = response.data.data;
          })
          .catch(err => {
            // console.log("err====>", err);
          });
      },
6c8f4ba9a   Neeraj Sharma   commit course all...
988
989
990
      removeChapterPoint: function() {
        this.findsChapterPoint = [{ value: "" }];
      },
11d037abe   Neeraj Sharma   commit code
991
992
993
994
995
996
      removeAddFind: function() {
        this.finds = [{ value: "" }];
      },
      addFind: function() {
        this.finds.push({ value: "" });
      },
6c8f4ba9a   Neeraj Sharma   commit course all...
997
998
      addChapterPoint: function() {
        this.findsChapterPoint.push({ value: "" });
7d2cd2462   Neeraj Sharma   fixed bugs
999
        console.log("this.findsChapterPoint", this.findsChapterPoint);
6c8f4ba9a   Neeraj Sharma   commit course all...
1000
      },
11d037abe   Neeraj Sharma   commit code
1001
      update: function() {
6c8f4ba9a   Neeraj Sharma   commit course all...
1002
        this.updates.push({ value: "" });
11d037abe   Neeraj Sharma   commit code
1003
      },
7d2cd2462   Neeraj Sharma   fixed bugs
1004
1005
1006
      removeUpdatePoints: function() {
        this.updates = [{ value: "" }];
      },
11d037abe   Neeraj Sharma   commit code
1007
1008
1009
1010
      deleteFind: function(index) {
        this.finds.splice(index, 1);
        if (index === 0) this.addFind();
      },
6c8f4ba9a   Neeraj Sharma   commit course all...
1011
1012
1013
1014
      deleteChapterPoint: function(index) {
        this.findsChapterPoint.splice(index, 1);
        if (index === 0) this.addChapterPoint();
      },
11d037abe   Neeraj Sharma   commit code
1015
1016
1017
1018
1019
      deleteUpdate: function(index) {
        this.updates.splice(index, 1);
        if (index === 0) this.update();
      },
      deleteUrl: function(index, youTubelinkId, id) {
6c8f4ba9a   Neeraj Sharma   commit course all...
1020
        this.editChapter.chapterPoints.splice(index, 1);
11d037abe   Neeraj Sharma   commit code
1021
        if (index === 0) this.update();
11d037abe   Neeraj Sharma   commit code
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
      },
      displaySearch() {
        this.show = false;
        this.showSearch = true;
      },
      closeSearch() {
        this.showSearch = false;
        this.show = true;
        this.search = "";
      }
    },
    mounted() {
      this.token = this.$store.state.token;
      this.getAllClasses();
    }
  };
  </script>