From a440df171ef0900638f2c6e44c56bb9f201c7d0e Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Thu, 7 Sep 2017 14:36:51 +0200 Subject: [PATCH] finsihed appointment types are highlighted in the visit detail view --- smash/web/static/css/smash.css | 11 ++++++ .../visit_appointment_types_field.html | 27 ++++++++++++++ .../web/templates/subjects/visitdetails.html | 20 ++++++----- smash/web/templates/visits/details.html | 36 ++++++++++--------- 4 files changed, 69 insertions(+), 25 deletions(-) create mode 100644 smash/web/templates/includes/visit_appointment_types_field.html diff --git a/smash/web/static/css/smash.css b/smash/web/static/css/smash.css index 64399d3d..d7391e23 100644 --- a/smash/web/static/css/smash.css +++ b/smash/web/static/css/smash.css @@ -26,4 +26,15 @@ .top-buffer { margin-top: 20px; +} + +.checkbox-circle { + width: 10px; + height: 10px; + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + border-radius: 5px; + float:left; + margin:5px; + display: inline; } \ No newline at end of file diff --git a/smash/web/templates/includes/visit_appointment_types_field.html b/smash/web/templates/includes/visit_appointment_types_field.html new file mode 100644 index 00000000..4e167755 --- /dev/null +++ b/smash/web/templates/includes/visit_appointment_types_field.html @@ -0,0 +1,27 @@ +<div class="col-md-6 form-group {% if field.errors %}has-error{% endif %} multi-checkboxes"> + <label for="{# TODO #}" class="col-sm-4 control-label">{{ field.label }}</label> + <div class="col-sm-8"> + <ul id="id_{{ field.name }}"> + {% for pk, choice in field.field.widget.choices %} + <li> + <label for="id_{{ field.name }}_{{ forloop.counter0 }}"> + <div class="checkbox-circle" + style=" + {% for appointment in appointments %}{% for appointment_type in appointment.appointment_types.all %}{% if appointment_type.id == pk|slugify or appointment_type.id == pk %}{% if appointment.status == "FINISHED" %} + background: green; + {% elif appointment.status == "SCHEDULED" %} + background: orange; + {% endif %}{% endif %}{% endfor %}{% endfor %} + "></div> + <input {% if readonly %}disabled="disabled"{% endif %} + {% for option in field.value %}{% if option == pk|slugify or option == pk %}checked="checked" + {% endif %}{% endfor %} type="checkbox" + id="id_{{ field.name }}_{{ forloop.counter0 }}" + name="{{ field.name }}" + value="{{ pk }}" + />{{ choice }}</label> + </li> + {% endfor %} + </ul> + </div> +</div> diff --git a/smash/web/templates/subjects/visitdetails.html b/smash/web/templates/subjects/visitdetails.html index 2bded9f9..dc586ec3 100644 --- a/smash/web/templates/subjects/visitdetails.html +++ b/smash/web/templates/subjects/visitdetails.html @@ -45,16 +45,20 @@ </div> <div class="box-footer"> {% for field in element.0 %} - <div class="col-md-6 form-group {% if field.errors %}has-error{% endif %} {% if field|is_checkbox %}multi-checkboxes{% endif %}"> - <label class="col-sm-4 control-label">{{ field.label }}</label> + {% if not field|is_checkbox %} + <div class="col-md-6 form-group {% if field.errors %}has-error{% endif %} {% if field|is_checkbox %}multi-checkboxes{% endif %}"> + <label class="col-sm-4 control-label">{{ field.label }}</label> - <div class="col-sm-8"> - {{ field|disable|add_class:'form-control' }} - </div> + <div class="col-sm-8"> + {{ field|disable|add_class:'form-control' }} + </div> - {% if field.errors %} - <span class="help-block">{{ field.errors }}</span>{% endif %} - </div> + {% if field.errors %} + <span class="help-block">{{ field.errors }}</span>{% endif %} + </div> + {% else %} + {% include 'includes/visit_appointment_types_field.html' with field=field appointments=element.1 readonly="true" %} + {% endif %} {% endfor %} </div> </div> diff --git a/smash/web/templates/visits/details.html b/smash/web/templates/visits/details.html index 1df9ff26..6953e3a9 100644 --- a/smash/web/templates/visits/details.html +++ b/smash/web/templates/visits/details.html @@ -30,30 +30,32 @@ </div> <div class="box-header with-border"> - <h3 class="box-title">Details of visit - - </h3> + <h3 class="box-title">Details of visit </h3> </div> <form method="post" action="" class="form-horizontal"> {% csrf_token %} <div class="box-body"> {% for field in vform %} - <div class="col-md-6 form-group {% if field.errors %}has-error{% endif %} {% if field|is_checkbox %}multi-checkboxes{% endif %}"> - <label for="{# TODO #}" class="col-sm-4 control-label"> - {{ field.label }} - </label> + {% if not field|is_checkbox %} + <div class="col-md-6 form-group {% if field.errors %}has-error{% endif %} {% if field|is_checkbox %}multi-checkboxes{% endif %}"> + <label for="{# TODO #}" class="col-sm-4 control-label">{{ field.label }}</label> - <div class="col-sm-8"> - {{ field|add_class:'form-control' }} + {# {% if not field|is_checkbox %}#} + <div class="col-sm-8"> + {{ field|add_class:'form-control' }} + </div> + + {% if field.errors %} + <span class="help-block"> + {{ field.errors }} + </span> + {% endif %} </div> + {% else %} + {% include 'includes/visit_appointment_types_field.html' with field=field appointments=loApp %} + {% endif %} - {% if field.errors %} - <span class="help-block"> - {{ field.errors }} - </span> - {% endif %} - </div> {% endfor %} <div class="col-md-6 form-group"> @@ -165,8 +167,8 @@ {% if field.errors %} <span class="help-block"> - {{ field.errors }} - </span> + {{ field.errors }} + </span> {% endif %} </div> {% endfor %} -- GitLab