components/widget/WaypointTable.vue

  1. <template>
  2. <!-- Waypoint Table widget -->
  3. <div class="w-100 h-100">
  4. <!-- Overflow container -->
  5. <div class="mh-100 overflow-auto">
  6. <!-- Table -->
  7. <table
  8. id="waypoint-table"
  9. class="table tabl e-borderless table-striped border-left border-right"
  10. style="text-align: center">
  11. <!-- Header -->
  12. <thead class="text-white bg-green-sb">
  13. <th style="width:20%">
  14. #
  15. </th>
  16. <th style="width:20%">
  17. X
  18. </th>
  19. <th style="width:20%">
  20. Y
  21. </th>
  22. <th style="width:20%">
  23. Yaw
  24. </th>
  25. <th style="width:20%">
  26. Remove
  27. </th>
  28. </thead>
  29. <!-- Body -->
  30. <tbody>
  31. <!-- Table row per waypoint in list -->
  32. <template v-for="(waypoint, index) of waypointList">
  33. <tr
  34. :key="waypoint.dateTime"
  35. class="border-bottom">
  36. <td style="width:20%">
  37. {{ (index+1).toFixed(0) }}
  38. </td>
  39. <td style="width:20%">
  40. {{ waypoint.x.toFixed(1) }}
  41. </td>
  42. <td style="width:20%">
  43. {{ waypoint.y.toFixed(1) }}
  44. </td>
  45. <td style="width:20%">
  46. {{ waypoint.yaw.toFixed(1) }}
  47. </td>
  48. <td style="width:20%">
  49. <!-- Remove button -->
  50. <button
  51. :id="'removeBtn'+index"
  52. type="button"
  53. class="btn btn-danger p-0 m-0 border border-secondary h-100 w-50"
  54. @click="removeWaypointFromList(index)">
  55. <img
  56. src="~/open-iconic/svg/trash.svg"
  57. alt=""
  58. style="width:12px;height:12px">
  59. </button>
  60. </td>
  61. </tr>
  62. </template>
  63. </tbody>
  64. </table>
  65. </div>
  66. </div>
  67. </template>
  68. <script>
  69. /**
  70. * Vue SFC used as a widget to show waypoints in a array given as props.
  71. * The waypoints are shown in a html table generated with vue v-for.
  72. * The table contains a colomn of buttons use to delete the row they
  73. * are in and, at the same time, delete the corresponding waypoint in
  74. * the array.
  75. * This component have the following dependency :
  76. * Bootstrap-Vue for styling.
  77. *
  78. *
  79. * @module widget/WaypointTable
  80. * @vue-prop {Object[]} waypointList - Lists the current waypoints
  81. */
  82. /* Disabled comment documentation
  83. * Might use those eventually by forking jsdoc-vue-js so it can manage the author
  84. * and version tag correctly
  85. * @author Valerie Gauthier <valerie.gauthier@usherbrooke.ca>
  86. * @author Edouard Legare <edouard.legare@usherbrooke.ca>
  87. * @version 1.0.0
  88. */
  89. export default {
  90. name: 'waypoint-table',
  91. props: {
  92. waypointList: {
  93. type: Object,
  94. required: true,
  95. },
  96. },
  97. data() {
  98. return {
  99. };
  100. },
  101. methods: {
  102. /**
  103. * Used to clear the patrol or empty the waypoint list.
  104. * @method
  105. * @param {Number} index - Index of the waypoint to remove from list.
  106. */
  107. removeWaypointFromList(index) {
  108. this.waypointList.splice(index, 1);
  109. },
  110. },
  111. };
  112. </script>
  113. <style>
  114. .bg-trash{
  115. display: block;
  116. background: url("~/open-iconic/svg/trash.svg");
  117. fill: black;
  118. }
  119. </style>