From: paul Date: Mon, 14 Nov 2016 17:06:51 +0000 (+0000) Subject: unify view functions for cards X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=0dc31a9e7992c227b680180d3ceee031ac293169;p=confetti unify view functions for cards svn path=/trunk/; revision=148 --- diff --git a/static/cards.css b/static/cards.css index 5d78a0f..002e66b 100644 --- a/static/cards.css +++ b/static/cards.css @@ -187,6 +187,7 @@ display: block; max-width: 100%; word-wrap: break-word; + white-space: pre-line; } .card .section .item label { font-weight: bold; diff --git a/templates/view_attendee.sh b/templates/view_attendee.sh index 5966729..10cb06e 100755 --- a/templates/view_attendee.sh +++ b/templates/view_attendee.sh @@ -1,4 +1,4 @@ -# Copyright 2014, 2015 Paul Hänsch +# Copyright 2014 - 2016 Paul Hänsch # # This file is part of Confetti. # @@ -15,71 +15,119 @@ # You should have received a copy of the GNU Affero General Public License # along with Confetti. If not, see . +list_items(){ + item="$1" + [ -n "${values[$item]+x}" ] && \ + printf '

%s

\n' "$(l10n $item)" + for n in "$item" "$item"{0..100}; do + [ -z "${values[$n]+x}" ] && break \ + || printf '%s\n' \ + "$item" "$(htmlsafe ${values[$n]})" + done +} + +list_section(){ + printf '
' "$1" + shift 1 + for each in $@; do + list_items "$each" + done + printf '
' +} + n=$(printf %s "$values[N+3] $values[N+1] $values[N+2] $values[N+0] $values[N+4]" \ | sed -r ':X;$!{N;bX}; s;^[\n ]+;;; s;[\n ]+$;;; s;[\r\t\n ]+; ;g;' ) fullname="${n:-${values[FN]:-${values[NICKNAME]}}}" -cat < -

$fullname

- ${values[GENDER]:+$(l10n $values[GENDER])} - - $(for n in NICKNAME NICKNAME{0..10}; do - echo "${values[$n]:+aka. $values[$n]}" - done) - - ${values[BDAY]:+*: $values[BDAY]} - ${values[X-ZACK-JOINDATE]:+$(l10n label_join): $values[X-ZACK-JOINDATE]} - ${values[X-ZACK-LEAVEDATE]:+$(l10n label_leave): $values[X-ZACK-LEAVEDATE]} - ${values[SOUND]:+} - ${values[PHOTO]:+} - ${values[LOGO]:+} -
-

$(l10n TEL)

- $(for n in TEL TEL{0..10}; do - echo "${values[$n]:+$values[${n}_TYPE] $values[$n]}" - done) -
- ${values[EMAIL]:+

$(l10n EMAIL)

} - $(for n in EMAIL EMAIL{0..10}; do - echo "${values[$n]:+}" - done) - ${values[IMPP]:+

$(l10n IMPP)

} - $(for n in IMPP IMPP{0..10}; do - echo "${values[$n]:+$values[${n}_TYPE] $values[$n]}" - done) -
-

$(l10n ADR)

- $(for n in ADR ADR{0..10}; do - echo "${values[$n]:+$values[$n]}" - done) - ${values[URL]:+

$(l10n URL)

} - $(for n in URL URL{0..10}; do - echo "${values[$n]:+$values[$n]}" - done) -
-

$(l10n NOTE)

- $(for n in NOTE NOTE{0..10}; do - echo "${values[$n]:+$values[$n]}" - done) -
-

$(l10n course_attendance)

-
    - $(sed -rn 's:(.*)\t'$id'$:\1:p' "$_DATA/mappings/attendance" |while read each; do - cname="$(sed -rn 's:^SUMMARY\:(.*)$:\1:p' "$_DATA/ical/$each")" - echo '
  • '$cname'
  • ' - done) -
-
-END_HTML +hi_company="${values[X-HEALTH-INSURANCE+0]}" + hi_number="${values[X-HEALTH-INSURANCE+1]}" + hi_status="${values[X-HEALTH-INSURANCE+2]}" + +printf '
+

%s

+' "$fullname" +[ -n "$values[GENDER]" ] && printf ' + %s + ' "$(l10n "$values[GENDER]")" + +for n in NICKNAME NICKNAME{0..100}; do + [ -z "${values[$n]+x}" ] && break \ + || printf ' + aka. %s + ' "$(htmlsafe ${values[$n]})" +done + +[ -n "$values[BDAY]" ] && printf ' + *:%s + ' "$(htmlsafe "$values[BDAY]")" +[ -n "$values[X-ZACK-JOINDATE]" ] && printf ' + %s:%s + ' "$(l10n label_join)" "$(htmlsafe "$values[X-ZACK-JOINDATE]")" +[ -n "$values[X-ZACK-LEAVEDATE]" ] && printf ' + %s:%s + ' "$(l10n label_leave)" "$(htmlsafe "$values[X-ZACK-LEAVEDATE]")" + +[ -n "$values[SOUND]" ] && printf ' + ' "$values[SOUND]" + +[ -n "$values[PHOTO]" ] && printf ' + + ' "${values[PHOTO_TYPE]}" "${values[PHOTO]}" + +[ -n "$values[LOGO]" ] && printf ' + + ' "${values[LOGO_TYPE]}" "${values[LOGO]}" + +if [ "$PROFILE" = circus ]; then + printf '
' + + list_section phone TEL + list_section message EMAIL IMPP URL + list_section address ADR + list_section note NOTE + + printf '

%s

    ' "$(l10n course_attendance)" + sed -rn 's:(.*)\t'"$id"'$:\1:p' "$_DATA/mappings/attendance" |while read each; do + cname="$(sed -rn 's:^SUMMARY\:(.*)$:\1:p' "$_DATA/ical/$each")" + printf '
  • %s
  • ' "$each" "$(htmlsafe $cname)" + done + printf '
' +elif [ "$PROFILE" = medical ]; then + list_items ADR + list_items URL + printf '' + + list_section phone TEL EMAIL IMPP + + printf '

%s

' "$(l10n X-HEALTH-INSURANCE)" + [ -n "$hi_company" ] && printf '%s' \ + "$(htmlsafe "$hi_company")" + [ -n "$hi_number" ] && printf '%s' \ + "$(l10n hi_number)" "$(htmlsafe "$hi_number")" + [ -n "$hi_status" ] && printf '%s' \ + "$(l10n hi_status)" "$(htmlsafe "$hi_status")" + printf '
' + + list_section note NOTE X-CLIENT-REFERRAL + + printf '

%s

    ' "$(l10n prescriptions)" + declare -A mpx + find "$_DATA/prescriptions/" -name "${id%.vcf}.*.mpx" \ + | while read pfile; do + mpx=(); cat "$pfile" |while read -r line; do + val="${line#*:}" + mpx[${line%%:*}]="$(htmlsafe "${val//\\n/$BR}")" + done + printf '
  • %s: %s - %s
  • ' \ + "${id}" "${pfile##*/}" "${mpx[date]}" "${mpx[indicator]}" \ + "$([ -n "${mpx[remidy]}" ] && printf '%s %s' "${mpx[quantity]}" "${mpx[remidy]}" + for n in {0..10}; do + [ -n "${mpx[remidy${n}]}" ] && printf ', %s %s' "${mpx[quantity${n}]}" "${mpx[remidy${n}]}" + done + )" + done |sort -r + printf '
' +fi diff --git a/templates/view_client.sh b/templates/view_client.sh index 2cb124b..0fe5e98 100755 --- a/templates/view_client.sh +++ b/templates/view_client.sh @@ -15,75 +15,91 @@ # You should have received a copy of the GNU Affero General Public License # along with Confetti. If not, see . -n=$(printf %s "$values[N]" \ - | sed -rn 's:^([^;]*)(\;[^;]*)(\;[^;]*)?(\;[^;]*)?(\;[^;]*)?$:\4 \2 \3 \1 \5:gp' \ - | sed -r 's:,: :;s:\;: :g;s: +: :g;s:^ $::;' +list_items(){ + item="$1" + [ -n "${values[$item]+x}" ] && \ + printf '

%s

\n' "$(l10n $item)" + for n in "$item" "$item"{0..100}; do + [ -z "${values[$n]+x}" ] && break \ + || printf '%s\n' \ + "$item" "$(htmlsafe ${values[$n]})" + done +} + +list_section(){ + printf '
' "$1" + shift 1 + for each in $@; do + list_items "$each" + done + printf '
' +} + +n=$(printf %s "$values[N+3] $values[N+1] $values[N+2] $values[N+0] $values[N+4]" \ + | sed -r ':X;$!{N;bX}; s;^[\n ]+;;; s;[\n ]+$;;; s;[\r\t\n ]+; ;g;' ) fullname="${n:-${values[FN]:-${values[NICKNAME]}}}" -hi_company="$(printf %s "${values[X-HEALTH-INSURANCE]}" |cut -d\; -f1)" -hi_number="$(printf %s "${values[X-HEALTH-INSURANCE]}" |cut -d\; -f2)" -hi_status="$(printf %s "${values[X-HEALTH-INSURANCE]}" |cut -d\; -f3)" +hi_company="${values[X-HEALTH-INSURANCE+0]}" + hi_number="${values[X-HEALTH-INSURANCE+1]}" + hi_status="${values[X-HEALTH-INSURANCE+2]}" + +printf '
+

%s

+' "$fullname" +[ -n "$values[GENDER]" ] && printf ' + %s + ' "$(l10n "$values[GENDER]")" +for n in NICKNAME NICKNAME{0..100}; do + [ -z "${values[$n]+x}" ] && break \ + || printf ' + aka. %s + ' "$(htmlsafe ${values[$n]})" +done -cat < -

$fullname

- ${values[GENDER]:+$(l10n $values[GENDER])} +[ -n "$values[BDAY]" ] && printf ' + *:%s + ' "$(htmlsafe "$values[BDAY]")" +[ -n "$values[X-ZACK-JOINDATE]" ] && printf ' + %s:%s + ' "$(l10n label_join)" "$(htmlsafe "$values[X-ZACK-JOINDATE]")" +[ -n "$values[X-ZACK-LEAVEDATE]" ] && printf ' + %s:%s + ' "$(l10n label_leave)" "$(htmlsafe "$values[X-ZACK-LEAVEDATE]")" - $(for n in NICKNAME NICKNAME{0..10}; do - echo "${values[$n]:+aka. $values[$n]}" - done) +[ -n "$values[SOUND]" ] && printf ' + ' "$values[SOUND]" - ${values[BDAY]:+ ${values[BDAY]}} - ${values[SOUND]:+} - ${values[PHOTO]:+} - ${values[LOGO]:+} +[ -n "$values[PHOTO]" ] && printf ' + + ' "${values[PHOTO_TYPE]}" "${values[PHOTO]}" -

$(l10n ADR)

- $(for n in ADR ADR{0..10}; do - echo "${values[$n]:+$values[$n]}" - done) - ${values[URL]:+

$(l10n URL)

} - $(for n in URL URL{0..10}; do - echo "${values[$n]:+$values[$n]}" - done) -
-

$(l10n TEL)

- $(for n in TEL TEL{0..10}; do - echo "${values[$n]:+$(l10n t${values[${n}_TYPE]}) $values[$n]}" - done) - ${values[EMAIL]:+

$(l10n EMAIL)

} - $(for n in EMAIL EMAIL{0..10}; do - echo "${values[$n]:+$values[$n]}" - done) - ${values[IMPP]:+

$(l10n IMPP)

} - $(for n in IMPP IMPP{0..10}; do - echo "${values[$n]:+$values[${n}_TYPE] $values[$n]}" - done) -
+ list_section phone TEL EMAIL IMPP + +cat <<-END_HTML +

$(l10n X-HEALTH-INSURANCE)

${hi_company:+${hi_company}} ${hi_number:+ ${hi_number}} ${hi_status:+ ${hi_status}} -
- ${values[NOTE]:+

$(l10n NOTE)

} - $(for n in NOTE NOTE{0..10}; do - echo "${values[$n]:+$values[$n]}" - done) - ${values[X-CLIENT-REFERRAL]:+

$(l10n X-CLIENT-REFERRAL)

} - $(for n in X-CLIENT-REFERRAL X-CLIENT-REFERRAL{0..10}; do - echo "${values[$n]:+$values[$n]}" - done) -
+cat <<-END_HTML +

$(l10n prescriptions)

    $(declare -A mpx