Adding a new view

From MMS Wiki
Jump to: navigation, search

We are using angular ui-router for views, which are called states for the router. A UI-router state has 3 basic components: the data (api call to server), the template (HTML), controller logic (JS) They need to be declared as a state in states.js.

  • Template (HTML)

Resides in web/views/. Just add a new file there. Easiest to copy-paste a similar example and then rework the copy.

  • Controller (JS)

Should be in web/scripts/comparison/controllers/. Again, copy-paste a similar example and work from there. For the .js to be included with the page, it needs to be added into web/build_blocks/comparison_js.html

  • API call

Server side apis reside in server/views/. Again, copy-paste an existing example. Any new files there need to be added to server/views/__init__.py to be accessible.

Adding new directives and services

For small directives and services, just add them to web/general/controllers/Snippets.js. For larger ones, follow the same steps as above for JS, only put them to directives/ or services/ folder instead of controllers/. For directives with large HTML templates, use web/views/misc/ folder for the template HTML.