Blame view
src/pages/Class/addclass.vue
11.8 KB
1ed542553
|
1 |
<template> |
a17c68a03
|
2 |
<div> |
1ed542553
|
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
<v-tabs grow slider-color="black"> <v-tab ripple @click="activeTab('existing')" v-bind:class="{ active: isActive }" id="tab" class="subheading" >Existing Class</v-tab> <v-tab ripple @click="activeTab('new')" v-bind:class="{ active: newActive }" id="tab1" User class="subheading" >Add New Class</v-tab> <!-- ****** EDITS ADD ClASS ****** --> <v-tab-item> <v-snackbar :timeout="timeout" :top="y === 'top'" :right="x === 'right'" :vertical="mode === 'vertical'" v-model="snackbar" color="success" >{{ text }}</v-snackbar> <v-dialog v-model="dialog" max-width="500px"> |
506be6fd7
|
31 |
<v-toolbar color="grey lighten-2"> |
1ed542553
|
32 |
<v-spacer></v-spacer> |
a17c68a03
|
33 34 35 |
<v-toolbar-title> <h3>Edit Class</h3> </v-toolbar-title> |
1ed542553
|
36 37 38 39 40 41 42 43 44 |
<v-spacer></v-spacer> </v-toolbar> <v-card> <v-card-text> <v-container> <v-layout wrap justify-center> <v-flex xs12 sm9> <v-form ref="form" v-model="valid" lazy-validation> <v-layout style="position:relative;"> |
a17c68a03
|
45 |
<v-flex xs4 lg2 class="pt-4 subheading"> |
506be6fd7
|
46 |
<label>Class:</label> |
1ed542553
|
47 |
</v-flex> |
a17c68a03
|
48 |
<v-flex xs10> |
506be6fd7
|
49 |
<v-autocomplete |
1ed542553
|
50 |
v-model="editedItem.classNum" |
a17c68a03
|
51 52 |
:label="editedItem.classNum" :items="classList" |
1ed542553
|
53 |
:rules="nameRules" |
506be6fd7
|
54 |
></v-autocomplete> |
1ed542553
|
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
</v-flex> </v-layout> <v-card-actions> <v-btn round dark @click.native="close">Cancel</v-btn> <v-spacer></v-spacer> <v-btn round dark @click="save">Save</v-btn> </v-card-actions> </v-form> </v-flex> </v-layout> </v-container> </v-card-text> </v-card> </v-dialog> <!-- ****** PROFILE VIEW STUDENTS ****** --> <v-dialog v-model="dialog1" max-width="600px"> |
506be6fd7
|
72 |
<v-toolbar color="grey lighten-2"> |
1ed542553
|
73 |
<v-spacer></v-spacer> |
a17c68a03
|
74 |
<v-toolbar-title> |
60e13c8f2
|
75 |
<h3>Class</h3> |
a17c68a03
|
76 |
</v-toolbar-title> |
1ed542553
|
77 78 79 80 |
<v-spacer></v-spacer> <v-icon @click="close1">close</v-icon> </v-toolbar> <v-card> |
60e13c8f2
|
81 |
<!-- <v-flex align-center justify-center layout text-xs-center> |
1ed542553
|
82 |
<v-avatar size="50px" style="position:absolute; top:20px;"> |
a17c68a03
|
83 |
<img src="/static/icon/user.png" /> |
1ed542553
|
84 |
</v-avatar> |
60e13c8f2
|
85 |
</v-flex> --> |
1ed542553
|
86 87 88 89 |
<v-card-text> <v-container grid-list-md> <v-layout wrap> <v-flex> |
1ed542553
|
90 |
<v-layout> |
a17c68a03
|
91 |
<v-flex xs6 sm6> |
ceb43037a
|
92 |
<h5 class="right my-1"><b>Class Name:</b></h5> |
1ed542553
|
93 |
</v-flex> |
a17c68a03
|
94 |
<v-flex sm6 xs6> |
1ed542553
|
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 |
<h5 class="my-1">{{ editedItem.classNum }}</h5> </v-flex> </v-layout> </v-flex> </v-layout> </v-container> </v-card-text> </v-card> </v-dialog> <v-snackbar :timeout="timeout" :top="y === 'top'" :right="x === 'right'" :vertical="mode === 'vertical'" v-model="snackbar" color="success" >{{ text }}</v-snackbar> <!-- ****** EXISTING-USERS Classess Table ****** --> <v-data-table :headers="headers" :items="desserts" :pagination.sync="pagination" :search="search" > <template slot="items" slot-scope="props"> |
1571e40b5
|
122 |
<td>{{ props.index }}</td> |
506be6fd7
|
123 |
<td class="text-xs-center">{{ props.item.classNum}}</td> |
1ed542553
|
124 125 126 127 128 129 130 |
<td class="text-xs-center"> <span> <img style="cursor:pointer; width:25px; height:18px; " class="mr-5" @click="profile(props.item)" src="/static/icon/eye1.png" |
a17c68a03
|
131 |
/> |
1ed542553
|
132 133 134 135 136 |
<img style="cursor:pointer; width:20px; height:18px; " class="mr-5" @click="editItem(props.item)" src="/static/icon/edit1.png" |
a17c68a03
|
137 |
/> |
1ed542553
|
138 |
<img |
b39d2afd2
|
139 |
style="cursor:pointer; width:20px; height:20px; " |
1ed542553
|
140 141 142 |
class="mr-5" @click="deleteItem(props.item)" src="/static/icon/delete1.png" |
a17c68a03
|
143 |
/> |
1ed542553
|
144 145 146 |
</span> </td> </template> |
a17c68a03
|
147 |
<v-alert |
1ed542553
|
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
slot="no-results" :value="true" color="error" icon="warning" >Your search for "{{ search }}" found no results.</v-alert> </v-data-table> </v-tab-item> <!-- ****** ADD multiple Classess ****** --> <v-tab-item> <v-container> <v-snackbar :timeout="timeout" :top="y === 'top'" :right="x === 'right'" :vertical="mode === 'vertical'" v-model="snackbar" color="success" >{{ text }}</v-snackbar> <v-flex xs12 sm8 offset-sm2 class="top"> <v-card flat> <v-container fluid fill-height> <v-layout align-center> |
79006bdcb
|
171 |
<v-flex xs12 class="mt-4"> |
1ed542553
|
172 173 174 |
<v-form ref="form" v-model="valid" lazy-validation> <v-layout> <v-flex xs4 class="pt-4 subheading"> |
506be6fd7
|
175 |
<label class="right">Class :</label> |
1ed542553
|
176 177 |
</v-flex> <v-flex xs6 class="ml-3"> |
506be6fd7
|
178 |
<v-autocomplete |
1ed542553
|
179 180 |
v-model="addclasses.classNum" placeholder="fill your class Name" |
1ed542553
|
181 |
type="text" |
506be6fd7
|
182 |
:items="classList" |
1ed542553
|
183 184 |
:rules="nameRules" required |
506be6fd7
|
185 |
></v-autocomplete> |
1ed542553
|
186 187 188 189 190 |
</v-flex> </v-layout> <v-layout> <v-flex xs12 sm9 offset-sm2> <v-card-actions> |
1ed542553
|
191 192 |
<v-spacer></v-spacer> <v-btn @click="submit" round dark :loading="loading">Add</v-btn> |
79006bdcb
|
193 |
<v-spacer></v-spacer> |
1ed542553
|
194 195 196 197 198 199 200 201 202 203 204 205 |
</v-card-actions> </v-flex> </v-layout> </v-form> </v-flex> </v-layout> </v-container> </v-card> </v-flex> </v-container> </v-tab-item> </v-tabs> |
4b169b574
|
206 207 208 |
<div class="loader" v-if="showLoader"> <v-progress-circular indeterminate color="white"></v-progress-circular> </div> |
a17c68a03
|
209 |
</div> |
1ed542553
|
210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
</template> <script> import http from "@/Services/http.js"; import Util from "@/util"; export default { data: () => ({ snackbar: false, y: "top", x: "right", mode: "", timeout: 3000, text: "", |
a17c68a03
|
224 |
showLoader: false, |
1ed542553
|
225 226 227 |
loading: false, date: null, search: "", |
1ed542553
|
228 229 230 231 232 233 234 235 236 |
dialog: false, dialog1: false, valid: true, isActive: true, newActive: false, AddUsercredentials: {}, pagination: { rowsPerPage: 15 }, |
46db0a3b5
|
237 |
nameRules: [v => !!v || " Class Name is required"], |
1ed542553
|
238 239 240 |
headers: [ { text: "No", |
506be6fd7
|
241 |
align: "left", |
1ed542553
|
242 243 244 |
sortable: false, value: "No" }, |
2b0e316ee
|
245 |
{ text: "Class No", value: "classNum", sortable: false, align: "center" }, |
1ed542553
|
246 247 248 |
{ text: "Action", value: "", sortable: false, align: "center" } ], desserts: [], |
a17c68a03
|
249 |
classList: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"], |
1ed542553
|
250 251 252 253 |
editedIndex: -1, editedItem: { classNum: "" }, |
a17c68a03
|
254 |
addclasses: { |
1ed542553
|
255 |
classNum: "" |
a17c68a03
|
256 |
} |
1ed542553
|
257 |
}), |
1ed542553
|
258 259 |
methods: { getClassList() { |
4b169b574
|
260 |
this.showLoader = true; |
1ed542553
|
261 262 |
var token = this.$store.state.token; http() |
2b0e316ee
|
263 |
.get("/getClassesList") |
1ed542553
|
264 265 |
.then(response => { this.desserts = response.data.data; |
4b169b574
|
266 |
this.showLoader = false; |
1ed542553
|
267 268 |
}) .catch(err => { |
2b0e316ee
|
269 |
console.log("err====>", err); |
4b169b574
|
270 |
this.showLoader = false; |
a17c68a03
|
271 272 273 274 275 |
if (error.response.status === 401) { this.$router.replace({ path: "/" }); this.$store.dispatch("setToken", null); this.$store.dispatch("Id", null); } |
1ed542553
|
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 |
}); }, editItem(item) { this.editedIndex = this.desserts.indexOf(item); this.editedItem = Object.assign({}, item); this.dialog = true; }, profile(item) { this.editedIndex = this.desserts.indexOf(item); this.editedItem = Object.assign({}, item); this.dialog1 = true; }, deleteItem(item) { let deleteStudent = { classId: item._id }; http() .delete( "/deleteClass", confirm("Are you sure you want to delete this?") && { params: deleteStudent } ) .then(response => { // console.log("deleteUers",deleteStudent) if ((this.snackbar = true)) { |
5f1d4b444
|
302 |
this.text = "Successfully delete Existing Class"; |
1ed542553
|
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 |
} this.getClassList(); }) .catch(error => { // console.log(error); }); }, activeTab(type) { switch (type) { case "existing": this.newActive = false; this.isActive = true; break; default: this.newActive = true; this.isActive = false; break; } }, close() { this.dialog = false; setTimeout(() => { this.editedItem = Object.assign({}, this.defaultItem); this.editedIndex = -1; }, 300); }, close1() { this.dialog1 = false; }, submit() { if (this.$refs.form.validate()) { let addClass = { classNum: this.addclasses.classNum }; console.log(addClass); |
5f1d4b444
|
339 |
this.loading = true; |
1ed542553
|
340 341 342 343 344 |
http() .post("/createClass", addClass) .then(response => { this.getClassList(); if ((this.snackbar = true)) { |
5f1d4b444
|
345 |
this.text = "New class added successfully"; |
1ed542553
|
346 |
} |
1ed542553
|
347 |
this.clear(); |
5f1d4b444
|
348 |
this.loading = false; |
1ed542553
|
349 350 351 |
}) .catch(error => { // console.log(error); |
5f1d4b444
|
352 |
this.loading = false; |
1ed542553
|
353 354 355 356 357 358 |
if ((this.snackbar = true)) { this.text = error.response.data.message; } }); } }, |
1ed542553
|
359 360 361 362 363 364 365 366 367 368 369 |
clear() { this.$refs.form.reset(); }, save() { let editClass = { classId: this.editedItem._id, classNum: this.editedItem.classNum }; http() .put("/updateClass", editClass) .then(response => { |
1ed542553
|
370 |
if ((this.snackbar = true)) { |
5f1d4b444
|
371 |
this.text = "Successfully Edit Existing Class"; |
1ed542553
|
372 373 374 375 376 377 378 |
} this.getClassList(); }) .catch(error => { // console.log(error); }); this.close(); |
1ed542553
|
379 380 381 382 |
} }, mounted() { this.getClassList(); |
a17c68a03
|
383 |
// console.log("this.search",this.search) |
1ed542553
|
384 |
}, |
a17c68a03
|
385 386 387 388 389 390 391 392 |
created() { this.$root.$on("app:search", search => { this.search = search; }); }, beforeDestroy() { // dont forget to remove the listener this.$root.$off("app:search"); |
1ed542553
|
393 394 395 |
} }; </script> |
506be6fd7
|
396 |
<style> |
1ed542553
|
397 398 399 400 401 402 403 |
.active { background-color: black; color: white !important; } .activebtn { color: black !important; } |
1ed542553
|
404 |
</style> |