Commit d84fa5db262e10f7a8c5c14061064e6966c8dec8

Authored by Amber Dev
1 parent f35ab5f436

bugs in report id

package-lock.json
... ... @@ -13867,9 +13867,9 @@
13867 13867 "dev": true
13868 13868 },
13869 13869 "qs": {
13870   - "version": "6.5.2",
13871   - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz",
13872   - "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA=="
  13870 + "version": "6.9.4",
  13871 + "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.4.tgz",
  13872 + "integrity": "sha512-A1kFqHekCTM7cz0udomYUoYNWjBebHm/5wzU/XqrBRBNWectVH0QIiN+NEcZ0Dte5hvzHwbr8+XQmguPhJ6WdQ=="
13873 13873 },
13874 13874 "query-string": {
13875 13875 "version": "4.3.4",
... ... @@ -14348,6 +14348,13 @@
14348 14348 "tough-cookie": "~2.5.0",
14349 14349 "tunnel-agent": "^0.6.0",
14350 14350 "uuid": "^3.3.2"
  14351 + },
  14352 + "dependencies": {
  14353 + "qs": {
  14354 + "version": "6.5.2",
  14355 + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz",
  14356 + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA=="
  14357 + }
14351 14358 }
14352 14359 },
14353 14360 "request-promise-core": {
... ...
... ... @@ -28,6 +28,7 @@
28 28 "moment": "^2.24.0",
29 29 "nprogress": "^0.2.0",
30 30 "papaparse": "^5.1.1",
  31 + "qs": "^6.9.4",
31 32 "quill": "^1.3.6",
32 33 "save": "^2.4.0",
33 34 "underscore": "^1.9.1",
... ...
src/pages/Report/idCard.vue
... ... @@ -13,13 +13,14 @@
13 13 label="Select Type"
14 14 :items="getRoles"
15 15 item-text="name"
16   - item-value="role"
  16 + return-object
17 17 @change="getRoleInputs(getReport.role)"
18 18 required
19 19 ></v-autocomplete>
20 20 </v-flex>
21 21 </v-layout>
22 22 </v-flex>
  23 + <!-- SELECT CLASS -->
23 24 <v-flex xs12 sm12 lg4 v-if="showClass">
24 25 <v-layout>
25 26 <v-flex xs12 sm12 lg10 class="ml-2">
... ... @@ -35,6 +36,7 @@
35 36 </v-flex>
36 37 </v-layout>
37 38 </v-flex>
  39 + <!-- SELECT SECTION -->
38 40 <v-flex xs12 sm12 lg4 v-if="showSections">
39 41 <v-layout>
40 42 <v-flex xs12 sm12 lg10 class="ml-2">
... ... @@ -51,6 +53,7 @@
51 53 </v-flex>
52 54 </v-layout>
53 55 </v-flex>
  56 + <!-- SELECT STUDENT -->
54 57 <v-flex xs12 sm12 lg4 v-if="showStudents">
55 58 <v-layout>
56 59 <v-flex xs12 sm12 lg10 class="ml-2">
... ... @@ -420,6 +423,7 @@
420 423 <script>
421 424 import http from "@/Services/http.js";
422 425 import moment from "moment";
  426 +var qs = require("qs");
423 427  
424 428 export default {
425 429 data: () => ({
... ... @@ -456,18 +460,18 @@ export default {
456 460 getSelectUserData: [],
457 461 // Users: [],
458 462 getReport: {},
459   - typeRules: [v => !!v || "Type is required"],
  463 + typeRules: [(v) => !!v || "Type is required"],
460 464 typeList: [
461 465 {
462 466 name: "Front Part",
463   - value: "frontPart"
  467 + value: "frontPart",
464 468 },
465 469 {
466 470 name: "Back Part",
467   - value: "backPart"
468   - }
  471 + value: "backPart",
  472 + },
469 473 ],
470   - backgroundList: ["Yes", "No"]
  474 + backgroundList: ["Yes", "No"],
471 475 }),
472 476  
473 477 mounted() {
... ... @@ -477,7 +481,7 @@ export default {
477 481 },
478 482  
479 483 methods: {
480   - dates: function(date) {
  484 + dates: function (date) {
481 485 return moment(date).format("MMMM DD, YYYY");
482 486 return date;
483 487 },
... ... @@ -496,7 +500,7 @@ export default {
496 500 this.showReport = false;
497 501 this.getReport._id = "";
498 502 this.getCard = "";
499   - if (role === 4) {
  503 + if (role.name === "STUDENT") {
500 504 // console.log("role", role);
501 505 this.showClass = true;
502 506 this.showTeacher = false;
... ... @@ -507,7 +511,7 @@ export default {
507 511 this.showSections = false;
508 512 this.getClass();
509 513 }
510   - if (role === 3) {
  514 + if (role.name === "TEACHER") {
511 515 this.showTeacher = true;
512 516 this.showClass = false;
513 517 this.showAdmin = false;
... ... @@ -517,7 +521,7 @@ export default {
517 521 this.showSections = false;
518 522 this.getTeacherList();
519 523 }
520   - if (role === 2) {
  524 + if (role.name === "ADMIN") {
521 525 this.showAdmin = true;
522 526 this.showTeacher = false;
523 527 this.showClass = false;
... ... @@ -527,7 +531,7 @@ export default {
527 531 this.showSections = false;
528 532 this.getUserData();
529 533 }
530   - if (role === 6) {
  534 + if (role.name === "ACCOUNTANT") {
531 535 this.showAccountant = true;
532 536 this.showAdmin = false;
533 537 this.showTeacher = false;
... ... @@ -535,9 +539,9 @@ export default {
535 539 this.showLibrarian = false;
536 540 this.showStudents = false;
537 541 this.showSections = false;
538   - this.getUsersList(role);
  542 + this.getUsersList(role.role);
539 543 }
540   - if (role === 7) {
  544 + if (role.name === "LIBRARIAN") {
541 545 this.showLibrarian = true;
542 546 this.showAccountant = false;
543 547 this.showAdmin = false;
... ... @@ -545,7 +549,7 @@ export default {
545 549 this.showClass = false;
546 550 this.showStudents = false;
547 551 this.showSections = false;
548   - this.getUsersList(role);
  552 + this.getUsersList(role.role);
549 553 }
550 554 },
551 555  
... ... @@ -558,10 +562,10 @@ export default {
558 562 this.showLoader = true;
559 563 http()
560 564 .get("/getParticularUserDetail")
561   - .then(response => {
  565 + .then((response) => {
562 566 let mergeObj = {
563 567 name: "Select All",
564   - id: "Select All"
  568 + id: "Select All",
565 569 };
566 570 this.getSelectUserData.push(mergeObj);
567 571 let getUserDetails = response.data.data;
... ... @@ -569,7 +573,7 @@ export default {
569 573 this.showLoader = false;
570 574 // this.adminList = response.data.data;
571 575 })
572   - .catch(error => {
  576 + .catch((error) => {
573 577 this.showLoader = false;
574 578 if (error.response.status === 401) {
575 579 this.$router.replace({ path: "/" });
... ... @@ -582,19 +586,22 @@ export default {
582 586 this.showLoader = true;
583 587 http()
584 588 .get("/getRolesList", {
585   - headers: { Authorization: "Bearer " + this.token }
  589 + headers: { Authorization: "Bearer " + this.token },
586 590 })
587   - .then(response => {
  591 + .then((response) => {
588 592 var getRoles = [];
589 593 getRoles = response.data.data;
590 594 for (let i = 0; i < getRoles.length; i++) {
591   - if (getRoles[i].role != "1" && getRoles[i].role != "5") {
  595 + if (
  596 + getRoles[i].name != "SUPERADMIN" &&
  597 + getRoles[i].name != "PARENT"
  598 + ) {
592 599 this.getRoles.push(getRoles[i]);
593 600 }
594 601 }
595 602 this.showLoader = false;
596 603 })
597   - .catch(error => {
  604 + .catch((error) => {
598 605 this.showLoader = false;
599 606 if (error.response.status === 401) {
600 607 this.$router.replace({ path: "/" });
... ... @@ -609,13 +616,13 @@ export default {
609 616 this.showLoader = true;
610 617 http()
611 618 .get("/getClassesList", {
612   - headers: { Authorization: "Bearer " + this.token }
  619 + headers: { Authorization: "Bearer " + this.token },
613 620 })
614   - .then(response => {
  621 + .then((response) => {
615 622 this.classList = response.data.data;
616 623 this.showLoader = false;
617 624 })
618   - .catch(error => {
  625 + .catch((error) => {
619 626 this.showLoader = false;
620 627 // console.log("err====>", err);
621 628 });
... ... @@ -627,15 +634,15 @@ export default {
627 634 "/getSectionsList",
628 635 { params: { classId: _id } },
629 636 {
630   - headers: { Authorization: "Bearer " + this.token }
  637 + headers: { Authorization: "Bearer " + this.token },
631 638 }
632 639 )
633   - .then(response => {
  640 + .then((response) => {
634 641 this.addSection = response.data.data;
635 642 this.showSections = true;
636 643 this.showLoader = false;
637 644 })
638   - .catch(err => {
  645 + .catch((err) => {
639 646 this.showLoader = false;
640 647 // console.log("err====>", err);
641 648 });
... ... @@ -647,19 +654,19 @@ export default {
647 654 .get("/getStudentWithClass", {
648 655 params: {
649 656 classId: this.getReport.classId,
650   - sectionId: this.getReport.sectionId
651   - }
  657 + sectionId: this.getReport.sectionId,
  658 + },
652 659 })
653   - .then(response => {
  660 + .then((response) => {
654 661 response.data.data.unshift({
655 662 name: "Select All",
656   - _id: "Select All"
  663 + _id: "Select All",
657 664 });
658 665 this.getSelectUserData = response.data.data;
659 666 this.showStudents = true;
660 667 this.showLoader = false;
661 668 })
662   - .catch(error => {
  669 + .catch((error) => {
663 670 console.log("err====>", error);
664 671 this.showLoader = false;
665 672 });
... ... @@ -669,42 +676,43 @@ export default {
669 676 var getSelectUserId = [];
670 677 for (let i = 0; i < this.getSelectUserData.length; i++) {
671 678 console.log("this.getReport._id", this.getReport._id);
  679 + /* if the selected user id mathches any id in the original user data then push it in
  680 + array, this way only one id will be pushed */
672 681 if (this.getReport._id === this.getSelectUserData[i]._id) {
673   - console.log(
674   - "this.getSelectUserData[i]._id------------",
675   - this.getSelectUserData[i]._id
676   - );
677 682 getSelectUserId.push(this.getSelectUserData[i]._id);
678   - } else if (this.getReport._id == "Select All") {
679   - console.log(
680   - "this.getSelectUserData[i]._id)",
681   - this.getSelectUserData[i]._id
682   - );
  683 + } /* else if select all option is selected then all ids will be pushed */ else if (
  684 + this.getReport._id == "Select All"
  685 + ) {
683 686 getSelectUserId.push(this.getSelectUserData[i]._id);
684   - if (getSelectUserId[0] == undefined) {
685   - delete getSelectUserId[0];
  687 + if (
  688 + getSelectUserId[0] == undefined ||
  689 + getSelectUserId[0] == "Select All"
  690 + ) {
  691 + getSelectUserId.shift();
686 692 }
687 693 }
688 694 }
689   - console.log(
690   - // "this.getSelectUserData[i]._id",/
691   - // this.getSelectUserData[i]._id,
692   - "getSelectUserId",
693   - getSelectUserId
694   - );
  695 +
695 696 if (this.$refs.form.validate()) {
696 697 this.showLoader = true;
  698 + // var strigified = JSON.stringify(getSelectUserId)
  699 + // var profileId = [];
  700 + // profileId = getSelectUserId;
697 701 http()
698 702 .get("/getIdCardDetail", {
699 703 headers: {
700   - Authorization: "Bearer " + this.token
  704 + Authorization: "Bearer " + this.token,
701 705 },
702   - params: {
703   - profileId: getSelectUserId,
704   - role: this.getReport.role
705   - }
  706 + params: { profileId: getSelectUserId, role: this.getReport.role.role, },
  707 + paramsSerializer: (params) => {
  708 + return qs.stringify(params);
  709 + },
  710 + // params: {
  711 + // profileId: strigified,
  712 + // role: this.getReport.role.role,
  713 + // },
706 714 })
707   - .then(response => {
  715 + .then((response) => {
708 716 this.getCard = "";
709 717 var data = response.data.data;
710 718 if (
... ... @@ -739,7 +747,7 @@ export default {
739 747 this.showLoader = false;
740 748 this.showReport = true;
741 749 })
742   - .catch(error => {
  750 + .catch((error) => {
743 751 this.showLoader = false;
744 752 // console.log("error", error.response.data.errors);
745 753 if (error.response.data.errors) {
... ... @@ -756,17 +764,17 @@ export default {
756 764 var token = this.$store.state.token;
757 765 http()
758 766 .get("/getTeachersList", {
759   - headers: { Authorization: "Bearer " + token }
  767 + headers: { Authorization: "Bearer " + token },
760 768 })
761   - .then(response => {
  769 + .then((response) => {
762 770 response.data.data.unshift({
763 771 name: "Select All",
764   - _id: "Select All"
  772 + _id: "Select All",
765 773 });
766 774 this.getSelectUserData = response.data.data;
767 775 this.showLoader = false;
768 776 })
769   - .catch(error => {
  777 + .catch((error) => {
770 778 this.showLoader = false;
771 779 if (error.response.status === 401) {
772 780 this.$router.replace({ path: "/" });
... ... @@ -781,17 +789,17 @@ export default {
781 789 var token = this.$store.state.token;
782 790 http()
783 791 .get("/getUsersList?role=" + role, {
784   - headers: { Authorization: "Bearer " + token }
  792 + headers: { Authorization: "Bearer " + token },
785 793 })
786   - .then(response => {
  794 + .then((response) => {
787 795 response.data.data.unshift({
788 796 name: "Select All",
789   - _id: "Select All"
  797 + _id: "Select All",
790 798 });
791 799 this.getSelectUserData = response.data.data;
792 800 this.showLoader = false;
793 801 })
794   - .catch(error => {
  802 + .catch((error) => {
795 803 this.showLoader = false;
796 804 if (error.response.status === 401) {
797 805 this.$router.replace({ path: "/" });
... ... @@ -804,13 +812,13 @@ export default {
804 812 http()
805 813 .get("getParentsList", {
806 814 headers: {
807   - Authorization: "Bearer " + this.$store.state.token
808   - }
  815 + Authorization: "Bearer " + this.$store.state.token,
  816 + },
809 817 })
810   - .then(response => {
  818 + .then((response) => {
811 819 this.parentsList = response.data.data;
812 820 })
813   - .catch(error => {
  821 + .catch((error) => {
814 822 // console.log("err====>", error.response.data.message);
815 823 this.showLoader = false;
816 824 if (error.response.status === 401) {
... ... @@ -820,8 +828,8 @@ export default {
820 828 this.$store.dispatch("Role", null);
821 829 }
822 830 });
823   - }
824   - }
  831 + },
  832 + },
825 833 };
826 834 </script>
827 835  
... ...
src/pages/User/user.vue
... ... @@ -768,6 +768,7 @@
768 768 import http from "@/Services/http.js";
769 769 import Util from "@/util";
770 770 import moment from "moment";
  771 +import _ from 'lodash';
771 772  
772 773 export default {
773 774 data: () => ({
... ... @@ -1093,19 +1094,17 @@ export default {
1093 1094 this.userRole = response.data.data;
1094 1095 this.showLoader = false;
1095 1096 this.userRole = response.data.data;
  1097 + console.log("response 1- ",response.data.data,"user role 1- ",this.userRole)
1096 1098 var removedRoles = _.remove(this.userRole, function(c) {
1097 1099 //remove if color is green or yellow
1098   - return c.role === 1 || c.role === 3 || c.role === 4 || c.role === 5;
1099   - // console.log(c);
  1100 + return c.name === "SUPERADMIN" || c.name === "TEACHER" || c.name === "STUDENT" || c.name === "PARENT" ;
1100 1101 });
  1102 + console.log("response - ",response.data.data,"user role - ",this.userRole,"removed - ",removedRoles)
  1103 +
1101 1104 })
1102 1105 .catch(error => {
1103 1106 this.showLoader = false;
1104   - if (error.response.status === 401) {
1105   - this.$router.replace({ path: "/" });
1106   - this.$store.dispatch("setToken", null);
1107   - this.$store.dispatch("Id", null);
1108   - }
  1107 +
1109 1108 });
1110 1109 },
1111 1110 suspendStatus(suspendStatus, id) {
... ...