Browse Source

new Demo Form

prieto 7 years ago
parent
commit
643c7e2a27

+ 2
- 2
lodel/leapi/leobject.py View File

@@ -311,8 +311,8 @@ class LeObject(object):
311 311
                 "The field %s is not initialized yet (and have no value)" % field_name)
312 312
         return self.__datas[field_name]
313 313
 
314
-    # @brief Read only access to all datas
315
-    #@return a dict representing datas of current instance
314
+    # @brief Read only access to all data
315
+    #@return a dict representing data of current instance
316 316
     def datas(self, internal=False):
317 317
         return {fname: self.data(fname) for fname in self.fieldnames(internal)}
318 318
 

+ 6
- 2
lodel/plugins/webui/interface/controllers/admin.py View File

@@ -1,6 +1,7 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 from ...exceptions import *
3 3
 from .base import get_response
4
+from .utils import *
4 5
 
5 6
 from lodel.context import LodelContext
6 7
 LodelContext.expose_modules(globals(), {
@@ -37,7 +38,6 @@ def admin_update(request):
37 38
     # temporary, the acl will be more restrictive
38 39
     #if WebUiClient.is_anonymous():
39 40
     #    return get_response('users/signin.html')
40
-    msg=''
41 41
 
42 42
     datas = process_form(request)
43 43
     if not(datas is False):
@@ -113,6 +113,10 @@ def admin_create(request):
113 113
         if 'lodel_id' in datas:
114 114
             raise HttpException(400)
115 115
         try:
116
+            for fld in datas:
117
+                if fld.endswith('[]'):
118
+                    datas[fld[:-2]] = ','.join(datas[fld])
119
+                    del datas[fld]
116 120
             new_uid = target_leo.insert(
117 121
                 { f:datas[f] for f in datas if f != 'classname'})
118 122
         except LeApiDataCheckErrors as e:
@@ -139,7 +143,7 @@ def admin_create(request):
139 143
 
140 144
     if classname is None or target_leo.is_abstract():
141 145
         raise HttpException(400)
142
-    return get_response('admin/admin_create.html', target=target_leo)
146
+    return get_response('admin/admin_create.html', target=target_leo, get_dataobjects=get_dataobjects)
143 147
 
144 148
 ##@brief Controller's function to delete an object of the editorial model
145 149
 # @param request : the request (get)

+ 1
- 1
lodel/plugins/webui/templates/admin/admin_create.html View File

@@ -16,7 +16,7 @@
16 16
      <input type="hidden" name="classname" id="classname" value="{{target.__name__}}" />
17 17
 	{% for fieldname, field in target.fields().items() %}
18 18
      <div class="form-group">
19
-     <div class="form-group" style="padding-bottom:15px;"> {{edit.input(fieldname, field) }}</div>
19
+     <div class="form-group" style="padding-bottom:15px;"> {{ edit.input(fieldname, field, ' ', get_dataobjects) }}</div>
20 20
      </div>
21 21
 	{% endfor %}
22 22
      <p>&nbsp;</p>

+ 4
- 4
lodel/plugins/webui/templates/admin/editable_component.html View File

@@ -1,4 +1,4 @@
1
-{% macro input(fieldname, field, value='') -%}
1
+{% macro input(fieldname, field, value='', function='') -%}
2 2
 	<label for="field_input_{{fieldname}}" class="col-sm-2 control-label">{{fieldname}}</label>
3 3
     <div class="col-xs-6">
4 4
 	{% if value == None %}
@@ -26,7 +26,8 @@
26 26
         	</script>
27 27
     {% elif field.base_type == 'ref' %}
28 28
         {% set l_classes = field.allowed_classes %}
29
-    	{% set ref_objects = dict() %}
29
+        {% set ref_objects = l_class.get(None) %}
30
+		{% set l_objs = function(ref_objects) %}
30 31
     	{% for l_class in l_classes %}
31 32
     		{% set _dummy = ref_objects.update(l_class.get(None)) %} 
32 33
     		{% if 'fullname' in l_class.fieldnames() %}
@@ -40,13 +41,12 @@
40 41
     		{% endif %}
41 42
     		{% set uidfield = l_class.uid_fieldname() %}
42 43
     	{% endfor %}
43
-    	<meta id="ref_objects" data-name="{{ ref_objects }}" >
44 44
     	{% if (field.__class__ == List) %}
45 45
     		<input id="{{fieldname}}" class="form-control" name="field_input_{{fieldname}}[]" type="text" value="{{sval}}" >
46 46
     		<script type="text/javascript">
47 47
     		$(function() {
48 48
 		    $('#{{fieldname}}').magicSuggest({
49
-		        data: $('#ref_objects').data(),
49
+		    	data: {{ l_objs }},
50 50
 		        valueField: {{ uidfield }},
51 51
 		        displayField: {{ displayfield }}
52 52
 		    });

Loading…
Cancel
Save