Advertisement
Guest User

Untitled

a guest
May 27th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. <template>
  2. <div>
  3. <h4>Inserisci nuova figura</h4>
  4. <div class="form-group">
  5. <label for="titolo">Titolo ruolo</label>
  6. <input type="text" v-model="title" class="form-control">
  7.  
  8. <button @click="saveRole" class="btn btn-primary">Salva</button>
  9. </div>
  10. <h4>Figure presenti</h4>
  11. <div class="form-group col-4 mt-3" v-for="role in roles">
  12. <p class="form-control">{{ role.title }}</p>
  13. <button class="btn btn-danger" :role="role" @click="deleteRole">Cancella</button>
  14. </div>
  15. </div>
  16. </template>
  17.  
  18. <script>
  19. import axios from 'axios'
  20.  
  21. export default {
  22. data() {
  23. return {
  24. 'title' : '',
  25. 'roles' : [],
  26. 'role' : '',
  27. }
  28. },
  29. mounted() {
  30. let obj = this;
  31.  
  32. axios.get('/api/getAllRoles', {
  33. })
  34. .then((response) => {
  35. obj.roles = response.data
  36. })
  37. },
  38. methods: {
  39. saveRole(){
  40. let obj = this;
  41.  
  42. axios.post('/api/role/save', {
  43. title: obj.title
  44. })
  45. .then(function(response) {
  46. console.log(response);
  47. });
  48. },
  49. deleteRole(){
  50. let obj = this;
  51.  
  52. axios.post('/api/role/delete', {
  53. role: obj.role.id
  54. })
  55. .then((response) => {
  56. });
  57. }
  58. },
  59. }
  60. </script>
  61.  
  62. <style>
  63.  
  64. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement