]> git.plutz.net Git - lobster/blobdiff - cards/widgets.sh
display "new therapy" button only when no therapies exist
[lobster] / cards / widgets.sh
index b0d188cabb06b90c9bc77ae0ca5d436480836e03..8be5cdec305c2f20679d34414f0c98135cc0b607 100755 (executable)
@@ -137,7 +137,9 @@ card_item(){
         printf '[h3 %s]' "$(l10n therapies)"
         (cd "$_DATA/therapies/"; printf '%s\n' "${client}".*.tpy) \
         | while read tpyfile; do
-          [ "$tpyfile" = "${client}.*.tpy" ] && break
+          [ "$tpyfile" = "${client}.*.tpy" ] \
+          && printf '[a .item .therapy href="/therapies/%s/new" . +]' "${client}" \
+          && break
           tpy="${tpyfile%.tpy}";
           tpydates="$(sed -En 's;^session[0-9]+_date:;;p;' "$_DATA/therapies/$tpyfile" \
                       | sort \
@@ -146,7 +148,6 @@ card_item(){
           printf '[a .item .therapy href="/therapies/%s" . %s] ' \
                  "${tpy%.*}/${tpy#*.}" "$(HTML "${tpydates:--}")"
         done |sort -n
-        printf '[a .item .therapy href="/therapies/%s/new" . +]' "${client}"
         ;;
       *)[ $cnt -gt 0 ] && printf '[h3 %s]' "$(l10n "$item")"
         shy="$(printf '\302\255')"