UploadTemplates constructor
the role when logged in: 'mdg', 'mus', 'com', 'syc'
builds the help panel for adm regions
builds an accordion listing a user's uploads
checks the input entered by the user in the CSV textarea
test date syntax if it matches postgres syntax four digits, hyphen, two digits, hyphen, two digits, e.g. 2024-06-01) note that the test always returns true when date is picked from dropdowns
a date, formatted by a user
checks if a dataset already exists
the unique combination that represents a dataset
checks if an indicator is valid
the selected category
the selected subcategory
an indicator code, manually typed in by a user
check whether all input elements have been populated and if campaign not too long Note that the "Check" button already checks for missing inputs This is just a double check in case the user passes the check and then (maybe accidentally) changes the dropdown values etc.
input-errors-detected or no-input-errors-detected
checks if an ISO code is valid
the selected administrative region
an ISO code, manually typed in by a user
checks if CSV line meets the expected count or differs from it
array of elements entered by the use
status
rejects the value if it is not a number exception: 'null', 'NULL', 'Null' are excepted as a value, even though not a number
the input value
clears all input fields
adds values to an object in a nested structure that might not exist yet
an object
path within the object where the value should be stored
value to be stored
sends the data to the server to delete an upload
disables or enables all user inputs
true = disable, false = enable
handler for the change event on a dropdown
the type of the dropdown: 'category', 'subcategory', 'name'
formats a date to the postgres format combines the provided year and month and adds the first day of the month, e.g. "2023-08-01" single indicators: gets year-month, e.g. "2023-08" multiple indicators: gets "read-from-dropdown" (the value is not provided with the dataset, and is read from the dropdown)
the combination of "year-month" or "read-from-dropdown"
datestamp formatted in potgres syntax, e.g. "2023-08-01"
gets a datestamp in postgres format (year-month-day) and returns a text that is better for display
datestamp in postgres format (year-month-day)
date_display
creates an array of years from 1975 until current year
years array of integers
based on selected options in the interface, calculates how many elements are expected in a CSV line
line_expected_elements the number of elements expected
reads the infotexts and creates an object with indicator codes as keys each indcator code is mapped to another object that holds the fr and en infotexts for a specific datestamp
{ "indicator_name_code": { "2000-06-01": {"fr": "", "en": ""}, "2000-01-01": {"fr": "","en": ""} }, "indicator_name_code": { "1999-12-01": {"fr": "", "en": ""}, }, }
infotexts_object an object
disables the input textarea on input change
triggered when an indicator is chosen or when the date checkbox is toggled only populates the hint when the indicator dropdown has been used (before that it is not clear whether one or multiple indicators will be entered) possible outcomes of the hint:
populates the date pickers
populates a dropdown
the type of the dropdown: 'category', 'subcategory', 'name'
replaces tabs with commas in the CSV textarea input
the paste event
resets a dropdown
the type of the dropdown: 'category', 'subcategory', 'name'
shows a modal to delete an upload
click event
handler for toggle changes in the date checkbox
checkbox toggle event
uploads the user input from the CSV textarea to the server
the value to be testet
if the value is actually numeric
UploadTemplates class