Blame view
src/pages/Event/event.vue
16.4 KB
4bd94ba60
|
1 |
<template> |
68d742034
|
2 3 |
<v-container fluid class="body-color"> <!-- ****** EDITS EVENT ****** --> |
db965de89
|
4 |
<v-dialog v-model="editEventdialog" max-width="500px" persistent> |
68d742034
|
5 6 7 |
<v-card flat class="card-style pa-2" dark> <v-layout> <v-flex xs12> |
8c3acf4a9
|
8 |
<label class="title text-xs-center">Edit Event</label> |
68d742034
|
9 10 11 12 |
<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 |
<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 ****** --> |
db965de89
|
92 |
<v-dialog v-model="viewEventdialog" max-width="500px" persistent> |
68d742034
|
93 94 95 96 97 98 99 100 101 102 103 |
<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 |
</v-avatar> </v-btn> </v-card-title> |
612b79bb4
|
169 |
<v-flex xs8 sm8 md3 lg2 v-if="showSearch"> |
68d742034
|
170 |
<v-layout> |
8e8d14254
|
171 172 173 174 175 176 177 |
<v-text-field autofocus v-model="search" label="Search" prepend-inner-icon="search" color="primary" ></v-text-field> |
68d742034
|
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
<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
|
197 |
src="/static/icon/view.png" |
68d742034
|
198 199 200 201 202 203 204 205 206 |
/> <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
|
207 |
src="/static/icon/edit.png" |
68d742034
|
208 209 210 211 212 213 214 215 216 |
/> <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
|
217 |
src="/static/icon/delete.png" |
68d742034
|
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 ****** --> |
db965de89
|
233 |
<v-dialog v-model="addEventDialog" max-width="500px" v-if="addEventDialog" persistent> |
68d742034
|
234 235 236 237 |
<v-card flat class="card-style pa-2" dark> <v-layout> <v-flex xs12> <label class="title text-xs-center">Add Event</label> |
8e8d14254
|
238 |
<v-icon size="24" class="right" @click="closeAddEventModel">cancel</v-icon> |
4bd94ba60
|
239 |
</v-flex> |
68d742034
|
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 324 325 326 327 328 329 |
</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
|
330 331 332 |
<div class="loader" v-if="showLoader"> <v-progress-circular indeterminate color="white"></v-progress-circular> </div> |
68d742034
|
333 |
</v-container> |
4bd94ba60
|
334 335 336 337 |
</template> <script> import http from "@/Services/http.js"; |
593420b06
|
338 |
import moment from "moment"; |
4bd94ba60
|
339 340 341 342 343 344 345 |
export default { data: () => ({ snackbar: false, y: "top", x: "right", mode: "", |
68d742034
|
346 |
timeout: 5000, |
4bd94ba60
|
347 |
text: "", |
68d742034
|
348 |
color: "", |
4bd94ba60
|
349 350 351 |
loading: false, date: null, search: "", |
68d742034
|
352 353 354 355 |
color: "", show: true, addEventDialog: false, showSearch: false, |
4bd94ba60
|
356 |
showLoader: false, |
68d742034
|
357 358 |
editEventdialog: false, viewEventdialog: false, |
4bd94ba60
|
359 |
valid: true, |
4bd94ba60
|
360 |
pagination: { |
8e8d14254
|
361 |
rowsPerPage: 10, |
4bd94ba60
|
362 363 364 365 |
}, date: null, menu1: false, menu: false, |
8e8d14254
|
366 367 368 |
titleRules: [(v) => !!v || " Tilte is required"], descriptionRules: [(v) => !!v || " Discription is required"], dateRules: [(v) => !!v || "Date is required"], |
4bd94ba60
|
369 370 371 |
headers: [ { text: "No", |
68d742034
|
372 |
align: "", |
4bd94ba60
|
373 |
sortable: false, |
8e8d14254
|
374 |
value: "No", |
4bd94ba60
|
375 376 |
}, { text: "Title", value: "title", sortable: false, align: "center" }, |
f4df757fe
|
377 |
{ text: "Date", value: "date", sortable: false, align: "center" }, |
4bd94ba60
|
378 379 380 381 |
{ text: "Description", value: "description", sortable: false, |
8e8d14254
|
382 |
align: "center", |
4bd94ba60
|
383 |
}, |
8e8d14254
|
384 |
{ text: "Action", value: "", sortable: false, align: "center" }, |
4bd94ba60
|
385 |
], |
68d742034
|
386 |
events: [], |
4bd94ba60
|
387 388 |
editedIndex: -1, addEvent: {}, |
8e8d14254
|
389 |
editedItem: {}, |
4bd94ba60
|
390 |
}), |
8e8d14254
|
391 392 393 394 395 396 397 398 |
watch: { addEventDialog: function (val) { if (!val) { this.addEvent = []; this.menu1 = false; } }, }, |
4bd94ba60
|
399 |
methods: { |
8e8d14254
|
400 |
dates: function (date) { |
593420b06
|
401 402 |
return moment(date).format("MMMM DD, YYYY"); }, |
4bd94ba60
|
403 |
getEvents() { |
db0c39244
|
404 |
this.showLoader = true; |
4bd94ba60
|
405 406 |
var token = this.$store.state.token; http() |
593420b06
|
407 |
.get("/getSchoolEventsList", { |
8e8d14254
|
408 |
headers: { Authorization: "Bearer " + token }, |
4bd94ba60
|
409 |
}) |
8e8d14254
|
410 |
.then((response) => { |
68d742034
|
411 |
this.events = response.data.data; |
4bd94ba60
|
412 413 |
this.showLoader = false; }) |
8e8d14254
|
414 |
.catch((error) => { |
4bd94ba60
|
415 416 417 418 419 420 421 422 423 424 |
// 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
|
425 |
this.editedIndex = this.events.indexOf(item); |
4bd94ba60
|
426 |
this.editedItem = Object.assign({}, item); |
db0c39244
|
427 |
this.editedItem.schoolEventId = item._id; |
68d742034
|
428 |
this.editEventdialog = true; |
4bd94ba60
|
429 430 |
}, profile(item) { |
68d742034
|
431 |
this.editedIndex = this.events.indexOf(item); |
4bd94ba60
|
432 |
this.editedItem = Object.assign({}, item); |
68d742034
|
433 |
this.viewEventdialog = true; |
4bd94ba60
|
434 435 436 437 |
}, deleteItem(item) { let deleteEvent = { |
8e8d14254
|
438 |
schoolEventId: item._id, |
4bd94ba60
|
439 440 441 |
}; http() .delete( |
593420b06
|
442 |
"/deleteSchoolEvent", |
4bd94ba60
|
443 |
confirm("Are you sure you want to delete this?") && { |
8e8d14254
|
444 |
params: deleteEvent, |
4bd94ba60
|
445 446 |
} ) |
8e8d14254
|
447 |
.then((response) => { |
68d742034
|
448 449 |
this.snackbar = true; this.text = response.data.message; |
4bd94ba60
|
450 |
this.getEvents(); |
68d742034
|
451 452 453 |
this.snackbar = true; this.color = "green"; this.text = response.data.message; |
4bd94ba60
|
454 |
}) |
8e8d14254
|
455 |
.catch((error) => { |
68d742034
|
456 457 458 459 |
this.snackbar = true; this.text = error.response.data.message; this.color = "error"; this.loading = false; |
4bd94ba60
|
460 461 |
}); }, |
4bd94ba60
|
462 |
close() { |
68d742034
|
463 |
this.editEventdialog = false; |
4bd94ba60
|
464 |
}, |
8e8d14254
|
465 466 467 468 469 |
closeAddEventModel() { this.addEventDialog = false; this.addEvent = []; this.menu1 = false; }, |
4bd94ba60
|
470 471 |
submit() { if (this.$refs.form.validate()) { |
4bd94ba60
|
472 473 |
this.loading = true; http() |
593420b06
|
474 |
.post("/createSchoolEvent", this.addEvent) |
8e8d14254
|
475 |
.then((response) => { |
68d742034
|
476 477 478 |
this.snackbar = true; this.text = response.data.message; this.color = "green"; |
4bd94ba60
|
479 480 481 |
this.getEvents(); this.clear(); this.loading = false; |
68d742034
|
482 |
this.addEventDialog = false; |
4bd94ba60
|
483 |
}) |
8e8d14254
|
484 |
.catch((error) => { |
68d742034
|
485 486 487 |
this.snackbar = true; this.text = error.response.data.message; this.color = "error"; |
4bd94ba60
|
488 489 490 491 492 493 494 495 |
this.loading = false; }); } }, clear() { this.$refs.form.reset(); }, save() { |
4bd94ba60
|
496 |
http() |
593420b06
|
497 |
.put("/updateSchoolEvent", this.editedItem) |
8e8d14254
|
498 |
.then((response) => { |
593420b06
|
499 500 |
this.snackbar = true; this.text = response.data.message; |
68d742034
|
501 |
this.color = "green"; |
4bd94ba60
|
502 |
this.getEvents(); |
593420b06
|
503 |
this.close(); |
4bd94ba60
|
504 |
}) |
8e8d14254
|
505 |
.catch((error) => { |
68d742034
|
506 507 508 |
this.snackbar = true; this.text = error.response.data.message; this.color = "error"; |
4bd94ba60
|
509 |
}); |
68d742034
|
510 511 512 513 514 515 516 517 |
}, displaySearch() { (this.show = false), (this.showSearch = true); }, closeSearch() { this.showSearch = false; this.show = true; this.search = ""; |
8e8d14254
|
518 |
}, |
4bd94ba60
|
519 520 521 |
}, mounted() { this.getEvents(); |
8e8d14254
|
522 |
}, |
4bd94ba60
|
523 |
}; |
68d742034
|
524 |
</script> |