Record.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <template>
  2. <div v-if="!record || !record.contact">Loading...</div>
  3. <div v-else class="record">
  4. <div class="headline-container">
  5. <Photo v-bind:photo="record.photo" class="headline-item"></Photo>
  6. <div class="headline-item">
  7. <h1>
  8. <span>Record: {{ record.contact.fullName }}</span>
  9. </h1>
  10. <p>{{ record.contact.badgeId }} &bull; {{ record.contact.email }}</p>
  11. </div>
  12. </div>
  13. <ul class="nav nav-tabs">
  14. <li id="tab_mode_record_details">
  15. <a @click="updateMode(modeDetails)">Details</a>
  16. </li>
  17. <li id="tab_mode_record_history">
  18. <a @click="updateMode(modeHistory)">History</a>
  19. </li>
  20. <li id="tab_mode_record_files">
  21. <a @click="updateMode(modeFiles)">Files</a>
  22. </li>
  23. <li
  24. v-show="numTeams > 0 && !readonly"
  25. id="tab_mode_record_create_appointment"
  26. >
  27. <a @click="updateMode(modeCreateAppointment)">Create Appointment</a>
  28. </li>
  29. </ul>
  30. <div v-if="mode === modeDetails" class="details-container">
  31. <ContactDetails
  32. v-bind:contact="record.contact"
  33. class="details-item"
  34. ></ContactDetails>
  35. <ScholarDetails
  36. v-bind:scholar="record.scholar"
  37. class="details-item"
  38. ></ScholarDetails>
  39. <div class="details-item">
  40. <InsuranceDetails
  41. v-bind:insurance="record.insurance"
  42. ></InsuranceDetails>
  43. <VaccinationDetails
  44. v-bind:vaccination="record.vaccination"
  45. ></VaccinationDetails>
  46. </div>
  47. </div>
  48. <div v-else-if="mode === modeHistory">
  49. <History v-bind:history="record.history"></History>
  50. <Entry
  51. v-if="id && entry_id && entry"
  52. v-bind:assignTo="entry.interaction.ownerName"
  53. v-bind:entry="entry"
  54. v-bind:entry_id="entry_id"
  55. v-bind:holds="record.scholar.hasAdvisingHolds"
  56. v-bind:id="id"
  57. v-bind:messages="entry.messages"
  58. v-bind:permissions="entry.permissions"
  59. v-bind:readonly="readonly"
  60. v-bind:state="entry.interaction.interactionState"
  61. v-bind:unfinished="entry.interaction.unfinished"
  62. ></Entry>
  63. </div>
  64. <div v-else-if="mode === modeFiles">
  65. <Files v-bind:files="record.files"></Files>
  66. </div>
  67. <div v-else-if="mode === modeCreateAppointment">
  68. <Followup v-bind:id="record.contact.id"></Followup>
  69. </div>
  70. <div v-else>Unknown mode: {{ mode }}</div>
  71. </div>
  72. </template>
  73. <script>
  74. import ContactDetails from "@/components/ContactDetails.vue";
  75. import Entry from "@/components/Entry.vue";
  76. import Files from "@/components/Files.vue";
  77. import Followup from "@/components/Followup.vue";
  78. import History from "@/components/History.vue";
  79. import InsuranceDetails from "@/components/InsuranceDetails.vue";
  80. import Photo from "@/components/Photo.vue";
  81. import ScholarDetails from "@/components/ScholarDetails.vue";
  82. import VaccinationDetails from "@/components/VaccinationDetails.vue";
  83. import { mapMutations, mapGetters } from "vuex";
  84. export default {
  85. name: "Record",
  86. components: {
  87. ContactDetails,
  88. Entry,
  89. Files,
  90. Followup,
  91. History,
  92. InsuranceDetails,
  93. Photo,
  94. ScholarDetails,
  95. VaccinationDetails
  96. },
  97. props: ["id", "entry_id"],
  98. computed: {
  99. ...mapGetters(["api", "readonly"]),
  100. entry: function() {
  101. return this.runtimevals.entry;
  102. },
  103. record: function() {
  104. return this.runtimevals.record;
  105. },
  106. modesAvailable: function() {
  107. return [
  108. this.modeDetails,
  109. this.modeHistory,
  110. this.modeFiles,
  111. this.modeCreateAppointment
  112. ];
  113. },
  114. modeDetails: function() {
  115. return "mode_record_details";
  116. },
  117. modeHistory: function() {
  118. return "mode_record_history";
  119. },
  120. modeFiles: function() {
  121. return "mode_record_files";
  122. },
  123. modeCreateAppointment: function() {
  124. return "mode_record_create_appointment";
  125. }
  126. },
  127. data() {
  128. return {
  129. mode: "mode_record_details",
  130. numTeams: 1,
  131. loading: false,
  132. runtimevals: {
  133. record: "",
  134. entry: ""
  135. },
  136. errorPrompt: ""
  137. };
  138. },
  139. methods: {
  140. ...mapMutations(["updateErrorPrompt"]),
  141. updateMode: function(mode) {
  142. this.mode = mode;
  143. },
  144. getRecord: function() {
  145. function getData(endpoint, that, bucket, refs, errorPrompt) {
  146. that["loading"] = true;
  147. if (endpoint) {
  148. fetch(`${endpoint}?id=${that.id}`)
  149. .then(response => response.json())
  150. .then(json => {
  151. if (json) {
  152. that[bucket][refs] = json;
  153. that["loading"] = false;
  154. } else {
  155. that[errorPrompt] = "Response failed.";
  156. that["loading"] = false;
  157. }
  158. })
  159. .catch(error => {
  160. that[errorPrompt] = `Request failed. ${error}`;
  161. that["loading"] = false;
  162. });
  163. } else {
  164. that[errorPrompt] = "No configuration.";
  165. that["loading"] = false;
  166. }
  167. }
  168. getData(this.api.record, this, "runtimevals", "record", "errorPrompt");
  169. },
  170. getEntry: function() {
  171. function getData(endpoint, that, bucket, refs, errorPrompt) {
  172. that["loading"] = true;
  173. if (endpoint) {
  174. fetch(`${endpoint}?id=${that.entry_id}`)
  175. .then(response => response.json())
  176. .then(json => {
  177. if (json) {
  178. that[bucket][refs] = json;
  179. that["loading"] = false;
  180. } else {
  181. that[errorPrompt] = "Response failed.";
  182. that["loading"] = false;
  183. }
  184. })
  185. .catch(error => {
  186. that[errorPrompt] = `Request failed. ${error}`;
  187. that["loading"] = false;
  188. });
  189. } else {
  190. that[errorPrompt] = "No configuration.";
  191. that["loading"] = false;
  192. }
  193. }
  194. getData(this.api.entry, this, "runtimevals", "entry", "errorPrompt");
  195. }
  196. },
  197. mounted() {
  198. this.getRecord();
  199. if (this.entry_id) {
  200. this.updateMode(this.modeHistory);
  201. this.getEntry();
  202. }
  203. },
  204. watch: {
  205. entry_id() {
  206. this.runtimevals.entry = "";
  207. this.getEntry();
  208. }
  209. }
  210. };
  211. </script>
  212. <style scoped>
  213. .details-container {
  214. display: flex;
  215. flex-wrap: wrap;
  216. justify-content: space-between;
  217. background-color: #faffff;
  218. }
  219. .details-item {
  220. min-width: 300px;
  221. width: 30%;
  222. margin-bottom: 2%;
  223. }
  224. .headline-container {
  225. display: flex;
  226. flex-wrap: wrap;
  227. }
  228. .headline-item {
  229. padding-right: 2%;
  230. }
  231. .headline-item:last-of-type {
  232. min-width: 50%;
  233. }
  234. </style>