checkbox for cybernauts + checkbox fix in dialog.js
authorJan Szejko <jan.szejko@gmail.com>
Thu, 24 Mar 2016 15:28:41 +0000 (16:28 +0100)
committerJan Szejko <jan.szejko@gmail.com>
Tue, 29 Mar 2016 11:33:34 +0000 (13:33 +0200)
src/editor/entrypoint.js
src/editor/modules/data/data.js
src/editor/views/dialog/dialog.js
src/editor/views/dialog/templates/checkbox.html

index b723517..ccc3738 100644 (file)
@@ -40,8 +40,9 @@
             '../../libs/ace/ace': {
                 exports: 'ace'
             },
             '../../libs/ace/ace': {
                 exports: 'ace'
             },
-        }
+        },
 
 
+        urlArgs: "bust=" + (new Date()).getTime()
     });
     
     requirejs([
     });
     
     requirejs([
index 0d556a2..6e8ec93 100644 (file)
@@ -196,6 +196,12 @@ return function(sandbox) {
                     url: sandbox.getConfig().documentSaveUrl(data.document_id),
                     data: formData,
                     success: function(data) {
                     url: sandbox.getConfig().documentSaveUrl(data.document_id),
                     data: formData,
                     success: function(data) {
+                        // ugly!
+                        $.each(sandbox.getConfig().documentSaveForm.fields, function(i, field) {
+                            if (field.name.indexOf('for_cybernauts') !== -1) {
+                                field.checked = event.formData['textsave-for_cybernauts'] === 'on';
+                            }
+                        });
                         event.success();
                         sandbox.publish('savingEnded', 'success', 'remote', data);
 
                         event.success();
                         sandbox.publish('savingEnded', 'success', 'remote', data);
 
index 7d9f775..0e45dd7 100644 (file)
@@ -70,7 +70,10 @@ define(function(require) {
 
             (this.options.fields || []).forEach(function(field) {
                 var widget = view.$('[name=' + field.name +']');
 
             (this.options.fields || []).forEach(function(field) {
                 var widget = view.$('[name=' + field.name +']');
-                formData[field.name] = widget.val();
+                var widget_type = widget.attr('type');
+                if (!(widget_type == 'checkbox' || widget_type == 'radio') || widget.is(':checked')) {
+                    formData[field.name] = widget.val();
+                }
             });
 
             this.trigger('execute', {
             });
 
             this.trigger('execute', {
index a6ad457..8d80d8c 100644 (file)
@@ -1,5 +1,7 @@
-<div>
-    <div style="float: left; width:100px;"><%= label %>:</div>
-    <input type="checkbox" name="<%= name %>"/> 
+<div style="vertical-align: top">
+    <label style="display: inline-block;">
+        <span style="display: inline-block; width:100px;"><%= label %>:</span>
+        <input type="checkbox" name="<%= name %>" <% if (checked) print('checked="checked"'); %>/>
+    </label>
     <span class="description"><%= description %></span>
 </div>
\ No newline at end of file
     <span class="description"><%= description %></span>
 </div>
\ No newline at end of file