notes.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <template>
  2. <ul class="list-unstyled">
  3. <note-form-modal :modal-id="'note'+noteType+'CreateModal'" :note-type="noteType" :woid="noteWoid" :note-user="authusername"></note-form-modal>
  4. <button type="button" data-toggle="modal" :data-target="'#note'+noteType+'CreateModal'" class="btn btn-primary"><i class="fas fa-fw fa-plus"></i> Add New Note</button>
  5. <li class="row no-gutters mb-2" v-bind:key="note.noteid" v-for="(note, index) in this.notes">
  6. <note-form-modal :modal-id="'note'+note.noteid+'editModal'" :populate-with="note"></note-form-modal>
  7. <div class="col-md-1 d-flex flex-column mx-md-3" :class="{ 'order-last': userChanged(index) }">
  8. <div class="text-center p-0 m-0">{{note.noteuser}}</div>
  9. <div class="text-muted text-small text-center p-0 m-0">{{getHRDate(note.notetime)}}</div>
  10. <div class="btn-group justify-content-center p-0 m-0">
  11. <template v-if="authusername === note.noteuser || authusername === 'admin'">
  12. <button class="btn btn-sm btn-primary m-1" data-toggle="modal" :data-target="'#note'+note.noteid+'editModal'"><i class="fas fa-fw fa-edit"></i></button>
  13. <button class="btn btn-sm btn-danger m-1"><i class="fas fa-fw fa-trash-alt"></i></button>
  14. <button class="btn btn-sm btn-primary m-1"><i class="fa fa-fw fa-random"></i></button>
  15. </template>
  16. </div>
  17. </div>
  18. <div class="col-md-10">
  19. <div class="card m-2">
  20. <div class="card-body p-2">
  21. {{ note.thenote }}
  22. </div>
  23. </div>
  24. </div>
  25. </li>
  26. </ul>
  27. </template>
  28. <script>
  29. import dateMixin from '../mixins/dateMixin'
  30. export default {
  31. mixins:[dateMixin],
  32. props: ['initialnotes', 'authusername', 'noteType', 'woid'],
  33. data () {
  34. return {
  35. notes: Object.values(this.initialnotes),
  36. noteWoid: this.woid
  37. }
  38. },
  39. methods: {
  40. userChanged (index) {
  41. if (index === 0) {
  42. return false
  43. } else {
  44. return this.notes[index].noteuser !== this.notes[index-1].noteuser
  45. }
  46. }
  47. }
  48. }
  49. </script>