Advertisement
asimryu

listItem.vue

Apr 28th, 2021
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. <template>
  2. <div class="item">
  3. <input
  4. type="checkbox"
  5. @change="updateCheck()"
  6. v-model="item.completed"
  7. />
  8. <span :class="[item.completed ? 'completed' : 'itemText']"> {{ item.name }} </span>
  9. <button @click="removeItem()" class="trashcan">
  10. <font-awesome-icon icon="trash" />
  11. </button>
  12. </div>
  13. </template>
  14. <script>
  15. export default {
  16. props: ['item'],
  17. methods: {
  18. updateCheck() {
  19. axios.put('api/item/' + this.item.id, {
  20. item: this.item
  21. })
  22. .then( response => {
  23. if( response.status == 200 ) {
  24. this.$emit('itemchanged');
  25. }
  26. })
  27. .catch( error => {
  28. console.log( error );
  29. } )
  30. },
  31. removeItem() {
  32. axios.delete('api/item/' + this.item.id, {
  33. item: this.item
  34. })
  35. .then( response => {
  36. if( response.status == 200 ) {
  37. this.$emit('itemchanged');
  38. }
  39. })
  40. .catch( error => {
  41. console.log( error );
  42. } )
  43. }
  44. }
  45.  
  46. }
  47. </script>
  48. <style scoped>
  49. .completed {
  50. text-decoration: line-through;
  51. color: #999999;
  52. width: 100%;
  53. }
  54. .itemText {
  55. width: 100%;
  56. color: #00000;
  57. }
  58. .item {
  59. display: flex;
  60. justify-content: center;
  61. align-items: center;
  62. }
  63. .trashcan {
  64. background: #e6e6e6;
  65. color: red;
  66. border: none;
  67. outline: none;
  68. }
  69. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement