Commit 8e9ce24f1b22dff41ffe8e0da7dcaa46dc6ecc6c

Authored by Shikha Mishra
1 parent 710438de6a

added subject file

Showing 1 changed file with 366 additions and 47 deletions   Show diff stats
src/pages/Subjects/subjects.vue
1 1 <template>
2 2 <v-container fluid class="body-color">
3 3 <!-- ****** EDIT Subject ****** -->
4   - <v-dialog v-model="editSubjectDialog" max-width="400px">
  4 + <v-dialog v-model="editSubjectDialog" max-width="600px">
5 5 <v-card flat class="card-style pa-2" dark>
6 6 <v-layout>
7 7 <v-flex xs12>
... ... @@ -17,18 +17,79 @@
17 17 </v-flex>
18 18 <v-flex xs8 class="ml-3">
19 19 <v-select
  20 + v-model="editedItem.classId"
  21 + label="Select your class"
  22 + type="text"
20 23 :items="classList"
21   - label="Select Class"
22   - v-model="addSubject.selectName"
23 24 item-text="classNum"
24 25 item-value="_id"
25   - name="Select Class"
26   - :rules="nameEditSubjectRules"
  26 + :rules="classRules"
  27 + required
  28 + ></v-select>
  29 + </v-flex>
  30 + </v-layout>
  31 + <v-layout>
  32 + <v-flex xs4 sm4 class="pt-4 subheading">
  33 + <label class="right">Teacher Name :</label>
  34 + </v-flex>
  35 + <v-flex xs8 sm8 class="ml-3">
  36 + <v-select
  37 + v-model="editedItem.teacherId"
  38 + label="Select your teacher"
  39 + type="text"
  40 + :items="teacherList"
  41 + item-text="name"
  42 + item-value="_id"
  43 + :rules="teacherRules"
  44 + required
  45 + ></v-select>
  46 + </v-flex>
  47 + </v-layout>
  48 + <v-layout>
  49 + <v-flex xs4 sm4 class="pt-4 sybheading">
  50 + <label class="right">Type :</label>
  51 + </v-flex>
  52 + <v-flex xs8 sm8 class="ml-3">
  53 + <v-select
  54 + v-model="editedItem.type"
  55 + :items="type"
  56 + label="Select your Type"
  57 + :rules="typeRules"
27 58 required
28 59 ></v-select>
29 60 </v-flex>
30 61 </v-layout>
31 62 <v-layout>
  63 + <v-flex xs4 sm4 class="pt-4 subheading">
  64 + <label class="right">Pass Mark :</label>
  65 + </v-flex>
  66 + <v-flex xs8 sm8 class="ml-3">
  67 + <v-text-field
  68 + label="Fill your Pass Mark"
  69 + name="name"
  70 + type="text"
  71 + :rules="markRules"
  72 + v-model="editedItem.passMarks"
  73 + required
  74 + ></v-text-field>
  75 + </v-flex>
  76 + </v-layout>
  77 + <v-layout>
  78 + <v-flex xs4 sm4 class="pt-4 subheading">
  79 + <label class="right">Final Mark :</label>
  80 + </v-flex>
  81 + <v-flex xs8 sm8 class="ml-3">
  82 + <v-text-field
  83 + label="Fill your final mark"
  84 + name="name"
  85 + type="text"
  86 + :rules="finalRules"
  87 + v-model="editedItem.finalMarks"
  88 + required
  89 + ></v-text-field>
  90 + </v-flex>
  91 + </v-layout>
  92 + <v-layout>
32 93 <v-flex xs4 class="pt-4 subheading">
33 94 <label class="right">Subject:</label>
34 95 </v-flex>
... ... @@ -36,18 +97,43 @@
36 97 <v-text-field
37 98 placeholder="fill your Subject"
38 99 v-model="editedItem.subjectName"
39   - :rules="subjectEditNameRules"
  100 + :rules="subjectRules"
40 101 type="text"
41 102 name="email"
42 103 required
43 104 ></v-text-field>
44 105 </v-flex>
45 106 </v-layout>
  107 + <v-layout>
  108 + <v-flex xs4 sm4 class="pt-4 subheading">
  109 + <label class="right">Subject Author :</label>
  110 + </v-flex>
  111 + <v-flex xs8 sm8 class="ml-3">
  112 + <v-text-field
  113 + v-model="editedItem.subjectAuthor"
  114 + placeholder="fill your Subject Author"
  115 + name="name"
  116 + type="text"
  117 + ></v-text-field>
  118 + </v-flex>
  119 + </v-layout>
  120 + <v-layout>
  121 + <v-flex xs4 sm4 class="pt-4 subheading">
  122 + <label class="right">Subject Code:</label>
  123 + </v-flex>
  124 + <v-flex xs8 sm8 class="ml-3">
  125 + <v-text-field
  126 + v-model="editedItem.subjectCode"
  127 + placeholder="fill your Subject Code"
  128 + name="name"
  129 + type="text"
  130 + ></v-text-field>
  131 + </v-flex>
  132 + </v-layout>
46 133 <v-flex xs12 sm12>
47 134 <v-card-actions>
48   - <v-btn round dark @click.native="close" class="clear-button">Cancel</v-btn>
49 135 <v-spacer></v-spacer>
50   - <v-btn round dark @click="save" :loading="editLoading" class="add-button">Save</v-btn>
  136 + <v-btn round dark @click="save" :loading="editLoading" class="add-button">Update Subject</v-btn>
51 137 </v-card-actions>
52 138 </v-flex>
53 139 </v-form>
... ... @@ -57,30 +143,88 @@
57 143  
58 144 <!-- ****** VIEW PROFIL NOTICE BOARD ****** -->
59 145  
60   - <v-dialog v-model="viewSubjectDialog" max-width="600px">
61   - <v-toolbar flat class="card-style pa-3" dark>
62   - <v-spacer></v-spacer>
63   - <v-toolbar-title>
64   - <h3>Subject</h3>
65   - </v-toolbar-title>
66   - <v-spacer></v-spacer>
67   - <v-icon @click="close1">close</v-icon>
68   - </v-toolbar>
69   - <v-card>
  146 + <v-dialog v-model="viewSubjectDialog" max-width="500px">
  147 + <v-card flat class="card-style pa-3" dark>
  148 + <v-layout>
  149 + <v-flex xs12>
  150 + <label class="title text-xs-center">View Subject</label>
  151 + <v-icon size="24" class="right" @click="viewSubjectDialog = false">cancel</v-icon>
  152 + </v-flex>
  153 + </v-layout>
70 154 <v-card-text>
71 155 <v-container grid-list-md>
72 156 <v-layout wrap>
73 157 <v-flex>
74 158 <v-layout>
75   - <v-flex xs7 sm6>
  159 + <v-flex xs6 sm4>
76 160 <h5 class="right my-1">
77 161 <b>Subject Name:</b>
78 162 </h5>
79 163 </v-flex>
80   - <v-flex sm6 xs5>
  164 + <v-flex sm8 xs6>
81 165 <h5 class="my-1">{{ editedItem.subjectName }}</h5>
82 166 </v-flex>
83 167 </v-layout>
  168 + <v-layout>
  169 + <v-flex xs6 sm4>
  170 + <h5 class="right my-1">
  171 + <b>Subject Author:</b>
  172 + </h5>
  173 + </v-flex>
  174 + <v-flex sm8 xs6>
  175 + <h5 class="my-1">{{ editedItem.subjectAuthor }}</h5>
  176 + </v-flex>
  177 + </v-layout>
  178 + <v-layout>
  179 + <v-flex xs6 sm4>
  180 + <h5 class="right my-1">
  181 + <b>Subject :</b>
  182 + </h5>
  183 + </v-flex>
  184 + <v-flex sm8 xs6>
  185 + <h5 class="my-1">{{ editedItem.subjectCode }}</h5>
  186 + </v-flex>
  187 + </v-layout>
  188 + <!-- <v-layout>
  189 + <v-flex xs6 sm4>
  190 + <h5 class="right my-1">
  191 + <b>Teacher :</b>
  192 + </h5>
  193 + </v-flex>
  194 + <v-flex sm8 xs6>
  195 + <h5 class="my-1">{{ editedItem.teacherId }}</h5>
  196 + </v-flex>
  197 + </v-layout>-->
  198 + <v-layout>
  199 + <v-flex xs6 sm4>
  200 + <h5 class="right my-1">
  201 + <b>Pass Marks :</b>
  202 + </h5>
  203 + </v-flex>
  204 + <v-flex sm8 xs6>
  205 + <h5 class="my-1">{{ editedItem.passMarks }}</h5>
  206 + </v-flex>
  207 + </v-layout>
  208 + <v-layout>
  209 + <v-flex xs6 sm4>
  210 + <h5 class="right my-1">
  211 + <b>Final Marks :</b>
  212 + </h5>
  213 + </v-flex>
  214 + <v-flex sm8 xs6>
  215 + <h5 class="my-1">{{ editedItem.finalMarks }}</h5>
  216 + </v-flex>
  217 + </v-layout>
  218 + <v-layout>
  219 + <v-flex xs6 sm4>
  220 + <h5 class="right my-1">
  221 + <b>Type :</b>
  222 + </h5>
  223 + </v-flex>
  224 + <v-flex sm8 xs6>
  225 + <h5 class="my-1">{{ editedItem.type }}</h5>
  226 + </v-flex>
  227 + </v-layout>
84 228 </v-flex>
85 229 </v-layout>
86 230 </v-container>
... ... @@ -100,7 +244,13 @@
100 244 <v-icon dark>add</v-icon>
101 245 </v-btn>
102 246 <v-flex xs1 class="hidden-sm-only hidden-xs-only">
103   - <v-btn round class="open-dialog-button" dark @click="addSubjectDialog = true">
  247 + <v-btn
  248 + round
  249 + class="open-dialog-button"
  250 + dark
  251 + @click="addSubjectDialog = true"
  252 + v-if="role != 'TEACHER' "
  253 + >
104 254 <v-icon class="white--text pr-1" size="20">add</v-icon>Add Subject
105 255 </v-btn>
106 256 </v-flex>
... ... @@ -109,11 +259,11 @@
109 259 <v-select
110 260 :items="classList"
111 261 label="Select Your Class"
112   - v-model="selectClassId"
  262 + v-model="addSubject.classId"
113 263 item-text="classNum"
114 264 item-value="_id"
115 265 name="Select Class"
116   - :rules="nameRules"
  266 + :rules="classRules"
117 267 @change="getClassSubject"
118 268 class="pl-2"
119 269 required
... ... @@ -149,9 +299,16 @@
149 299 <tr class="tr">
150 300 <td class="td-row td">{{ props.index + 1 }}</td>
151 301 <td class="text-xs-center td td-row">{{ props.item.subjectName }}</td>
  302 + <td class="text-xs-center td td-row">{{ props.item.subjectAuthor }}</td>
  303 + <td class="text-xs-center td td-row">{{ props.item.subjectCode }}</td>
  304 + <!-- <td class="text-xs-center td td-row">{{ props.item.teacherId }}</td> -->
  305 + <td class="text-xs-center td td-row">{{ props.item.passMarks }}</td>
  306 + <td class="text-xs-center td td-row">{{ props.item.finalMarks }}</td>
  307 + <td class="text-xs-center td td-row">{{ props.item.type }}</td>
  308 +
152 309 <td class="text-xs-center td td-row">
153 310 <span>
154   - <v-tooltip top>
  311 + <!-- <v-tooltip top>
155 312 <img
156 313 slot="activator"
157 314 style="cursor:pointer; width:25px; height:25px; "
... ... @@ -160,7 +317,7 @@
160 317 src="/static/icon/view.png"
161 318 />
162 319 <span>View</span>
163   - </v-tooltip>
  320 + </v-tooltip>-->
164 321 <v-tooltip top>
165 322 <img
166 323 slot="activator"
... ... @@ -201,7 +358,7 @@
201 358 v-model="snackbar"
202 359 :color="color"
203 360 >{{ text }}</v-snackbar>
204   - <v-dialog v-model="addSubjectDialog" max-width="400px">
  361 + <v-dialog v-model="addSubjectDialog" max-width="600px">
205 362 <v-card flat class="card-style pa-2" dark>
206 363 <v-layout>
207 364 <v-flex xs12>
... ... @@ -215,7 +372,7 @@
215 372 <v-form ref="form" v-model="valid" lazy-validation>
216 373 <v-layout>
217 374 <v-flex xs4 sm4 class="pt-4 subheading">
218   - <label class="right">Class :</label>
  375 + <label class="right">Class Name :</label>
219 376 </v-flex>
220 377 <v-flex xs8 sm8 class="ml-3">
221 378 <v-select
... ... @@ -225,13 +382,74 @@
225 382 :items="classList"
226 383 item-text="classNum"
227 384 item-value="_id"
228   - :rules="nameRules"
  385 + :rules="classRules"
229 386 required
230 387 ></v-select>
231 388 </v-flex>
232 389 </v-layout>
233 390 <v-layout>
234 391 <v-flex xs4 sm4 class="pt-4 subheading">
  392 + <label class="right">Teacher Name :</label>
  393 + </v-flex>
  394 + <v-flex xs8 sm8 class="ml-3">
  395 + <v-select
  396 + v-model="addSubject.teacherId"
  397 + label="Select your teacher"
  398 + type="text"
  399 + :items="teacherList"
  400 + item-text="name"
  401 + item-value="_id"
  402 + :rules="teacherRules"
  403 + required
  404 + ></v-select>
  405 + </v-flex>
  406 + </v-layout>
  407 + <v-layout>
  408 + <v-flex xs4 sm4 class="pt-4 sybheading">
  409 + <label class="right">Type :</label>
  410 + </v-flex>
  411 + <v-flex xs8 sm8 class="ml-3">
  412 + <v-select
  413 + v-model="addSubject.type"
  414 + :items="type"
  415 + label="Select your Type"
  416 + :rules="typeRules"
  417 + required
  418 + ></v-select>
  419 + </v-flex>
  420 + </v-layout>
  421 + <v-layout>
  422 + <v-flex xs4 sm4 class="pt-4 subheading">
  423 + <label class="right">Pass Mark :</label>
  424 + </v-flex>
  425 + <v-flex xs8 sm8 class="ml-3">
  426 + <v-text-field
  427 + label="Fill your Pass Mark"
  428 + name="name"
  429 + type="text"
  430 + :rules="markRules"
  431 + v-model="addSubject.passMarks"
  432 + required
  433 + ></v-text-field>
  434 + </v-flex>
  435 + </v-layout>
  436 + <v-layout>
  437 + <v-flex xs4 sm4 class="pt-4 subheading">
  438 + <label class="right">Final Mark :</label>
  439 + </v-flex>
  440 + <v-flex xs8 sm8 class="ml-3">
  441 + <v-text-field
  442 + label="Fill your final mark"
  443 + name="name"
  444 + type="text"
  445 + :rules="finalRules"
  446 + v-model="addSubject.finalMarks"
  447 + required
  448 + ></v-text-field>
  449 + </v-flex>
  450 + </v-layout>
  451 + <v-layout>
  452 + <v-flex xs4 sm4 class="pt-4 subheading">
235 453 <label class="right">Subject :</label>
236 454 </v-flex>
237 455 <v-flex xs8 sm8 class="ml-3">
... ... @@ -246,11 +464,42 @@
246 464 </v-flex>
247 465 </v-layout>
248 466 <v-layout>
  467 + <v-flex xs4 sm4 class="pt-4 subheading">
  468 + <label class="right">Subject Author :</label>
  469 + </v-flex>
  470 + <v-flex xs8 sm8 class="ml-3">
  471 + <v-text-field
  472 + v-model="addSubject.subjectAuthor"
  473 + placeholder="fill your Subject Author"
  474 + name="name"
  475 + type="text"
  476 + ></v-text-field>
  477 + </v-flex>
  478 + </v-layout>
  479 + <v-layout>
  480 + <v-flex xs4 sm4 class="pt-4 subheading">
  481 + <label class="right">Subject Code:</label>
  482 + </v-flex>
  483 + <v-flex xs8 sm8 class="ml-3">
  484 + <v-text-field
  485 + v-model="addSubject.subjectCode"
  486 + placeholder="fill your Subject Code"
  487 + name="name"
  488 + type="text"
  489 + ></v-text-field>
  490 + </v-flex>
  491 + </v-layout>
  492 + <v-layout>
249 493 <v-flex xs12 sm12>
250 494 <v-card-actions>
251   - <v-btn @click="clear" round dark class="clear-button">Clear</v-btn>
252 495 <v-spacer></v-spacer>
253   - <v-btn @click="submit" round dark :loading="loading" class="add-button">Add</v-btn>
  496 + <v-btn
  497 + @click="submit"
  498 + round
  499 + dark
  500 + :loading="loading"
  501 + class="add-button"
  502 + >Add Subject</v-btn>
254 503 </v-card-actions>
255 504 </v-flex>
256 505 </v-layout>
... ... @@ -275,6 +524,7 @@ export default {
275 524 snackbar: false,
276 525 y: "top",
277 526 x: "right",
  527 + role: "",
278 528 mode: "",
279 529 timeout: 3000,
280 530 text: "",
... ... @@ -293,15 +543,17 @@ export default {
293 543 addSubjectDialog: false,
294 544 // isActive: true,
295 545 // newActive: false,
296   - gender: ["Male", "Female"],
  546 + type: ["Optional", "Mandatory"],
297 547 pagination: {
298 548 rowsPerPage: 10
299 549 },
300 550 token: "",
301   - nameRules: [v => !!v || " Class Name is required"],
302   - nameEditSubjectRules: [v => !!v || " Class Name is required"],
  551 + classRules: [v => !!v || " Class Name is required"],
  552 + teacherRules: [v => !!v || " Teacher Name is required"],
  553 + typeRules: [v => !!v || "Type is required"],
  554 + markRules: [v => !!v || " Pass Mark is required"],
  555 + finalRules: [v => !!v || "Final MArk is required"],
303 556 subjectRules: [v => !!v || " Subject Name is required"],
304   - subjectEditNameRules: [v => !!v || " Subject Name is required"],
305 557 headers: [
306 558 {
307 559 text: "No",
... ... @@ -315,16 +567,53 @@ export default {
315 567 sortable: false,
316 568 align: "center"
317 569 },
  570 + {
  571 + text: "Subject Author",
  572 + value: "subjectAuthor",
  573 + sortable: false,
  574 + align: "center"
  575 + },
  576 + {
  577 + text: "Subject Code",
  578 + value: "subjectCode",
  579 + sortable: false,
  580 + align: "center"
  581 + },
  582 + // {
  583 + // text: "Teacher",
  584 + // value: "teacherId",
  585 + // sortable: false,
  586 + // align: "center"
  587 + // },
  588 + {
  589 + text: "Pass Marks",
  590 + value: "passMarks",
  591 + sortable: false,
  592 + align: "center"
  593 + },
  594 + {
  595 + text: "Final Marks",
  596 + value: "finalMarks",
  597 + sortable: false,
  598 + align: "center"
  599 + },
  600 + {
  601 + text: "Type",
  602 + value: "type",
  603 + sortable: false,
  604 + align: "center"
  605 + },
318 606 { text: "Action", value: "", sortable: false, align: "center" }
319 607 ],
320 608 subjectList: [],
321 609 classList: [],
  610 + teacherList: [],
322 611 editedIndex: -1,
323 612 addSubject: {},
324   - selectClassId: "",
325   - selectClassId: "",
  613 +
326 614 editedItem: {
327   - subjectName: ""
  615 + // subjectName: "",
  616 + // subjectAuthor: ""
328 617 }
329 618 }),
330 619 methods: {
... ... @@ -342,11 +631,10 @@ export default {
342 631 this.editedItem = Object.assign({}, item);
343 632 this.dialog1 = true;
344 633 this.viewSubjectDialog = true;
345   -
346 634 },
347 635 deleteItem(item) {
348 636 let deleteSubject = {
349   - classId: this.selectClassId,
  637 + classId: this.addSubject.classId,
350 638 subjectId: item._id
351 639 };
352 640 http()
... ... @@ -357,9 +645,10 @@ export default {
357 645 }
358 646 )
359 647 .then(response => {
360   - this.getClassSubject();
  648 + this.getClassSubject(_id);
361 649 this.snackbar = true;
362 650 this.text = "Successfully delete Existing Subject";
  651 + this.color = "green";
363 652 })
364 653 .catch(error => {
365 654 this.snackbar = true;
... ... @@ -378,7 +667,7 @@ export default {
378 667 http()
379 668 .post("/addSubject", this.addSubject)
380 669 .then(response => {
381   - this.getClassSubject();
  670 + this.getClassSubject(_id);
382 671 this.snackbar = true;
383 672 this.text = "New Subject added successfully";
384 673 this.clear();
... ... @@ -399,8 +688,14 @@ export default {
399 688 save() {
400 689 if (this.$refs.formEditSubject.validate()) {
401 690 let editSubject = {
402   - classId: this.addSubject.selectName,
  691 + classId: this.editedItem.classId,
403 692 subjectId: this.editedItem._id,
  693 + teacherId: this.editedItem.teacherId,
  694 + type: this.editedItem.type,
  695 + passMarks: this.editedItem.passMarks,
  696 + finalMarks: this.editedItem.finalMarks,
  697 + subjectAuthor: this.editedItem.subjectAuthor,
  698 + subjectCode: this.editedItem.subjectCode,
404 699 subjectName: this.editedItem.subjectName
405 700 };
406 701 this.editLoading = true;
... ... @@ -409,18 +704,19 @@ export default {
409 704 .then(response => {
410 705 this.snackbar = true;
411 706 this.text = "Successfully Edit Existing Subject";
  707 + this.color = "green";
412 708 this.editLoading = false;
  709 + this.editSubjectDialog = false;
413 710 http()
414 711 .get(
415 712 "/getParticularClass",
416   - { params: { classId: this.selectClassId } },
  713 + { params: { classId: _id } },
417 714 {
418 715 headers: { Authorization: "Bearer " + this.token }
419 716 }
420 717 )
421 718 .then(response => {
422 719 this.subjectList = response.data.data;
423   - this.getClassSubject();
424 720 this.snackbar = true;
425 721 this.color = "green";
426 722 this.text = response.data.message;
... ... @@ -437,13 +733,13 @@ export default {
437 733 });
438 734 }
439 735 },
440   - getClassSubject() {
  736 + getClassSubject(_id) {
441 737 this.showLoader = true;
442   - this.selectClassId = this.selectClassId;
  738 + // this.classId = this.classId;
443 739 http()
444 740 .get(
445 741 "/getParticularClass",
446   - { params: { classId: this.selectClassId } },
  742 + { params: { classId: _id } },
447 743 {
448 744 headers: { Authorization: "Bearer " + this.token }
449 745 }
... ... @@ -472,6 +768,27 @@ export default {
472 768 }
473 769 });
474 770 },
  771 + getTeacherList() {
  772 + this.showLoader = true;
  773 + var token = this.$store.state.token;
  774 + http()
  775 + .get("/getTeachersList", {
  776 + headers: { Authorization: "Bearer " + token }
  777 + })
  778 + .then(response => {
  779 + this.teacherList = response.data.data;
  780 + this.showLoader = false;
  781 + // console.log("getTeacherList=====>",this.desserts)
  782 + })
  783 + .catch(error => {
  784 + this.showLoader = false;
  785 + if (error.response.status === 401) {
  786 + this.$router.replace({ path: "/" });
  787 + this.$store.dispatch("setToken", null);
  788 + this.$store.dispatch("Id", null);
  789 + }
  790 + });
  791 + },
475 792 displaySearch() {
476 793 (this.show = false), (this.showSearch = true);
477 794 },
... ... @@ -485,6 +802,8 @@ export default {
485 802 this.token = this.$store.state.token;
486 803 // this.getNoticeDataList();
487 804 this.getClass();
  805 + this.getTeacherList();
  806 + this.role = this.$store.state.role;
488 807 }
489 808 };
490 809 </script>
491 810 \ No newline at end of file
... ...