Guest User

Untitled

a guest
Nov 21st, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. <template>
  2. <div class="filter filter-group wrapper">
  3. <div class="inner">
  4. <div class="btn-group" aria-label="Basic example" role="group">
  5. <button type="button" class="btn" :class="getClass('my')"
  6. @click="changeData('my')">{{$t('my')}}
  7. </button>
  8. <button type="button" class="btn " :class="getClass('my_agency')"
  9. @click="changeData('my_agency')">{{$t('my_agency')}}
  10. </button>
  11. <button type="button" class="btn" :class="getClass('no_my')"
  12. @click="changeData('no_my')">{{$t('no_my')}}
  13. </button>
  14. </div>
  15. </div>
  16. </div>
  17. </template>
  18.  
  19. <script>
  20. export default {
  21. name: 'FilterGroup',
  22. data() {
  23. return {
  24. provide: {
  25. my: false,
  26. no_my: false,
  27. my_agency: false,
  28. },
  29. classes: {
  30. my: 'btn-success',
  31. no_my: 'btn-danger',
  32. my_agency: 'btn-warning',
  33. },
  34. }
  35. },
  36. methods: {
  37. changeData(key) {
  38.  
  39. this.provide[key] = !this.provide[key]
  40. },
  41. getClass(key){
  42. let object = {}
  43.  
  44. object[this.classes[key]] = this.provide[key]
  45.  
  46. if(!this.provide[key]){
  47. object['btn-default-white'] = true
  48. }
  49. return object
  50. },
  51. },
  52. watch: {
  53. provide: {
  54. handler(newVal){
  55.  
  56. this.$emit('update', newVal, 'provide')
  57. },
  58. deep: true,
  59. },
  60. },
  61. }
  62. </script>
Add Comment
Please, Sign In to add comment