Module: units

Contains the functionalities related to the units page.
Author:
  • Joonas Konki
  • Anu Koskela
  • Mikko Kuhno
  • Henrik Paananen
  • Atte Räty
License:
  • BSD 3-clause, see LICENSE for more details.
Source:

Methods

(static) addResourceToUnitInfo(res)

Creates a label and an input field for the resource and fills them with the information of the resource.
Parameters:
Name Type Description
res object The resource to be shown.
Source:

(static) doc_ready()

This is executed after the HTML page has been loaded. This is a common procedure of all of the client-side modules to initialise the page content.
Source:

(static) fillEditFields()

Empties the edit fields and fills them with the information of the current unit, if the information can be found. Otherwise shows the placeholders.
Source:

(static) hideResource()

Sets hidden to true for the current resource to prevent the resource from being displayed in the module.
Source:

(static) initModal()

Initialises the modal where the resources are selected.
Source:

(static) makeUpdateResource(res)

Sets the count for the selected resource.
Parameters:
Name Type Description
res object The selected resource.
Source:
Returns:
A function which sets the count for the selected resource.

(static) resetView()

Empties the edit fields of the unit and reloads the current unit list.
Source:

(static) setCurrentSelection()

Sets the information of the chosen unit to the corresponding fields.
Source:

(static) setNewUnit()

Makes a new object by cloning the empty unit received from the database.
Source:

(static) setResCopy()

Copies the list of resources and for each resource sets hidden to false if the current unit already uses the resource.
Source:

(static) updateResInfo()

If a resource has been selected, sets its information to the corresponding fields. Otherwise shows a notification.
Source:

(static) updateResList(inputText)

Displays all the resources in the list of resources that match the search criterion.
Parameters:
Name Type Description
inputText string The string that has to be found in the resource's name.
Source:

(static) updateResources()

Displays the current unit's resources and their amounts in the displayed resources area.
Source:

(static) updateUnitList(inputText)

Fills the unit list with the units that match the search string.
Parameters:
Name Type Description
inputText string String that has to be found in the name of every displayed unit.
Source:

(inner) btnAddNewUnit click()

Empties the edit fields and sets the placeholders. Sets the current unit to null. Initialises the resource area.
Source:

(inner) btnDeleteUnit click()

If the current unit id is not null, removes it from the database.
Source:

(inner) btnSaveChanges click()

If current unit id is null, makes a call to create a new unit with the given parameters. Otherwise makes a call to save changes to the current unit. If important fields are empty, shows a notification without making a call. Updates the view after the call has been completed.
Source:

(inner) modalButtonAdd click()

Adds the selected resource to the list of resources of the current unit and updates the view.
Source:

(inner) modalButtonYes click()

Makes a call to remove the current unit from the database.
Source:

(inner) resourceList change()

Displays the information of the selected resource.
Source:

(inner) unitList change()

Makes a clone of the selected unit and sets its information to the edit fields.
Source: