You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
2.0 KiB

  1. <app-modal>
  2. <div class="modal">
  3. <div class="modal__inner">
  4. <div class="modal__title center">
  5. <slot name="title" />
  6. </div>
  7. <div class="modal__body">
  8. { state.body }
  9. </div>
  10. <div class="modal__footer">
  11. <button class="button button--outline button--danger" onclick={ (event) => { handleConfirm(event) } }>
  12. Confirm
  13. </button>
  14. <button class="button button--outline float-right" onclick={ (event) => { handleClose(event) } } >
  15. Reject
  16. </button>
  17. </div>
  18. </div>
  19. </div>
  20. <script>
  21. /**
  22. *
  23. *
  24. *
  25. *
  26. */
  27. export default {
  28. state: {
  29. confirm: {}
  30. },
  31. onMounted() {
  32. this.root.addEventListener('open', this.__open)
  33. this.root.addEventListener('close', this.__close)
  34. },
  35. __open(event) {
  36. // adding confirm function to state
  37. this.state.confirm = event.detail.confirm
  38. this.state.body = event.detail.body
  39. this.$('.modal').classList.add('modal--open')
  40. this.update()
  41. },
  42. __close(event) {
  43. this.$('.modal').classList.remove('modal--open')
  44. this.update()
  45. },
  46. /**
  47. *
  48. * @param {[type]} event
  49. * @return {[type]}
  50. *
  51. */
  52. handleConfirm(event) {
  53. event.preventDefault()
  54. // calling confirm function
  55. this.state.confirm()
  56. this.__close()
  57. },
  58. /**
  59. *
  60. *
  61. * @param {object} event
  62. *
  63. */
  64. handleClose(event) {
  65. event.preventDefault()
  66. this.__close()
  67. }
  68. }
  69. </script>
  70. </app-modal>