Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. <template>
  2. <div class="row">
  3.  
  4. <div class="col-12" :class="{'col-md-8': $store.state.user}"> <!-- caso o user esteja autenticado -->
  5. <div class="col-12">
  6.  
  7. <div class="row">
  8. <div class="col-md-12">
  9. <h5>Todos os Livros</h5>
  10. </div>
  11. </div>
  12. </div>
  13. <div class="list-wrapper">
  14. <books-list :books="books" :loans="loans" @updateAll="updateAll()"> </books-list>
  15. </div>
  16.  
  17. </div>
  18.  
  19. <div class="col-12 col-md-4 list-wrapper" v-if="$store.state.user"> <!-- caso o user esteja autenticado -->
  20. <loans-list :loans="loans" @updateAll="updateAll()"> </loans-list>
  21. </div>
  22. </div>
  23. </template>
  24.  
  25. <script type="text/javascript">
  26. import BookList from "./books_list.vue";
  27. import LoanList from "./loans_list.vue";
  28.  
  29. export default {
  30. data: function() {
  31. return {
  32. // title: "List Users",
  33. editingUser: false,
  34. showSuccess: false,
  35. showFailure: false,
  36. successMessage: "",
  37. failMessage: "",
  38. currentUser: null,
  39. currentUserIndex: -1,
  40. currentAuctionShow: null,
  41. //url: "api/users",
  42. loans:[],
  43. books:[],
  44. };
  45. },
  46. methods: {
  47. getBooks: function(){
  48.  
  49. axios.get('api/books')
  50. .then(response=>{this.books = response.data;});
  51. },
  52. getLoans: function(){
  53.  
  54. axios.get('api/loans')
  55. .then(response=>{this.loans = response.data.data;});
  56. },
  57. updateAll: function() {
  58. this.getBooks();
  59. this.getLoans();
  60. },
  61.  
  62. },
  63.  
  64. mounted() {
  65. this.getBooks();
  66. this.getLoans();
  67. },
  68. components: {
  69. "books-list": BookList,
  70. "loans-list": LoanList,
  71.  
  72. },
  73. sockets:{
  74. reloadRequired: function() {
  75. this.getBooks();
  76. if(this.$store.state.user){
  77. this.getLoans();
  78. }
  79. }
  80. }
  81. };
  82. </script>
  83.  
  84. <style scoped>
  85. .list-wrapper {
  86. max-height: 75vh;
  87. overflow-y: auto;
  88. }
  89. p {
  90. font-size: 2em;
  91. text-align: center;
  92. }
  93.  
  94. .center {
  95. text-align: center;
  96. }
  97.  
  98. .button {
  99. background-color: #4caf50;
  100. border: none;
  101. color: white;
  102. padding: 15px 32px;
  103. text-align: center;
  104. text-decoration: none;
  105. display: inline-block;
  106. font-size: 16px;
  107. margin: 4px 2px;
  108. cursor: pointer;
  109.  
  110.  
  111. }
  112. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement