Blame view

src/pages/Academic/subject.vue 25.9 KB
068907f66   Shikha Mishra   improve subject ui
1
2
3
  <template>
    <v-container fluid class="body-color">
      <!-- ****** EDIT  Subject ****** -->
db965de89   Amber Dev   added dialog pers...
4
      <v-dialog v-model="editSubjectDialog" max-width="600px" persistent>
068907f66   Shikha Mishra   improve subject ui
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
134
135
        <v-card flat class="card-style pa-2" dark>
          <v-layout>
            <v-flex xs12>
              <label class="title text-xs-center">Edit Subject</label>
              <v-icon size="24" class="right" @click="editSubjectDialog = false">cancel</v-icon>
            </v-flex>
          </v-layout>
          <v-container fluid>
            <v-form ref="formEditSubject" v-model="validEditSubject" lazy-validation>
              <v-layout>
                <v-flex xs4 class="pt-4 subheading">
                  <label class="right">Class:</label>
                </v-flex>
                <v-flex xs8 class="ml-3">
                  <v-select
                    v-model="editedItem.classId"
                    label="Select your class"
                    type="text"
                    :items="classList"
                    item-text="classNum"
                    item-value="_id"
                    :rules="classRules"
                    required
                  ></v-select>
                </v-flex>
              </v-layout>
              <v-layout>
                <v-flex xs4 sm4 class="pt-4 subheading">
                  <label class="right">Teacher Name :</label>
                </v-flex>
                <v-flex xs8 sm8 class="ml-3">
                  <v-select
                    v-model="editedItem.teacherId"
                    label="Select your teacher"
                    type="text"
                    :items="teacherList"
                    item-text="name"
                    item-value="_id"
                    :rules="teacherRules"
                    required
                  ></v-select>
                </v-flex>
              </v-layout>
              <v-layout>
                <v-flex xs4 sm4 class="pt-4 sybheading">
                  <label class="right">Type :</label>
                </v-flex>
                <v-flex xs8 sm8 class="ml-3">
                  <v-select
                    v-model="editedItem.type"
                    :items="type"
                    label="Select your Type"
                    :rules="typeRules"
                    required
                  ></v-select>
                </v-flex>
              </v-layout>
              <v-layout>
                <v-flex xs4 sm4 class="pt-4 subheading">
                  <label class="right">Pass Mark :</label>
                </v-flex>
                <v-flex xs8 sm8 class="ml-3">
                  <v-text-field
                    label="Fill your Pass Mark"
                    name="name"
                    type="text"
                    :rules="markRules"
                    v-model="editedItem.passMarks"
                    required
                  ></v-text-field>
                </v-flex>
              </v-layout>
              <v-layout>
                <v-flex xs4 sm4 class="pt-4 subheading">
                  <label class="right">Final Mark :</label>
                </v-flex>
                <v-flex xs8 sm8 class="ml-3">
                  <v-text-field
                    label="Fill your final mark"
                    name="name"
                    type="text"
                    :rules="finalRules"
                    v-model="editedItem.finalMarks"
                    required
                  ></v-text-field>
                </v-flex>
              </v-layout>
              <v-layout>
                <v-flex xs4 class="pt-4 subheading">
                  <label class="right">Subject:</label>
                </v-flex>
                <v-flex xs8 class="ml-3">
                  <v-text-field
                    placeholder="fill your Subject"
                    v-model="editedItem.subjectName"
                    :rules="subjectRules"
                    type="text"
                    name="email"
                    required
                  ></v-text-field>
                </v-flex>
              </v-layout>
              <v-layout>
                <v-flex xs4 sm4 class="pt-4 subheading">
                  <label class="right">Subject Author :</label>
                </v-flex>
                <v-flex xs8 sm8 class="ml-3">
                  <v-text-field
                    v-model="editedItem.subjectAuthor"
                    placeholder="fill your Subject Author"
                    name="name"
                    type="text"
                  ></v-text-field>
                </v-flex>
              </v-layout>
              <v-layout>
                <v-flex xs4 sm4 class="pt-4 subheading">
                  <label class="right">Subject Code:</label>
                </v-flex>
                <v-flex xs8 sm8 class="ml-3">
                  <v-text-field
                    v-model="editedItem.subjectCode"
                    placeholder="fill your Subject Code"
                    name="name"
                    type="text"
                  ></v-text-field>
                </v-flex>
              </v-layout>
              <v-flex xs12 sm12>
                <v-card-actions>
                  <v-spacer></v-spacer>
b0e0491ab   Shikha Mishra   solve the issue o...
136
137
138
139
140
141
142
                  <v-btn
                    round
                    dark
                    @click="save"
                    :loading="editLoading"
                    class="add-button"
                  >Update Subject</v-btn>
068907f66   Shikha Mishra   improve subject ui
143
144
145
146
147
148
149
150
                </v-card-actions>
              </v-flex>
            </v-form>
          </v-container>
        </v-card>
      </v-dialog>
  
      <!-- ****** VIEW PROFIL NOTICE BOARD ******  -->
db965de89   Amber Dev   added dialog pers...
151
      <v-dialog v-model="viewSubjectDialog" max-width="500px" persistent>
068907f66   Shikha Mishra   improve subject ui
152
153
154
155
156
157
158
159
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
259
260
261
262
263
264
265
266
        <v-card flat class="card-style pa-3" dark>
          <v-layout>
            <v-flex xs12>
              <label class="title text-xs-center">View Subject</label>
              <v-icon size="24" class="right" @click="viewSubjectDialog = false">cancel</v-icon>
            </v-flex>
          </v-layout>
          <v-card-text>
            <v-container grid-list-md>
              <v-layout wrap>
                <v-flex>
                  <v-layout>
                    <v-flex xs6 sm4>
                      <h5 class="right my-1">
                        <b>Subject Name:</b>
                      </h5>
                    </v-flex>
                    <v-flex sm8 xs6>
                      <h5 class="my-1">{{ editedItem.subjectName }}</h5>
                    </v-flex>
                  </v-layout>
                  <v-layout>
                    <v-flex xs6 sm4>
                      <h5 class="right my-1">
                        <b>Subject Author:</b>
                      </h5>
                    </v-flex>
                    <v-flex sm8 xs6>
                      <h5 class="my-1">{{ editedItem.subjectAuthor }}</h5>
                    </v-flex>
                  </v-layout>
                  <v-layout>
                    <v-flex xs6 sm4>
                      <h5 class="right my-1">
                        <b>Subject :</b>
                      </h5>
                    </v-flex>
                    <v-flex sm8 xs6>
                      <h5 class="my-1">{{ editedItem.subjectCode }}</h5>
                    </v-flex>
                  </v-layout>
                  <!-- <v-layout>
                    <v-flex xs6 sm4>
                      <h5 class="right my-1">
                        <b>Teacher :</b>
                      </h5>
                    </v-flex>
                    <v-flex sm8 xs6>
                      <h5 class="my-1">{{ editedItem.teacherId }}</h5>
                    </v-flex>
                  </v-layout>-->
                  <v-layout>
                    <v-flex xs6 sm4>
                      <h5 class="right my-1">
                        <b>Pass Marks :</b>
                      </h5>
                    </v-flex>
                    <v-flex sm8 xs6>
                      <h5 class="my-1">{{ editedItem.passMarks }}</h5>
                    </v-flex>
                  </v-layout>
                  <v-layout>
                    <v-flex xs6 sm4>
                      <h5 class="right my-1">
                        <b>Final Marks :</b>
                      </h5>
                    </v-flex>
                    <v-flex sm8 xs6>
                      <h5 class="my-1">{{ editedItem.finalMarks }}</h5>
                    </v-flex>
                  </v-layout>
                  <v-layout>
                    <v-flex xs6 sm4>
                      <h5 class="right my-1">
                        <b>Type :</b>
                      </h5>
                    </v-flex>
                    <v-flex sm8 xs6>
                      <h5 class="my-1">{{ editedItem.type }}</h5>
                    </v-flex>
                  </v-layout>
                </v-flex>
              </v-layout>
            </v-container>
          </v-card-text>
        </v-card>
      </v-dialog>
  
      <!-- ****** EXISTING SUBJECTS 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="addSubjectDialog = true"
        >
          <v-icon dark>add</v-icon>
        </v-btn>
        <v-flex xs1 class="hidden-sm-only hidden-xs-only">
          <v-btn
            round
            class="open-dialog-button"
            dark
            @click="addSubjectDialog = true"
            v-if="role != 'TEACHER' "
          >
            <v-icon class="white--text pr-1" size="20">add</v-icon>Add Subject
          </v-btn>
        </v-flex>
        <v-spacer></v-spacer>
        <v-flex lg2 md2 xs12 v-show="show">
          <v-select
            :items="classList"
            label="Select Your Class"
b0e0491ab   Shikha Mishra   solve the issue o...
267
            v-model="getSubject.classId"
068907f66   Shikha Mishra   improve subject ui
268
269
270
271
272
273
274
275
276
277
278
279
            item-text="classNum"
            item-value="_id"
            name="Select Class"
            :rules="classRules"
            @change="getClassSubject"
            class="pl-2"
            required
          ></v-select>
        </v-flex>
        <v-card-title class="body-1" v-show="show">
          <v-btn icon flat @click="displaySearch">
            <v-avatar size="27">
1fb26113b   Amber Dev   added auto focus ...
280
              <img src="/static/icon/search.png" alt="icon" />
068907f66   Shikha Mishra   improve subject ui
281
282
283
            </v-avatar>
          </v-btn>
        </v-card-title>
1fb26113b   Amber Dev   added auto focus ...
284
        <v-flex xs9 sm9 md2 lg2 xl2 v-if="showSearch">
068907f66   Shikha Mishra   improve subject ui
285
286
          <v-layout>
            <v-text-field
8e8d14254   Shikha Mishra   Cleared data whil...
287
              autofocus
068907f66   Shikha Mishra   improve subject ui
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
              v-model="search"
              label="Search"
              prepend-inner-icon="search"
              color="primary"
              style="transition: 0.8s cubic-bezier(0.25, 0.8, 0.25, 1); !important"
            ></v-text-field>
            <v-icon @click="closeSearch" color="error">close</v-icon>
          </v-layout>
        </v-flex>
      </v-toolbar>
      <v-data-table
        :headers="headers"
        :items="subjectList.subjects"
        :pagination.sync="pagination"
        :search="search"
      >
        <template slot="items" slot-scope="props">
          <tr class="tr">
            <td class="td-row td">{{ props.index + 1 }}</td>
            <td class="text-xs-center td td-row">{{ props.item.subjectName }}</td>
            <td class="text-xs-center td td-row">{{ props.item.subjectAuthor }}</td>
            <td class="text-xs-center td td-row">{{ props.item.subjectCode }}</td>
            <!-- <td class="text-xs-center td td-row">{{ props.item.teacherId }}</td> -->
            <td class="text-xs-center td td-row">{{ props.item.passMarks }}</td>
            <td class="text-xs-center td td-row">{{ props.item.finalMarks }}</td>
            <td class="text-xs-center td td-row">{{ props.item.type }}</td>
b039d39fb   Shikha Mishra   Hide Edit functio...
314
            <!-- <td class="text-xs-center td td-row">
068907f66   Shikha Mishra   improve subject ui
315
              <span>
b039d39fb   Shikha Mishra   Hide Edit functio...
316
                <v-tooltip top>
068907f66   Shikha Mishra   improve subject ui
317
318
319
320
321
322
323
324
                  <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>
b039d39fb   Shikha Mishra   Hide Edit functio...
325
                </v-tooltip>
068907f66   Shikha Mishra   improve subject ui
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
                <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>
                </v-tooltip>
                <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>
              </span>
b0e0491ab   Shikha Mishra   solve the issue o...
347
            </td>-->
068907f66   Shikha Mishra   improve subject ui
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
          </tr>
        </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 MULTIPLE Subject ****** -->
      <v-snackbar
        :timeout="timeout"
        :top="y === 'top'"
        :right="x === 'right'"
        :vertical="mode === 'vertical'"
        v-model="snackbar"
        :color="color"
      >{{ text }}</v-snackbar>
db965de89   Amber Dev   added dialog pers...
366
      <v-dialog v-model="addSubjectDialog" max-width="600px" v-if="addSubjectDialog" persistent>
068907f66   Shikha Mishra   improve subject ui
367
368
369
370
        <v-card flat class="card-style pa-2" dark>
          <v-layout>
            <v-flex xs12>
              <label class="title text-xs-center">Add Subject</label>
8e8d14254   Shikha Mishra   Cleared data whil...
371
372
373
374
375
              <v-icon
                size="24"
                class="right"
                @click="$refs.form.reset();addSubjectDialog = false"
              >cancel</v-icon>
068907f66   Shikha Mishra   improve subject ui
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
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
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
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
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
            </v-flex>
          </v-layout>
          <v-container fluid fill-height>
            <v-layout align-center>
              <v-flex xs12>
                <v-form ref="form" v-model="valid" lazy-validation>
                  <v-layout>
                    <v-flex xs4 sm4 class="pt-4 subheading">
                      <label class="right">Class Name :</label>
                    </v-flex>
                    <v-flex xs8 sm8 class="ml-3">
                      <v-select
                        v-model="addSubject.classId"
                        label="Select your class"
                        type="text"
                        :items="classList"
                        item-text="classNum"
                        item-value="_id"
                        :rules="classRules"
                        required
                      ></v-select>
                    </v-flex>
                  </v-layout>
                  <v-layout>
                    <v-flex xs4 sm4 class="pt-4 subheading">
                      <label class="right">Teacher Name :</label>
                    </v-flex>
                    <v-flex xs8 sm8 class="ml-3">
                      <v-select
                        v-model="addSubject.teacherId"
                        label="Select your teacher"
                        type="text"
                        :items="teacherList"
                        item-text="name"
                        item-value="_id"
                        :rules="teacherRules"
                        required
                      ></v-select>
                    </v-flex>
                  </v-layout>
                  <v-layout>
                    <v-flex xs4 sm4 class="pt-4 sybheading">
                      <label class="right">Type :</label>
                    </v-flex>
                    <v-flex xs8 sm8 class="ml-3">
                      <v-select
                        v-model="addSubject.type"
                        :items="type"
                        label="Select your Type"
                        :rules="typeRules"
                        required
                      ></v-select>
                    </v-flex>
                  </v-layout>
                  <v-layout>
                    <v-flex xs4 sm4 class="pt-4 subheading">
                      <label class="right">Pass Mark :</label>
                    </v-flex>
                    <v-flex xs8 sm8 class="ml-3">
                      <v-text-field
                        label="Fill your Pass Mark"
                        name="name"
                        type="text"
                        :rules="markRules"
                        v-model="addSubject.passMarks"
                        required
                      ></v-text-field>
                    </v-flex>
                  </v-layout>
                  <v-layout>
                    <v-flex xs4 sm4 class="pt-4 subheading">
                      <label class="right">Final Mark :</label>
                    </v-flex>
                    <v-flex xs8 sm8 class="ml-3">
                      <v-text-field
                        label="Fill your final mark"
                        name="name"
                        type="text"
                        :rules="finalRules"
                        v-model="addSubject.finalMarks"
                        required
                      ></v-text-field>
                    </v-flex>
                  </v-layout>
                  <v-layout>
                    <v-flex xs4 sm4 class="pt-4 subheading">
                      <label class="right">Subject :</label>
                    </v-flex>
                    <v-flex xs8 sm8 class="ml-3">
                      <v-text-field
                        v-model="addSubject.subjectName"
                        placeholder="fill your Subject Name"
                        name="name"
                        type="text"
                        :rules="subjectRules"
                        required
                      ></v-text-field>
                    </v-flex>
                  </v-layout>
                  <v-layout>
                    <v-flex xs4 sm4 class="pt-4 subheading">
                      <label class="right">Subject Author :</label>
                    </v-flex>
                    <v-flex xs8 sm8 class="ml-3">
                      <v-text-field
                        v-model="addSubject.subjectAuthor"
                        placeholder="fill your Subject Author"
                        name="name"
                        type="text"
                      ></v-text-field>
                    </v-flex>
                  </v-layout>
                  <v-layout>
                    <v-flex xs4 sm4 class="pt-4 subheading">
                      <label class="right">Subject Code:</label>
                    </v-flex>
                    <v-flex xs8 sm8 class="ml-3">
                      <v-text-field
                        v-model="addSubject.subjectCode"
                        placeholder="fill your Subject Code"
                        name="name"
                        type="text"
                      ></v-text-field>
                    </v-flex>
                  </v-layout>
                  <v-layout>
                    <v-flex xs12 sm12>
                      <v-card-actions>
                        <v-spacer></v-spacer>
                        <v-btn
                          @click="submit"
                          round
                          dark
                          :loading="addLoading"
                          class="add-button"
                        >Add Subject</v-btn>
                      </v-card-actions>
                    </v-flex>
                  </v-layout>
                </v-form>
              </v-flex>
            </v-layout>
          </v-container>
        </v-card>
      </v-dialog>
      <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";
  import Util from "@/util";
  
  export default {
    data: () => ({
      snackbar: false,
      y: "top",
      x: "right",
      role: "",
      mode: "",
      timeout: 3000,
      text: "",
      color: "",
      show: true,
      showSearch: false,
      showLoader: false,
      loading: false,
      editLoading: false,
      addLoading: false,
      date: null,
      search: "",
      viewSubjectDialog: false,
      editSubjectDialog: false,
      valid: true,
      validEditSubject: true,
      addSubjectDialog: false,
      // isActive: true,
      // newActive: false,
      type: ["Optional", "Mandatory"],
      pagination: {
b0e0491ab   Shikha Mishra   solve the issue o...
558
        rowsPerPage: 10,
068907f66   Shikha Mishra   improve subject ui
559
560
      },
      token: "",
b0e0491ab   Shikha Mishra   solve the issue o...
561
562
563
564
565
566
      classRules: [(v) => !!v || " Class Name is required"],
      teacherRules: [(v) => !!v || " Teacher Name is required"],
      typeRules: [(v) => !!v || "Type is required"],
      markRules: [(v) => !!v || " Pass Mark is required"],
      finalRules: [(v) => !!v || "Final MArk is required"],
      subjectRules: [(v) => !!v || " Subject Name is required"],
068907f66   Shikha Mishra   improve subject ui
567
568
569
570
571
      headers: [
        {
          text: "No",
          align: "",
          sortable: false,
b0e0491ab   Shikha Mishra   solve the issue o...
572
          value: "No",
068907f66   Shikha Mishra   improve subject ui
573
574
575
576
577
        },
        {
          text: "Subject Name",
          value: "subjectName",
          sortable: false,
b0e0491ab   Shikha Mishra   solve the issue o...
578
          align: "center",
068907f66   Shikha Mishra   improve subject ui
579
580
581
582
583
        },
        {
          text: "Subject Author",
          value: "subjectAuthor",
          sortable: false,
b0e0491ab   Shikha Mishra   solve the issue o...
584
          align: "center",
068907f66   Shikha Mishra   improve subject ui
585
586
587
588
589
        },
        {
          text: "Subject Code",
          value: "subjectCode",
          sortable: false,
b0e0491ab   Shikha Mishra   solve the issue o...
590
          align: "center",
068907f66   Shikha Mishra   improve subject ui
591
592
593
594
595
596
597
598
599
600
601
        },
        // {
        //   text: "Teacher",
        //   value: "teacherId",
        //   sortable: false,
        //   align: "center"
        // },
        {
          text: "Pass Marks",
          value: "passMarks",
          sortable: false,
b0e0491ab   Shikha Mishra   solve the issue o...
602
          align: "center",
068907f66   Shikha Mishra   improve subject ui
603
604
605
606
607
        },
        {
          text: "Final Marks",
          value: "finalMarks",
          sortable: false,
b0e0491ab   Shikha Mishra   solve the issue o...
608
          align: "center",
068907f66   Shikha Mishra   improve subject ui
609
610
611
612
613
        },
        {
          text: "Type",
          value: "type",
          sortable: false,
b0e0491ab   Shikha Mishra   solve the issue o...
614
          align: "center",
068907f66   Shikha Mishra   improve subject ui
615
        },
b039d39fb   Shikha Mishra   Hide Edit functio...
616
        // { text: "Action", value: "", sortable: false, align: "center" }
068907f66   Shikha Mishra   improve subject ui
617
618
619
620
621
622
      ],
      subjectList: [],
      classList: [],
      teacherList: [],
      editedIndex: -1,
      addSubject: {},
b0e0491ab   Shikha Mishra   solve the issue o...
623
      getSubject: {},
068907f66   Shikha Mishra   improve subject ui
624
625
626
627
  
      editedItem: {
        // subjectName: "",
        // subjectAuthor: ""
b0e0491ab   Shikha Mishra   solve the issue o...
628
      },
068907f66   Shikha Mishra   improve subject ui
629
    }),
8e8d14254   Shikha Mishra   Cleared data whil...
630
631
632
633
634
635
636
    watch: {
      addSubjectDialog: function (val) {
        if (!val) {
          this.addSubject = [];
        }
      },
    },
068907f66   Shikha Mishra   improve subject ui
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
    methods: {
      pickFile() {
        this.$refs.image.click();
      },
      editItem(item) {
        this.editedIndex = this.subjectList.subjects;
        this.editedItem = Object.assign({}, item);
        this.dialog = true;
        this.editSubjectDialog = true;
      },
      profile(item) {
        this.editedIndex = this.subjectList.subjects;
        this.editedItem = Object.assign({}, item);
        this.dialog1 = true;
        this.viewSubjectDialog = true;
      },
      deleteItem(item) {
        let deleteSubject = {
          classId: this.addSubject.classId,
b0e0491ab   Shikha Mishra   solve the issue o...
656
          subjectId: item._id,
068907f66   Shikha Mishra   improve subject ui
657
658
659
660
661
        };
        http()
          .delete(
            "/deleteSubject",
            confirm("Are you sure you want to delete this?") && {
b0e0491ab   Shikha Mishra   solve the issue o...
662
              params: deleteSubject,
068907f66   Shikha Mishra   improve subject ui
663
664
            }
          )
b0e0491ab   Shikha Mishra   solve the issue o...
665
          .then((response) => {
068907f66   Shikha Mishra   improve subject ui
666
667
668
669
670
            this.snackbar = true;
            this.color = "green";
            this.text = "Successfully delete Existing Subject";
            this.getClassSubject(this.addSubject.classId);
          })
b0e0491ab   Shikha Mishra   solve the issue o...
671
672
673
674
          .catch((error) => {
            //   this.snackbar = true;
            //   this.text = error.response.data.message;
            //   this.color = "error";
068907f66   Shikha Mishra   improve subject ui
675
676
677
678
679
680
681
682
683
684
685
            console.log("error", error);
          });
      },
      close() {
        this.editSubjectDialog = false;
      },
      close1() {
        this.viewSubjectDialog = false;
      },
      submit() {
        if (this.$refs.form.validate()) {
b0e0491ab   Shikha Mishra   solve the issue o...
686
          this.addLoading = true;
068907f66   Shikha Mishra   improve subject ui
687
688
          http()
            .post("/addSubject", this.addSubject)
b0e0491ab   Shikha Mishra   solve the issue o...
689
            .then((response) => {
068907f66   Shikha Mishra   improve subject ui
690
691
692
693
              this.snackbar = true;
              this.text = "New Subject added successfully";
              this.color = "green";
              this.addLoading = false;
8e8d14254   Shikha Mishra   Cleared data whil...
694
              this.$refs.form.reset();
068907f66   Shikha Mishra   improve subject ui
695
696
697
              this.addSubjectDialog = false;
              this.getClassSubject(_id);
            })
b0e0491ab   Shikha Mishra   solve the issue o...
698
            .catch((error) => {
068907f66   Shikha Mishra   improve subject ui
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
              this.addLoading = false;
            });
        }
      },
      clear() {
        this.$refs.form.reset();
      },
      save() {
        if (this.$refs.formEditSubject.validate()) {
          let editSubject = {
            classId: this.editedItem.classId,
            subjectId: this.editedItem._id,
            teacherId: this.editedItem.teacherId,
            type: this.editedItem.type,
            passMarks: this.editedItem.passMarks,
            finalMarks: this.editedItem.finalMarks,
            subjectAuthor: this.editedItem.subjectAuthor,
            subjectCode: this.editedItem.subjectCode,
b0e0491ab   Shikha Mishra   solve the issue o...
717
            subjectName: this.editedItem.subjectName,
068907f66   Shikha Mishra   improve subject ui
718
719
720
721
          };
          this.editLoading = true;
          http()
            .put("/updateSubject", editSubject)
b0e0491ab   Shikha Mishra   solve the issue o...
722
            .then((response) => {
068907f66   Shikha Mishra   improve subject ui
723
724
725
726
727
728
729
              this.snackbar = true;
              this.text = "Successfully Edit Existing Subject";
              this.color = "green";
              this.editLoading = false;
              this.editSubjectDialog = false;
              this.getClassSubject(this.editedItem.classId);
            })
b0e0491ab   Shikha Mishra   solve the issue o...
730
            .catch((error) => {
068907f66   Shikha Mishra   improve subject ui
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
              this.editLoading = false;
  
              // console.log(error);
            });
        }
      },
      getClassSubject(_id) {
        this.showLoader = true;
        console.log("class", _id);
        // this.classId = this.classId;
        http()
          .get(
            "/getParticularClass",
            { params: { classId: _id } },
            {
b0e0491ab   Shikha Mishra   solve the issue o...
746
              headers: { Authorization: "Bearer " + this.token },
068907f66   Shikha Mishra   improve subject ui
747
748
            }
          )
b0e0491ab   Shikha Mishra   solve the issue o...
749
          .then((response) => {
068907f66   Shikha Mishra   improve subject ui
750
751
752
            this.subjectList = response.data.data;
            this.showLoader = false;
          })
b0e0491ab   Shikha Mishra   solve the issue o...
753
          .catch((err) => {
068907f66   Shikha Mishra   improve subject ui
754
755
756
757
758
759
            this.showLoader = false;
          });
      },
      getClass() {
        http()
          .get("/getClassesList", {
b0e0491ab   Shikha Mishra   solve the issue o...
760
            headers: { Authorization: "Bearer " + this.token },
068907f66   Shikha Mishra   improve subject ui
761
          })
b0e0491ab   Shikha Mishra   solve the issue o...
762
          .then((response) => {
068907f66   Shikha Mishra   improve subject ui
763
764
            this.classList = response.data.data;
          })
b0e0491ab   Shikha Mishra   solve the issue o...
765
          .catch((error) => {
068907f66   Shikha Mishra   improve subject ui
766
767
768
769
770
771
772
773
774
775
776
777
            if (error.response.status === 401) {
              this.$router.replace({ path: "/" });
              this.$store.dispatch("setToken", null);
              this.$store.dispatch("Id", null);
            }
          });
      },
      getTeacherList() {
        this.showLoader = true;
        var token = this.$store.state.token;
        http()
          .get("/getTeachersList", {
b0e0491ab   Shikha Mishra   solve the issue o...
778
            headers: { Authorization: "Bearer " + token },
068907f66   Shikha Mishra   improve subject ui
779
          })
b0e0491ab   Shikha Mishra   solve the issue o...
780
          .then((response) => {
068907f66   Shikha Mishra   improve subject ui
781
782
783
784
            this.teacherList = response.data.data;
            this.showLoader = false;
            // console.log("getTeacherList=====>",this.desserts)
          })
b0e0491ab   Shikha Mishra   solve the issue o...
785
          .catch((error) => {
068907f66   Shikha Mishra   improve subject ui
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
            this.showLoader = false;
            if (error.response.status === 401) {
              this.$router.replace({ path: "/" });
              this.$store.dispatch("setToken", null);
              this.$store.dispatch("Id", null);
            }
          });
      },
      displaySearch() {
        (this.show = false), (this.showSearch = true);
      },
      closeSearch() {
        this.showSearch = false;
        this.show = true;
        this.search = "";
b0e0491ab   Shikha Mishra   solve the issue o...
801
      },
068907f66   Shikha Mishra   improve subject ui
802
803
804
805
806
807
808
    },
    mounted() {
      this.token = this.$store.state.token;
      // this.getNoticeDataList();
      this.getClass();
      this.getTeacherList();
      this.role = this.$store.state.role;
b0e0491ab   Shikha Mishra   solve the issue o...
809
    },
068907f66   Shikha Mishra   improve subject ui
810
811
  };
  </script>