credential-list.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <template>
  2. <div>
  3. <credential-form-modal modal-id="newCredentialModal" :descriptions="creddescList" :create="true" :pcid="pcid"></credential-form-modal>
  4. <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#newCredentialModal">New Credential</button>
  5. <div v-for="(credential, index) in credentials" :key="index">
  6. <credential :credential="credential" :descriptions="creddescList" @delete-cred="deleteCred(index)"></credential>
  7. </div>
  8. </div>
  9. </template>
  10. <script>
  11. export default {
  12. props: {
  13. credentialList: {
  14. type: Array,
  15. required: true
  16. },
  17. descriptions: {
  18. type: Array,
  19. required: true
  20. },
  21. pcid: {
  22. type: Number
  23. },
  24. groupid: {
  25. type: Number
  26. }
  27. },
  28. data () {
  29. return {
  30. credentials: this.credentialList
  31. }
  32. },
  33. computed : {
  34. creddescList: function () {
  35. let list = {}
  36. this.descriptions.map(val => {
  37. list[val.creddescid] = val.credtitle
  38. })
  39. return list
  40. }
  41. },
  42. methods: {
  43. deleteCred: function(index) {
  44. console.log(this.credentials.splice(index, 1));
  45. }
  46. }
  47. }
  48. </script>