Advertisement
ricksantiago

Untitled

Feb 21st, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. const urlListaHorario = $('#listaHorario').val() + '.json';
  2. new Vue({
  3. el: '#app',
  4. data: {
  5. agendas: [],
  6. classObject: {
  7. 'red': true,
  8. 'white-text': true,
  9. },
  10. disabled: false,
  11. hora: ''
  12. },
  13. methods: {
  14. recebeHora: function (hora) {
  15. this.hora = hora
  16. }
  17. },
  18. created: async function() {
  19. const response = await fetch(urlListaHorario);
  20. const { agendas } = await response.json();
  21.  
  22. const all = [
  23. '06:00', '07:00', '08:00', '09:00',
  24. '10:00', '11:00', '12:00', '13:00',
  25. '14:00', '15:00', '16:00', '17:00',
  26. '18:00', '19:00', '20:00', '21:00'
  27. ]
  28.  
  29. const allSalas = [
  30. 'Sala 01', 'Sala 02',
  31. 'Sala 03', 'Sala 04',
  32. 'Sala 05', 'Sala 06'
  33. ]
  34.  
  35. agendas.map(idSala => {
  36.  
  37. if(idSala.horarioSala.length === 0){
  38. disabled = true
  39. }
  40.  
  41. idSala.horarioSala = all.filter(t => !idSala.horarioSala.includes(t)).concat(idSala.horarioSala);
  42. idSala.horarioSala.sort();
  43.  
  44. idSala.nomeSala = allSalas.filter(sl => !idSala.nomeSala.includes(sl)).concat(idSala.nomeSala);
  45. idSala.nomeSala.sort();
  46.  
  47. });
  48.  
  49. this.agendas = agendas
  50. }
  51.  
  52. });
  53.  
  54.  
  55.  
  56. <div class="swiper-container">
  57. <div id="app" class="swiper-wrapper">
  58. %{--<div>--}%
  59. <div v-for="agenda in agendas" class="swiper-slide card grey darken-1">
  60. <div class="card-content white-text">
  61. <span class="card-title" v-for="salinhas in agenda.nomeSala">{{ salinhas }}</span>
  62. <p>
  63. </p>
  64. <p>
  65. <button v-on:click="recebeHora(tempo)"
  66. :disabled="agenda.horarioSala.lenght === 0"
  67. class="btn white black-text
  68. btnHorario waves-teal waves-effect waves-light btn-large"
  69. v-for="tempo in agenda.horarioSala">{{ tempo }}</button>
  70. </p>
  71. <p>Quantas vezes o botão acima foi clicado: {{ hora }}</p>
  72.  
  73. </div>
  74. </div>
  75. %{--</div>--}%
  76. </div>
  77. <!-- Add Pagination -->
  78. <br>
  79. <div class="swiper-pagination"></div>
  80. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement