Blame view
src/pages/Event/event.vue
15.9 KB
4bd94ba60
|
1 |
<template> |
68d742034
|
2 3 4 5 6 7 8 9 10 11 12 |
<v-container fluid class="body-color"> <!-- ****** EDITS EVENT ****** --> <v-dialog v-model="editEventdialog" max-width="500px"> <v-card flat class="card-style pa-2" dark> <v-layout> <v-flex xs12> <label class="title text-xs-center">Edit Class</label> <v-icon size="24" class="right" @click="editEventdialog = false">cancel</v-icon> </v-flex> </v-layout> <v-container fluid> |
4bd94ba60
|
13 |
<v-flex xs12 sm12> |
68d742034
|
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 |
<v-layout> <v-flex xs4 class="pt-4 subheading"> <label class="right">Title:</label> </v-flex> <v-flex xs7 class="ml-3"> <v-text-field v-model="editedItem.title" placeholder="fill your Title" name="name" type="text" ></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">Date:</label> </v-flex> <v-flex xs7 class="ml-3"> <v-menu ref="menu" :close-on-content-click="false" v-model="menu" :nudge-right="40" lazy transition="scale-transition" offset-y full-width min-width="290px" > <v-text-field slot="activator" :rules="dateRules" v-model="editedItem.dateOfEvent" placeholder="Select date" ></v-text-field> <v-date-picker color="info" ref="picker" v-model="editedItem.dateOfEvent" @input="$refs.menu.save(editedItem.dateOfEvent)" ></v-date-picker> </v-menu> </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 xs7 class="ml-3"> <v-text-field placeholder="fill your Description" v-model="editedItem.description" type="text" ></v-text-field> </v-flex> </v-layout> </v-flex> <v-layout> <v-flex xs12> <v-card-actions class="hidden-xs-only hidden-sm-only"> <v-spacer></v-spacer> <v-btn round dark @click="save" class="add-button">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" class="add-button">Save</v-btn> <v-spacer></v-spacer> </v-card-actions> </v-flex> </v-layout> </v-container> </v-card> </v-dialog> <!-- ****** PROFILE VIEW EVENT ****** --> <v-dialog v-model="viewEventdialog" max-width="500px"> <v-card flat class="card-style pa-3" dark> <v-layout> <v-flex xs12> <label class="title text-xs-center">View Event</label> <v-icon size="24" class="right" @click="viewEventdialog = false">cancel</v-icon> </v-flex> </v-layout> <v-card-text> <v-container grid-list-md> <v-layout wrap> <v-flex> |
495e4037c
|
104 |
<v-layout> |
68d742034
|
105 106 107 108 |
<v-flex xs5 sm6> <h5 class="right my-1"> <b>Title:</b> </h5> |
495e4037c
|
109 |
</v-flex> |
68d742034
|
110 111 |
<v-flex sm6 xs8> <h5 class="my-1">{{ editedItem.title }}</h5> |
4bd94ba60
|
112 113 |
</v-flex> </v-layout> |
68d742034
|
114 115 116 117 118 119 120 121 |
<v-layout> <v-flex xs5 sm6> <h5 class="right my-1"> <b>Date:</b> </h5> </v-flex> <v-flex sm6 xs8> <h5 class="my-1">{{ dates(editedItem.dateOfEvent) }}</h5> |
4bd94ba60
|
122 |
</v-flex> |
68d742034
|
123 124 125 126 127 128 |
</v-layout> <v-layout> <v-flex xs5 sm6> <h5 class="right my-1"> <b>Description:</b> </h5> |
4bd94ba60
|
129 |
</v-flex> |
68d742034
|
130 131 |
<v-flex sm6 xs8> <h5 class="my-1">{{ editedItem.description }}</h5> |
4bd94ba60
|
132 |
</v-flex> |
68d742034
|
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
</v-layout> </v-flex> </v-layout> </v-container> </v-card-text> </v-card> </v-dialog> <!-- ****** EVENT 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="addEventDialog = true" > <v-icon dark>add</v-icon> </v-btn> <v-btn round class="open-dialog-button hidden-sm-only hidden-xs-only" dark @click="addEventDialog = true" > <v-icon class="white--text pr-1" size="20">add</v-icon>Add Event </v-btn> <v-spacer></v-spacer> <v-card-title class="body-1" v-show="show"> <v-btn icon large flat @click="displaySearch"> <v-avatar size="27"> |
aa310d61a
|
165 |
<img src="/static/icon/search.png" alt="icon" /> |
68d742034
|
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 |
</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="events" :pagination.sync="pagination" :search="search"> <template slot="items" slot-scope="props"> <tr class="tr"> <td class="td td-row">{{ props.index + 1}}</td> <td class="td td-row text-xs-center">{{ props.item.title}}</td> <td class="td td-row text-xs-center">{{ dates(props.item.dateOfEvent)}}</td> <td class="td td-row text-xs-center">{{ props.item.description}}</td> <td class="td td-row text-xs-center"> <span> <v-tooltip top> <img slot="activator" style="cursor:pointer; width:25px; height:25px; " class="mr-3" @click="profile(props.item)" |
aa310d61a
|
191 |
src="/static/icon/view.png" |
68d742034
|
192 193 194 195 196 197 198 199 200 |
/> <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)" |
aa310d61a
|
201 |
src="/static/icon/edit.png" |
68d742034
|
202 203 204 205 206 207 208 209 210 |
/> <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)" |
aa310d61a
|
211 |
src="/static/icon/delete.png" |
68d742034
|
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
/> <span>Delete</span> </v-tooltip> </span> </td> </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 EVENT ****** --> <v-dialog v-model="addEventDialog" max-width="500px"> <v-card flat class="card-style pa-2" dark> <v-layout> <v-flex xs12> <label class="title text-xs-center">Add Event</label> <v-icon size="24" class="right" @click="addEventDialog = false">cancel</v-icon> |
4bd94ba60
|
233 |
</v-flex> |
68d742034
|
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 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 |
</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">Title:</label> </v-flex> <v-flex xs8 sm8 class="ml-3"> <v-text-field v-model="addEvent.title" placeholder="fill your Title" type="text" :rules="titleRules" 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">Date:</label> </v-flex> <v-flex xs8 sm8 class="ml-3"> <v-menu ref="menu1" :close-on-content-click="false" v-model="menu1" :nudge-right="40" :return-value.sync="addEvent.dateOfEvent" app lazy transition="scale-transition" offset-y full-width min-width="290px" > <v-text-field slot="activator" :rules="dateRules" v-model="addEvent.dateOfEvent" append-icon="event" placeholder="Select date" ></v-text-field> <v-date-picker color="info" v-model="addEvent.dateOfEvent" @input="$refs.menu1.save(addEvent.dateOfEvent)" ></v-date-picker> </v-menu> </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 class="ml-3"> <v-text-field placeholder="fill your Description" :rules="descriptionRules" v-model="addEvent.description" type="text" required ></v-text-field> </v-flex> </v-layout> </v-flex> <v-layout> <v-flex xs12> <v-layout class="right"> <v-btn @click="clear" round class="clear-button" dark>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> |
4bd94ba60
|
324 325 326 |
<div class="loader" v-if="showLoader"> <v-progress-circular indeterminate color="white"></v-progress-circular> </div> |
68d742034
|
327 |
</v-container> |
4bd94ba60
|
328 329 330 331 |
</template> <script> import http from "@/Services/http.js"; |
593420b06
|
332 |
import moment from "moment"; |
4bd94ba60
|
333 334 335 336 337 338 339 |
export default { data: () => ({ snackbar: false, y: "top", x: "right", mode: "", |
68d742034
|
340 |
timeout: 5000, |
4bd94ba60
|
341 |
text: "", |
68d742034
|
342 |
color: "", |
4bd94ba60
|
343 344 345 |
loading: false, date: null, search: "", |
68d742034
|
346 347 348 349 |
color: "", show: true, addEventDialog: false, showSearch: false, |
4bd94ba60
|
350 |
showLoader: false, |
68d742034
|
351 352 |
editEventdialog: false, viewEventdialog: false, |
4bd94ba60
|
353 |
valid: true, |
4bd94ba60
|
354 |
pagination: { |
68d742034
|
355 |
rowsPerPage: 10 |
4bd94ba60
|
356 357 358 359 |
}, date: null, menu1: false, menu: false, |
4bd94ba60
|
360 361 362 363 364 365 |
titleRules: [v => !!v || " Tilte is required"], descriptionRules: [v => !!v || " Discription is required"], dateRules: [v => !!v || "Date is required"], headers: [ { text: "No", |
68d742034
|
366 |
align: "", |
4bd94ba60
|
367 368 369 370 |
sortable: false, value: "No" }, { text: "Title", value: "title", sortable: false, align: "center" }, |
f4df757fe
|
371 |
{ text: "Date", value: "date", sortable: false, align: "center" }, |
4bd94ba60
|
372 373 374 375 376 377 378 379 |
{ text: "Description", value: "description", sortable: false, align: "center" }, { text: "Action", value: "", sortable: false, align: "center" } ], |
68d742034
|
380 |
events: [], |
4bd94ba60
|
381 382 383 384 385 |
editedIndex: -1, addEvent: {}, editedItem: {} }), methods: { |
593420b06
|
386 387 388 |
dates: function(date) { return moment(date).format("MMMM DD, YYYY"); }, |
4bd94ba60
|
389 |
getEvents() { |
db0c39244
|
390 |
this.showLoader = true; |
4bd94ba60
|
391 392 |
var token = this.$store.state.token; http() |
593420b06
|
393 |
.get("/getSchoolEventsList", { |
4bd94ba60
|
394 395 396 |
headers: { Authorization: "Bearer " + token } }) .then(response => { |
68d742034
|
397 |
this.events = response.data.data; |
4bd94ba60
|
398 399 |
this.showLoader = false; }) |
00e4bc4e1
|
400 |
.catch(error => { |
4bd94ba60
|
401 402 403 404 405 406 407 408 409 410 |
// 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); } }); }, editItem(item) { |
68d742034
|
411 |
this.editedIndex = this.events.indexOf(item); |
4bd94ba60
|
412 |
this.editedItem = Object.assign({}, item); |
db0c39244
|
413 |
this.editedItem.schoolEventId = item._id; |
68d742034
|
414 |
this.editEventdialog = true; |
4bd94ba60
|
415 416 |
}, profile(item) { |
68d742034
|
417 |
this.editedIndex = this.events.indexOf(item); |
4bd94ba60
|
418 |
this.editedItem = Object.assign({}, item); |
68d742034
|
419 |
this.viewEventdialog = true; |
4bd94ba60
|
420 421 422 423 |
}, deleteItem(item) { let deleteEvent = { |
593420b06
|
424 |
schoolEventId: item._id |
4bd94ba60
|
425 426 427 |
}; http() .delete( |
593420b06
|
428 |
"/deleteSchoolEvent", |
4bd94ba60
|
429 |
confirm("Are you sure you want to delete this?") && { |
593420b06
|
430 |
params: deleteEvent |
4bd94ba60
|
431 432 433 |
} ) .then(response => { |
68d742034
|
434 435 |
this.snackbar = true; this.text = response.data.message; |
4bd94ba60
|
436 |
this.getEvents(); |
68d742034
|
437 438 439 |
this.snackbar = true; this.color = "green"; this.text = response.data.message; |
4bd94ba60
|
440 441 |
}) .catch(error => { |
68d742034
|
442 443 444 445 |
this.snackbar = true; this.text = error.response.data.message; this.color = "error"; this.loading = false; |
4bd94ba60
|
446 447 |
}); }, |
4bd94ba60
|
448 |
close() { |
68d742034
|
449 |
this.editEventdialog = false; |
4bd94ba60
|
450 451 452 |
}, submit() { if (this.$refs.form.validate()) { |
4bd94ba60
|
453 454 |
this.loading = true; http() |
593420b06
|
455 |
.post("/createSchoolEvent", this.addEvent) |
4bd94ba60
|
456 |
.then(response => { |
68d742034
|
457 458 459 |
this.snackbar = true; this.text = response.data.message; this.color = "green"; |
4bd94ba60
|
460 461 462 |
this.getEvents(); this.clear(); this.loading = false; |
68d742034
|
463 |
this.addEventDialog = false; |
4bd94ba60
|
464 465 |
}) .catch(error => { |
68d742034
|
466 467 468 |
this.snackbar = true; this.text = error.response.data.message; this.color = "error"; |
4bd94ba60
|
469 470 471 472 473 474 475 476 |
this.loading = false; }); } }, clear() { this.$refs.form.reset(); }, save() { |
4bd94ba60
|
477 |
http() |
593420b06
|
478 |
.put("/updateSchoolEvent", this.editedItem) |
4bd94ba60
|
479 |
.then(response => { |
593420b06
|
480 481 |
this.snackbar = true; this.text = response.data.message; |
68d742034
|
482 |
this.color = "green"; |
4bd94ba60
|
483 |
this.getEvents(); |
593420b06
|
484 |
this.close(); |
4bd94ba60
|
485 486 |
}) .catch(error => { |
68d742034
|
487 488 489 |
this.snackbar = true; this.text = error.response.data.message; this.color = "error"; |
4bd94ba60
|
490 |
}); |
68d742034
|
491 492 493 494 495 496 497 498 |
}, displaySearch() { (this.show = false), (this.showSearch = true); }, closeSearch() { this.showSearch = false; this.show = true; this.search = ""; |
4bd94ba60
|
499 500 501 502 |
} }, mounted() { this.getEvents(); |
4bd94ba60
|
503 504 |
} }; |
68d742034
|
505 |
</script> |