Contains the functionalities related to the units page.
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. |
(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.
(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.
(static) hideResource()
Sets hidden to true for the current resource to prevent the resource
from being displayed in the module.
(static) initModal()
Initialises the modal where the resources are selected.
(static) makeUpdateResource(res)
Sets the count for the selected resource.
Parameters:
Name | Type | Description |
---|---|---|
res |
object | The selected resource. |
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.
(static) setCurrentSelection()
Sets the information of the chosen unit to the corresponding fields.
(static) setNewUnit()
Makes a new object by cloning the empty unit received from the database.
(static) setResCopy()
Copies the list of resources and for each resource sets hidden to false if the
current unit already uses the resource.
(static) updateResInfo()
If a resource has been selected, sets its information to the corresponding
fields. Otherwise shows a notification.
(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. |
(static) updateResources()
Displays the current unit's resources and their amounts in the displayed
resources area.
(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. |
(inner) btnAddNewUnit click()
Empties the edit fields and sets the placeholders.
Sets the current unit to null. Initialises the resource area.
(inner) btnDeleteUnit click()
If the current unit id is not null, removes it from the database.
(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.
(inner) modalButtonAdd click()
Adds the selected resource to the list of resources of the current
unit and updates the view.
(inner) modalButtonYes click()
Makes a call to remove the current unit from the database.
(inner) resourceList change()
Displays the information of the selected resource.
(inner) unitList change()
Makes a clone of the selected unit and sets its information to the
edit fields.