FW Apps Tutorial - Models

Before you get too far, make sure to go through the process to install the Training App for developing on your local. Use the repository given to you by an admin, which should be training-developer-app-{username}, and Install it for development (using the Git url). You can find documentation for that here.

Introduce It!

Ember Models are the bread and butter of our Informatics application. Every part of the app revolves around the success of the Models. Models are what store the data for the client side to access. They are the integral link between the user and the server side (which in turn links the client side to the database). So information stored in the database is ultimately stored in the ember models on the client side.

Please refresh yourself on the brief overview on models given above at this time. It can be found at Conceptual Introduction - Client - Models .

Learn It!

For Models, you can get a general picture of the models by reading both the Ember guides on models and the Ember API docs on models. Begin with the Ember Guides, but SKIP the following pages, as they are “advanced topics,” which are used very rarely in the apps:

You may wish to go back and look at these during your specific work in the apps, but for a general introduction to our apps, these are unnecessary. Our apps do use both serializers and adapters, thoough they very rarely use other than the default, so knowing where to find information on each of these pages might be helpful for your future development. If you have extra time this unit, and wish to learn more (and you don’t feel too overwhelmed), then you may read these two pages for extra information.

Keep all these pages in mind, and continue to refer back to them as you complete the following assignments in the bring it home section.

Bring It Home!

Since this is the first Unit, there are not a lot of things you have learned, so the things you are doing are fairly simple additions to the models. In your training app, you will notice that there are two models, checkout and book. Each of these models is very underdeveloped. Your task for this Unit training section is to develop them the rest of the way. While the fetching and creating of models will be very important in apps, most of that is done through Controllers or Components, so we will come back to fetching data in future units. Here are your assignments:

  1. Issue #1: A book should have more than just title and author. I want to be able to know a lot of information about it. I would like to be able to view the information about the book such as: title, author’s name, genre, publication date, page count, the location in the library, the book’s condition, and the isbn of the book. Please be careful to think about what data type each of these values should be. Feel free to check out other informatics apps for examples of different data types.

    • Note: this issue would ordinarily require database changes, but these have already been done for you, as database and server side changes will be discussed at a later time.
    • Note: in the Ember Guides it suggested that you use the date transformer (attribute type) for dates and times, but in informatics we have a custom transformer. Look at the checkout model for an example of how to use it.
    • Hint: if you find it is not working, check the server side Model (server/src/Model/Book.php look at the aliases array) to see what the name of each attribute should be (otherwise saving won’t work correctly).
    • For Testing: I have placed test code at {studentid}.localhost.com/trad/#/books for you. This will allow you to test the validity of your model and make sure it works. This code will be removed for the next stage, as it is very basic code (vanilla HTML) for testing purposes only. Please do not use this code as a standard for any other code you write. Please make sure to make at least one book, as it will be used in the next unit. Check your database to ensure that books are being added successfully.
  2. Issue #2: I want more information in a checkout record as well. I think a checkout record should include the following information: the due date, the date the book was checked out, whether or not it has been renewed, the name of the person who checked it out, the email of the person who checked it out, the id/barcode of the person who checked it out, the employee (person currently logged in) who helped them, and the book they checked out (this should include the ability to see information about the book as well, like I might want the ISBN or title of the book that was checked out as well).

    • Note: Remember all of the things you learned above, and refer back to them or ask questions if you need help.
  3. Challenge (Remember, don’t work on this unless you have time): A lot of libraries have a special classification system to know exactly where on a shelf a particular book will be. It uses book subject and author last name to place them in unique categories. The most common of these is called the Dewey Decimal System, but as the Dewey system has over 100,000 possible numbers (not to mention author last name), it is probably best to come up with a new system. Come up with a variable in the model (call it bookClassification) that generates a somewhat special value based on the various other information in the model for book. It should be re-generated anytime one of the attributes you are using changes.

Check It!

Congratulations, you have almost finished your first unit. Please let one of the developer admin know that you have completed this unit, and they will fork the training-developer-model-fork repository for just you, so you can have access to view the answers, and compare your code.

Each commit should be labeled with an issue number, telling you which issue that commit fixes. Anywhere your code differs more substantially than a variable name, note the differences and understand why that code was written by the lead developer.

While yours may not necessarily be “wrong” there may be a better or more “Informatics” way of doing it. Feel free to ask whatever questions you desire about this to any of the Informatics Admin.

After you have sufficiently checked your code, make sure you have pushed all your changes to bitbucket (on the old repository), and then please delete your trad folder, and complete the Install App For Development for the new repository with the answer code. After you have sufficiently downloaded and installed this app, you are ready to continue to the next Unit when you get the go ahead from the developer admin.