src/catedit/templates/cateditor.html
changeset 3 73b18cb88583
parent 2 f7bc7942969a
child 5 259707477c10
--- a/src/catedit/templates/cateditor.html	Mon Nov 24 11:05:08 2014 +0100
+++ b/src/catedit/templates/cateditor.html	Tue Nov 25 16:24:37 2014 +0100
@@ -42,14 +42,14 @@
     <div class="alert alert-warning" role="alert">
       <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
       <span class="sr-only">Attention:</span>
-      Vous n'avez pas accès en écriture au repository contenant les catégories - Vous ne pourrez pas les modifier
+      Vous n'avez pas accès en écriture au repository contenant les catégories - Vous ne pourrez pas les modifier.
     </div>
     {% endif %}
     {% if not session["user_logged"] %}
     <div class="alert alert-warning" role="alert">
       <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
       <span class="sr-only">Attention:</span>
-      Vous devez être authentifié pour modifier les catégories
+      Vous devez être authentifié pour modifier les catégories.
     </div> {% endif %}
     {% if form.label.errors or form.description.errors or form.commit_message.errors %}
     <div class="alert alert-danger">
@@ -57,7 +57,7 @@
         <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
         Erreur:
       </strong>
-      vous n'avez pas rempli certains champs obligatoires
+      Vous n'avez pas rempli certains champs obligatoires.
     </div>
     {% endif %}
     <h2>{% if cat_id: %} Edition : <small>Catégorie existante</small>{% else %}Création : <small>Nouvelle catégorie</small>{% endif %}</h2>
@@ -77,37 +77,74 @@
         {{ form.description.label }} <br> {{ form.description(size=150, class="form-control", readonly=readonly, placeholder=description_placeholder) }} <br>
         <label>Propriétés </label>
         <div class="form-inline">
-          <input type="button" value="Ajouter propriété" onClick="CatEditScripts.addProperty('properties');" class="btn btn-default" {{ readonly }}>
-          <select id="property_type_selector" class="form-control">
-            <option value="subClassOf" label="literal">Sous-classe de</option>
-            <option value="value" label="literal">Valeur</option>
-            <option value="type" label="literal">Type</option>
+          <input type="button" value="Ajouter propriété" onClick="CatEditScripts.addProperty('properties','property_table_body');" class="btn btn-default" {{ readonly }}>
+          <select id="property_selector" class="form-control" onChange="CatEditScripts.displayCorrespondingField();" {{readonly}}>
+            <option label="property_type_default" selected>
+              Liste des propriétés ...
+            </option>
+            {% for predicate in config["PROPERTY_LIST"] %}
+            <option value='{{ predicate }}' label={{ config["PROPERTY_LIST"][predicate]["object_type"] }} >{{ config["PROPERTY_LIST"][predicate]["descriptive_label_fr"] }}</option>
+            {% endfor %}
+          </select>
+          <input type="text" id="literal-field" class="hidden form-control">
+          <input type="text" id="uriref-link-field" placeholder="http://my-example.com" class="hidden form-control">
+          <select id="uriref-category-field" class="hidden form-control">
+            <option value="default" selected> Liste des catégories </option>
+            {% for cat in cat_list %}
+            <option value="{{ cat.cat_id }}"> {{ cat.cat_label }} </option>
+            {% endfor %}
           </select>
         </div>
-        <div id="properties" class="hidden">
-          {% set property_count=1 %}
-          {% for (predicate, object) in cat_properties %}
-            <div id="property_div{{ property_count }}" class="row property-row">
-              <div class="form-inline">
-                <label class="col-md-2">
-                  {% if predicate == "subClassOf" %} Sous-classe de
-                  {% elif predicate == "value" %} Valeur
-                  {% elif predicate == "type" %} Type
-                  {% endif %}
-                </label>
-                <input type="hidden" id="property_predicate{{ property_count }}" name="property_predicate" value={{ predicate }}>
-                <input type="text" id="property_object{{ property_count }}" name="property_object" class="form-control col-md-8" value={{ object }}>
-                <input type="button" id="property_delete_button{{ property_count }}" class="btn btn-default property-delete-button" onClick="CatEditScripts.removeProperty({{ property_count }})" value="Supprimer">
-              </div>
+        <div id="properties" class="row hidden">
+          <div class="row">
+            <div class="col-md-6">
+              <br>
+              <table id="property_table" class="table table-condensed">
+                <tbody id="property_table_body">
+                {% set property_count=1 %}
+                {% for (predicate, object) in cat_properties %}
+                    <tr id="property_tr{{property_count}}">
+                      {% if config["PROPERTY_LIST"][predicate]["object_type"]=="uriref-category" %}
+                        {% for cat in cat_list %}
+                          {% if object == config["ONTOLOGY_NAMESPACE"]+cat.cat_id %}
+                            <input type="hidden" id="property_predicate{{ property_count }}" name="property_predicate" value="{{predicate}}"/>
+                            <input type="hidden" id="property_object{{ property_count }}" name="property_object" value="{{cat.cat_id}}"/>
+                            <td id="predicate_td{{ property_count }}">
+                              <strong>{{ config["PROPERTY_LIST"][predicate]["descriptive_label_fr"] }}</strong>
+                            </td>
+                            <td id="object_td{{ property_count }}">
+                              {{ cat.cat_label }}
+                            </td>
+                            <td id="delete_button_td{{ property_count }}">
+                              <input type="button" id="property_delete_button{{ property_count }}" class="btn btn-default property-delete-button" onClick="CatEditScripts.removeProperty({{ property_count }}, 'properties')" value="Supprimer">
+                            </td>
+                          {% endif %}
+                        {% endfor %}
+                      {% else %}
+                        <input type="hidden" id="property_predicate{{ property_count }}" name="property_predicate" value="{{predicate}}"/>
+                        <input type="hidden" id="property_object{{ property_count }}" name="property_object" value="{{object}}"/>
+                        <td id="predicate_td{{ property_count }}">
+                          <strong>{{ config["PROPERTY_LIST"][predicate]["descriptive_label_fr"] }}</strong>
+                        </td>
+                        <td id="object_td{{ property_count }}">
+                          {{ object }}
+                        </td>
+                        <td id="delete_button_td{{ property_count }}">
+                          <input type="button" id="property_delete_button{{ property_count }}" class="btn btn-default property-delete-button" onClick="CatEditScripts.removeProperty({{ property_count }}, 'properties')" value="Supprimer">
+                        </td>
+                      {% endif %}
+                    {% set property_count=property_count+1 %}
+                    </tr>
+                {% endfor %}
+                </tbody>
+              </table>
             </div>
-            {% set property_count=property_count+1 %}
-          {% endfor %}
+          </div>
         </div><br>
         {{ form.commit_message.label }} <br> {{ form.commit_message(size=150, class="form-control", readonly=readonly, placeholder=description_placeholder) }} <br>
         <br><input type="submit" value="Sauvegarder" class="btn btn-default">
     </form>
     {% if readonly %} </fieldset> {% endif %}
-  </div>
   <script src="{{ url_for('static', filename='js/property_functions.js') }}" language="Javascript" type="text/javascript"></script>
   {% if cat_id %}
     <script type=text/javascript>