For this last sprint, our team made several steps to continue tackling additional features for our left navigation bar. As I described in the previous sprint retrospective, we had made a list of other tasks that would make sense to be added to this minimum viable product. Last sprint, I focused primarily on the CSS styling of the navigation bar. This sprint, I spent more time refactoring our code so that it would be more easily modifiable and versatile for upcoming semesters. We also looked at integration of other components into the main app.
Towards the beginning and throughout the sprint, our team had been starting to discuss how our code would work with other components that other teams were making. Instead of putting all of our navigation bar code into the app.component.html file of the Angular project (the main app’s HTML), we were directed to make a new component, called “left-nav-bar,” which would store all of the code that we had already written. The file structure of this component is the same as the “app” component, so that our code was easily transferrable, moving the contents of the app.component.html file to the left-nav-bar.component.html file, as well as updating the left-nav-bar’s CSS file in a similar manner. To generate this new component through the terminal, I used the command, “ng generate component left-nav-bar” (reference found here). Then, once all of the files of the left-nav-bar component had been updated, the app.component.html file was modified such that it referenced left-nav-bar. This utilized the left-nav-bar selector tag, found in the left-nav-bar.component.ts file. The following line is the only one in the app.component.html file: <app-left-nav-bar></app-left-nav-bar>. With this left-nav-bar component, rather than having all of the code in the app component, any other component could utilize the left-nav-bar code. It becomes easier for the left-nav-bar to be used elsewhere through referencing it, whether in the main app or within another component.
Another significant addition to the navigation bar was a home button, so that the user could navigate to a primary home page at any time. This home page would also be the default page when initially launching the main application. In order to go about this task, I once again used the above mentioned command to generate a new component: “ng generate component home-page”. This created the home-page component in the “app” folder. Fortunately, I did not have to change anything that was created from this command. However, my component was missing a routing module, which implements the Router service provided by Angular to display certain components or component views, based on the definition of a given URL (reference found here). In order to successfully create this module file, I created a file with a name (home-page-routing.module.ts) that matched other components’ router module names (patient-search-routing.module.ts, for example). Then, I copied the code from the latter file into the former, and changed the names presented in the home-page-routing file accordingly such that they reflected that component and not the patient-search component. For example, I changed the name of the router module class name from PatientSearchRoutingModule to HomePageRoutingModule. The following line was also added to the home-page-module.ts file such that the importing of this routing module into the application was recognized: import { HomePageRoutingModule } from ‘./home-page-routing.module’;. I also updated the app-routing.module.ts file (more specifically, its list of possible Routes) to add a new path to this home page component, as such: path:’home-page’,. Finally, I added the following code to the end of this list so that upon starting the app, the home page component view would be immediately shown – path: ”, redirectTo: ‘/home-page’, pathMatch: ‘full’. The redirectTo section allowed me to specify that component.
After these were added to the app, we set to start merging our app with other teams’ components. However, this encountered further issues, as these other components were overlaying our navigation bar while the application was running and caused them to not work properly at the same time. While we did not have much time to fix this issue, we discussed that continuous integration with other teams should have been a top priority from earlier sprints, and unfortunately this was not considered until the last minute. Hopefully during future semesters, other classes can ensure that this process is started earlier so that we could end up with a working app with multiple components.
Thanks for reading! It’s been a productive semester, and I hope to have more posts soon about my experience as a new software engineer.
From the blog CS@Worcester – Hi, I'm Kat. by Kat Law and used with permission of the author. All other rights reserved by the author.