]> git.plutz.net Git - confetti/commitdiff
list courses alphabetically when editing attendant
authorPaul Hänsch <paul@plutz.net>
Wed, 10 Feb 2021 12:19:37 +0000 (13:19 +0100)
committerPaul Hänsch <paul@plutz.net>
Wed, 10 Feb 2021 12:19:37 +0000 (13:19 +0100)
cards/list.sh
cards/widgets.sh

index cd0d21f1e320aa958839b8fdbe75dec051286da9..9f1e1d8ec800eddbf05c952840769de4583c616e 100755 (executable)
@@ -35,13 +35,13 @@ edit_card(){
          [div .section .note    $(edit_item "$card" NOTE)]
          [div .section .attendance
            [h3 $(l10n course_attendance) ] $(
-           for course in "$_DATA"/ical/*.ics; do
+            list_courses |while IFS=/ read course coursename; do
              printf '[label [input type="checkbox" name="attendance" value="%s" %s] %s]' \
-                    "${course##*/}" \
-                    "$(grep -qF "${course##*/} ${cardfile##*/}" "$_DATA/mappings/attendance" \
+                     "$(HTML "$course")" \
+                    "$(grep -qF "${course}     ${cardfile##*/}" "$_DATA/mappings/attendance" \
                        && printf 'checked="checked"'
                       )" \
-                    "$(pdi_value "$(pdi_load "$course")" SUMMARY || l10n "(unnamed course)" |unescape |HTML)"
+                     "$coursename"
            done)
            [h3 $(l10n CATEGORIES) ] $(
            grep -xE '[^ ]+' "$_DATA"/mappings/categories |while read -r cat; do
@@ -95,7 +95,7 @@ print_card(){
           printf '[li [a .item .attendance href="/courses#%s" . %s]]' \
                  "$each" \
                  "$(pdi_value "$(pdi_load "$_DATA/ical/$each")" SUMMARY || l10n "(unnamed course)" |unescape |HTML)"
-        done)]
+        done |sort -k7)]
         $(card_item "$card" CATEGORIES)
       ]
       [div .control
index 463a64814cf0afaa8dd72e74fe23bbca8a9a2fa0..61a6938d9d96ec0f2e712c80a2be734140b5c763 100755 (executable)
@@ -25,10 +25,10 @@ list_courses() {
     cat "$cachefile"
   else
     for file in "$_DATA/ical"/*.ics; do
-      name="$(pdi_value "$(pdi_load "$file")" SUMMARY |HTML)"
-      printf '%s       %s\n' "$file" "$name"
+      name="$(pdi_value "$(pdi_load "$file")" SUMMARY || l10n "(unnamed course)" |unescape |HTML)"
+      printf '%s/%s\n' "${file##*/}" "$name"
     done \
-    | sort -k2 |tee "$cachefile"
+    | sort -t/ -k2 |tee "$cachefile"
   fi
 }
 
@@ -54,7 +54,7 @@ cat <<EOF
       [a href="/categories/" $(l10n edit_categories)]
     ]
     [fieldset .courses
-      $(list_courses | while read course coursename; do
+      $(list_courses | while IFS=/ read course coursename; do
         printf '[label [checkbox "filter_course%i" "|%s" %s] %s ] ' \
                "$n" "$(HTML "${course##*/}")" \
                "$(printf %s "${course##*/}" |grep -qxEe "$2" && printf checked )" \