UploadTemplates class

Constructors

  • UploadTemplates constructor

    Parameters

    • user_role: string

      the role when logged in: 'mdg', 'mus', 'com', 'syc'

    Returns UploadTemplates

Properties

accordion_user_uploads: HTMLDivElement
btn_check_csv: HTMLButtonElement
btn_upload_data: HTMLButtonElement
btnDeleteUpload: HTMLButtonElement
checkbox_projected_data: HTMLInputElement
checkbox_provide_date: HTMLInputElement
config_indicators: Record<string, any>
config_iso_codes: Record<string, any>
container_adm_regions_help: HTMLDivElement
container_csv_preview_table: HTMLDivElement
container_indicators_help: HTMLDivElement
container_infotexts_inputs: HTMLDivElement
csv_textarea: HTMLTextAreaElement
current_line_causes_override: boolean
current_line_has_errors: boolean
date_provided_for_each_value: boolean
dropdown_administrative_region: HTMLSelectElement
dropdown_category: HTMLSelectElement
dropdown_date_month: HTMLSelectElement
dropdown_date_year: HTMLSelectElement
dropdown_indicator_name: HTMLSelectElement
dropdown_subcategory: HTMLSelectElement
entering_multiple_indicators: boolean
errors_persist_block_upload: boolean
hint_csv_syntax: HTMLParagraphElement
idCurrentUpload: string
indicators_upload_array: any
input_campaign: HTMLInputElement
lang: string
line_error_messages: any
mapping_upload_uuid_to_data: any
modalDeleteUpload: any
months: Record<string, any>
unique_data_combinations: Record<string, any>
uploads_infos: any
user_country_code: string

Methods

  • builds the help panel for adm regions

    Returns void

  • builds an accordion listing a user's uploads

    Returns void

  • checks the input entered by the user in the CSV textarea

    Returns void

  • 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

    Parameters

    • datestamp: string

      a date, formatted by a user

    Returns void

  • checks if a dataset already exists

    Parameters

    • unique_combination_key: string

      the unique combination that represents a dataset

    Returns void

  • checks if an indicator is valid

    Parameters

    • selected_category: string

      the selected category

    • selected_subcategory: string

      the selected subcategory

    • indicator_name: string

      an indicator code, manually typed in by a user

    Returns void

  • 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.

    Returns "input-errors-detected" | "no-input-errors-detected"

    input-errors-detected or no-input-errors-detected

  • checks if an ISO code is valid

    Parameters

    • selected_administrative_region: string

      the selected administrative region

    • iso_code: string

      an ISO code, manually typed in by a user

    Returns void

  • checks if CSV line meets the expected count or differs from it

    Parameters

    • current_line_array: any

      array of elements entered by the use

    Returns any

    status

  • rejects the value if it is not a number exception: 'null', 'NULL', 'Null' are excepted as a value, even though not a number

    Parameters

    • value: any

      the input value

    Returns void

  • clears all input fields

    Returns void

  • adds values to an object in a nested structure that might not exist yet

    Parameters

    • obj: any

      an object

    • path: any

      path within the object where the value should be stored

    • value: any

      value to be stored

    Returns void

  • sends the data to the server to delete an upload

    Returns void

  • disables or enables all user inputs

    Parameters

    • disable_true_false: boolean

      true = disable, false = enable

    Returns void

  • handler for the change event on a dropdown

    Parameters

    • dropdown_type: string

      the type of the dropdown: 'category', 'subcategory', 'name'

    Returns void

  • 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)

    Parameters

    • year_month: string

      the combination of "year-month" or "read-from-dropdown"

    Returns string

    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

    Parameters

    • datestamp_postgres: string

      datestamp in postgres format (year-month-day)

    Returns string

    date_display

  • creates an array of years from 1975 until current year

    Returns number[]

    years array of integers

  • based on selected options in the interface, calculates how many elements are expected in a CSV line

    Returns number

    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": ""}, }, }

    Returns any

    infotexts_object an object

  • disables the input textarea on input change

    Returns void

  • 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:

    • iso_code,data_value
    • iso_code,data_value,date
    • indicator_name_code,iso_code,data_value
    • indicator_name_code,iso_code,data_value,date

    Returns void

  • populates the date pickers

    Returns void

  • populates a dropdown

    Parameters

    • dropdown_type: string

      the type of the dropdown: 'category', 'subcategory', 'name'

    Returns void

  • replaces tabs with commas in the CSV textarea input

    Parameters

    • event: any

      the paste event

    Returns void

  • resets a dropdown

    Parameters

    • dropdown_type: string

      the type of the dropdown: 'category', 'subcategory', 'name'

    Returns void

  • shows a modal to delete an upload

    Parameters

    • event: any

      click event

    Returns void

  • handler for toggle changes in the date checkbox

    Parameters

    • event: any

      checkbox toggle event

    Returns void

  • uploads the user input from the CSV textarea to the server

    Returns void

  • Parameters

    • value_to_test: string

      the value to be testet

    Returns boolean

    if the value is actually numeric