New datasheet row grouping
authorveltr
Thu, 26 Sep 2013 13:54:06 +0200
changeset 119 984d0da5e84d
parent 118 3d102aed3213
child 120 a09b26c435a1
New datasheet row grouping
src/jocondelab/static/jocondelab/css/front-notice.css
src/jocondelab/templates/jocondelab/front_notice.html
src/jocondelab/templates/jocondelab/partial/datasheet_row.html
src/jocondelab/templatetags/jlutils.py
--- a/src/jocondelab/static/jocondelab/css/front-notice.css	Wed Sep 25 17:34:18 2013 +0200
+++ b/src/jocondelab/static/jocondelab/css/front-notice.css	Thu Sep 26 13:54:06 2013 +0200
@@ -24,24 +24,16 @@
     }
 }
 
-.notice-termgroup {
-    margin: 10px 0 5px; font-size: 16px; font-weight: 800;
-}
-
 .notice-datasheet {
     font-size: 13px;
 }
 
-.notice-title {
-    font-size: 15px;
-}
-
-.notice-datasheet tr {
-    line-height: 1em;
+.datasheet-title {
+    font-size: 15px; font-weight: bold;
 }
 
 .notice-datasheet th {
-    width: 130px; font-weight: 700; text-align: left; padding-right: 2px;
+    width: 130px; font-style: italic; text-align: left; padding-right: 2px;
 }
 
 html[dir=rtl] .notice-datasheet th {
@@ -53,32 +45,48 @@
 }
 
 .notice-datasheet th, .notice-datasheet td {
-    padding-top: 3px;
-}
-
-.notice-marginabove th, .notice-marginabove td {
-    padding-top: 10px;
+    line-height: 1.2em; padding-top: 8px;
 }
 
 .notice-term {
     margin: -2px 5px 4px 0;
 }
 
-.notice-term.term-untranslated, .notice-term.contribution-null {
-    background: transparent; color: #333333; font-style: italic;
+.notice-term.term-untranslated {
+    background: transparent; padding: 0;
+}
+
+.notice-term.term-untranslated:after {
+    content: " ;";
+}
+
+.notice-term.term-untranslated:last-child:after {
+    display: none;
 }
 
 .notice-small {
     font-size: 11px;
 }
 
+.datasheet-group {
+    display: inline;
+}
+
+.datasheet-group:before {
+    content: " | ";
+}
+
+.datasheet-group:first-child:before {
+    display: none;
+}
+
 .notice-contribution-field {
     font-size: 12px; line-height: 20px; height: 20px; padding: 0 4px; border: 1px solid #999999; margin-bottom: 8px;
     border-radius: 4px; width: 90%;
 }
 
 .notice-jocondelink {
-    margin: 10px 0; font-size: 16px; color: #0000C0;
+    margin: 15px 0; font-size: 16px; color: #0000C0;
 }
 
 .contribution-frame {
@@ -101,6 +109,10 @@
     font-size: 14px; line-height: 16px;
 }
 
+.notice-term.contribution-null {
+    background: transparent; font-style: italic;
+}
+
 .contribution-vote {
     float: right; height: 16px; width: 13px; margin-left: 3px;
 }
--- a/src/jocondelab/templates/jocondelab/front_notice.html	Wed Sep 25 17:34:18 2013 +0200
+++ b/src/jocondelab/templates/jocondelab/front_notice.html	Thu Sep 26 13:54:06 2013 +0200
@@ -47,43 +47,84 @@
             <div class="notice-colright-wrapper">
                 <div class="notice-colright">
                     <table class="notice-datasheet">
-                        {% show_datasheet_row 'AUTR' row_class='notice-title' %}
-                        {% show_datasheet_row 'ECOL' row_class='notice-marginabove' %}
-                        {% show_datasheet_row 'DOMN' row_class='notice-marginabove' %}
-                    </table>
-                    <h3 class="notice-termgroup">{% trans 'Désignation' %}</h3>
-                    <table class="notice-datasheet">
-                        {% show_datasheet_row 'TITR' row_class='notice-title' %}
-                        {% show_datasheet_row 'APPL' row_class='notice-title' %}
-                        {% show_datasheet_row 'DENO' row_class='notice-title' %}
+                    {% if object.autr %}
+                        <tr class="datasheet-title">
+                            <th>{% trans 'Auteur(s)&nbsp;:' %}</th>
+                            <td>{% show_datasheet_row 'AUTR' %}</td>
+                        </tr>
+                    {% endif %}
+                    {% if object.ecol %}
+                        <tr>
+                            <th>{% trans 'École&nbsp;:' %}</th>
+                            <td>{% show_datasheet_row 'ECOL' %}</td>
+                        </tr>
+                    {% endif %}
+                    {% if object.domn %}
+                        <tr>
+                            <th>{% trans 'Domaine(s)&nbsp;:' %}</th>
+                            <td>{% show_datasheet_row 'DOMN' %}</td>
+                        </tr>
+                    {% endif %}
+                    {% if object.titr or object.deno or object.appl %}
+                        <tr class="datasheet-title">
+                            <th>{% trans 'Désignation&nbsp;:' %}</th>
+                            <td>{% show_datasheet_row 'TITR' %}{% show_datasheet_row 'APPL' %}{% show_datasheet_row 'DENO' %}</td>
+                        </tr>
+                    {% endif %}
                     {% if object.repr or object.srep %}
-                    </table>
-                    <h3 class="notice-termgroup">{% trans 'Sujet représenté' %}</h3>
-                    <table class="notice-datasheet">
-                        {% show_datasheet_row 'REPR' %}
-                        {% show_datasheet_row 'SREP' %}
+                        <tr>
+                            <th>{% trans 'Sujet représenté&nbsp;:' %}</th>
+                            <td>{% show_datasheet_row 'REPR' %}{% show_datasheet_row 'SREP' %}</td>
+                        </tr>
                     {% endif %}
                     {% if object.peri or object.mill or object.epoq %}
-                    </table>
-                    <h3 class="notice-termgroup">{% trans 'Datation' %}</h3>
-                    <table class="notice-datasheet">
-                        {% show_datasheet_row 'PERI' %}
-                        {% show_datasheet_row 'MILL' %}
-                        {% show_datasheet_row 'EPOQ' %}
+                        <tr>
+                            <th>{% trans 'Datation&nbsp;:' %}</th>
+                            <td>{% show_datasheet_row 'PERI' %}{% show_datasheet_row 'MILL' %}{% show_datasheet_row 'EPOQ' %}</td>
+                        </tr>
                     {% endif %}
-                        {% show_datasheet_row 'TECH' row_class='notice-marginabove' %}
-                        {% show_datasheet_row 'DIMS' row_class='notice-marginabove' %}
+                    {% if object.tech %}
+                        <tr>
+                            <th>{% trans 'Matériaux / Techniques&nbsp;:' %}</th>
+                            <td>{% show_datasheet_row 'TECH' %}</td>
+                        </tr>
+                    {% endif %}
+                    {% if object.tech %}
+                        <tr>
+                            <th>{% trans 'Mesures&nbsp;:' %}</th>
+                            <td>{% show_datasheet_row 'DIMS' %}</td>
+                        </tr>
+                    {% endif %}
                     {% if object.lieux or object.decv %}
-                    </table>
-                    <h3 class="notice-termgroup">{% trans 'Provenance' %}</h3>
-                    <table class="notice-datasheet">
-                        {% show_datasheet_row 'LIEUX' %}
-                        {% show_datasheet_row 'DECV' %}
+                        <tr>
+                            <th>{% trans 'Provenance&nbsp;:' %}</th>
+                            <td>{% show_datasheet_row 'LIEUX' %}{% show_datasheet_row 'DECV' %}</td>
+                        </tr>
+                    {% endif %}
+                    {% if object.hist %}
+                        <tr>
+                            <th>{% trans 'Historique&nbsp;:' %}</th>
+                            <td>{% show_datasheet_row 'HIST' %}</td>
+                        </tr>
                     {% endif %}
-                        {% show_datasheet_row 'HIST' row_class='notice-marginabove' %}
-                        {% show_datasheet_row 'LOCA' row_class='notice-marginabove' %}
-                        {% show_datasheet_row 'COPY' row_class='notice-small notice-marginabove' %}
-                        {% show_datasheet_row 'PHOT' row_class='notice-small' %}
+                    {% if object.loca %}
+                        <tr>
+                            <th>{% trans 'Lieu de conservation&nbsp;:' %}</th>
+                            <td>{% show_datasheet_row 'LOCA' %}</td>
+                        </tr>
+                    {% endif %}
+                    {% if object.copy %}
+                        <tr class="notice-small">
+                            <th>{% trans 'Copyright notice&nbsp;:' %}</th>
+                            <td>{% show_datasheet_row 'COPY' %}</td>
+                        </tr>
+                    {% endif %}
+                    {% if object.phot %}
+                        <tr class="notice-small">
+                            <th>{% trans 'Crédits photographiques&nbsp;:' %}</th>
+                            <td>{% show_datasheet_row 'PHOT' %}</td>
+                        </tr>
+                    {% endif %}
                     </table>
                     
                     <p class="notice-jocondelink">
--- a/src/jocondelab/templates/jocondelab/partial/datasheet_row.html	Wed Sep 25 17:34:18 2013 +0200
+++ b/src/jocondelab/templates/jocondelab/partial/datasheet_row.html	Thu Sep 26 13:54:06 2013 +0200
@@ -1,25 +1,17 @@
 {% load i18n %}
 
 {% if linked_terms %}
-<tr{% if row_class %} class="{{row_class}}"{% endif %}>
-    <th>{% trans fieldname context 'Thesaurus label' %}{% trans ':' %}</th>
-    <td>
-        <ul class="notice-term-list">
-        {% for term in linked_terms.translated %}
-            <li class="notice-term term-translated">
-                <a href="{% url 'front_search' %}?dbpedia_uri={{term.dbpedia_uri|urlencode}}" data-dbpedia-uri="{{term.dbpedia_uri}}">{{term.label}}</a>
-            </li>
-        {% endfor %}
-        {% for term in linked_terms.untranslated %}
-            <li class="notice-term term-untranslated" dir="ltr">{{term.label}}</li>
-        {% endfor %}
-        </ul>
-    </td>
-</tr>
+<ul class="datasheet-group notice-term-list">
+    {% for term in linked_terms.translated %}
+        <li class="notice-term term-translated">
+            <a href="{% url 'front_search' %}?dbpedia_uri={{term.dbpedia_uri|urlencode}}" data-dbpedia-uri="{{term.dbpedia_uri}}">{{term.label}}</a>
+        </li>
+    {% endfor %}
+    {% for term in linked_terms.untranslated %}
+        <li class="notice-term term-untranslated" dir="ltr">{{term.label}}</li>
+    {% endfor %}
+</ul>
 {% elif base_field %}
-<tr{% if row_class %} class="{{row_class}}"{% endif %}>
-    <th>{% trans fieldname context 'Thesaurus label' %}{% trans ':' %}</th>
-    <td dir="ltr">{{base_field}}</td>
-</tr>
+<span class="datasheet-group" dir="ltr">{{base_field}}</span>
 {% endif %}
 
--- a/src/jocondelab/templatetags/jlutils.py	Wed Sep 25 17:34:18 2013 +0200
+++ b/src/jocondelab/templatetags/jlutils.py	Thu Sep 26 13:54:06 2013 +0200
@@ -4,12 +4,11 @@
 register = template.Library()
 
 @register.inclusion_tag('jocondelab/partial/datasheet_row.html', takes_context=True)
-def show_datasheet_row(context, fieldname, **kwargs):
+def show_datasheet_row(context, fieldname):
     return {
             "fieldname": fieldname,
             "linked_terms": context['terms_by_thesaurus'].get(fieldname.upper(),None),
-            "base_field": getattr(context['object'],fieldname.lower()),
-            "row_class": kwargs.get("row_class", None)
+            "base_field": getattr(context['object'],fieldname.lower())
     }
 
 @register.filter