diff --git a/doc/config.html b/doc/config.html index b68942a1..37c409b9 100755 --- a/doc/config.html +++ b/doc/config.html @@ -2567,6 +2567,12 @@ Options Location = Main Building{a}, New Building{b}, Old Building{c} entry. If this flag is 1, then the last entry of each thread is shown, otherwise the first thread is displayed. Default for this setting is 1. +
  • + Sort Attribute Options = 0|1
    + If this opeion is 1, all attribute options are sorted alphanumerically. This + can be handy when locating options from long lists in drop-down boxes in + quick filters for example. Default for this setting is 0. +
  • diff --git a/src/elogd.c b/src/elogd.c index 5ba21ca5..bfd7f921 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -434,6 +434,7 @@ time_t convert_datetime(char *date_string); int get_thumb_name(const char *file_name, char *thumb_name, int size, int index); int create_thumbnail(LOGBOOK * lbs, char *file_name); int ascii_compare(const void *s1, const void *s2); +int ascii_compare2(const void *s1, const void *s2); /*---- Funcions from the MIDAS library -----------------------------*/ @@ -7105,7 +7106,7 @@ int scan_attributes(char *logbook) and attr_flags arrays */ { char list[10000], str[NAME_LENGTH], type[NAME_LENGTH], tmp_list[MAX_N_ATTR][NAME_LENGTH]; - int i, j, n, m; + int i, j, n, m, n_options; if (getcfg(logbook, "Attributes", list, sizeof(list))) { /* reset attribute flags */ @@ -7133,27 +7134,33 @@ int scan_attributes(char *logbook) /* get options lists for attributes */ memset(attr_options, 0, sizeof(attr_options)); for (i = 0; i < n; i++) { + n_options = 0; + sprintf(str, "Options %s", attr_list[i]); if (getcfg(logbook, str, list, sizeof(list))) - strbreak(list, attr_options[i], MAX_N_LIST, ",", FALSE); + n_options = strbreak(list, attr_options[i], MAX_N_LIST, ",", FALSE); sprintf(str, "MOptions %s", attr_list[i]); if (getcfg(logbook, str, list, sizeof(list))) { - strbreak(list, attr_options[i], MAX_N_LIST, ",", FALSE); + n_options = strbreak(list, attr_options[i], MAX_N_LIST, ",", FALSE); attr_flags[i] |= AF_MULTI; } sprintf(str, "ROptions %s", attr_list[i]); if (getcfg(logbook, str, list, sizeof(list))) { - strbreak(list, attr_options[i], MAX_N_LIST, ",", FALSE); + n_options = strbreak(list, attr_options[i], MAX_N_LIST, ",", FALSE); attr_flags[i] |= AF_RADIO; } sprintf(str, "IOptions %s", attr_list[i]); if (getcfg(logbook, str, list, sizeof(list))) { - strbreak(list, attr_options[i], MAX_N_LIST, ",", FALSE); + n_options = strbreak(list, attr_options[i], MAX_N_LIST, ",", FALSE); attr_flags[i] |= AF_ICON; } + + if (n_options && getcfg(logbook, "Sort Attribute Options", str, sizeof(str)) && atoi(str) == 1) { + qsort(attr_options[i], n_options, NAME_LENGTH, ascii_compare2); + } } /* check if attribute required */ @@ -13030,6 +13037,13 @@ int ascii_compare(const void *s1, const void *s2) /*------------------------------------------------------------------*/ +int ascii_compare2(const void *s1, const void *s2) +{ + return stricmp((char *) s1, (char *) s2); +} + +/*------------------------------------------------------------------*/ + void show_config_page(LOGBOOK * lbs) { char str[256], user[80], password[80], full_name[80], user_email[80], logbook[256];