From 291bac0b1569b072f98e7622a64569330a1eb4e2 Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Thu, 24 Mar 2016 16:28:41 +0100 Subject: [PATCH 1/1] checkbox for cybernauts + checkbox fix in dialog.js --- src/editor/entrypoint.js | 3 ++- src/editor/modules/data/data.js | 6 ++++++ src/editor/views/dialog/dialog.js | 5 ++++- src/editor/views/dialog/templates/checkbox.html | 8 +++++--- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/editor/entrypoint.js b/src/editor/entrypoint.js index b723517..ccc3738 100644 --- a/src/editor/entrypoint.js +++ b/src/editor/entrypoint.js @@ -40,8 +40,9 @@ '../../libs/ace/ace': { exports: 'ace' }, - } + }, + urlArgs: "bust=" + (new Date()).getTime() }); requirejs([ diff --git a/src/editor/modules/data/data.js b/src/editor/modules/data/data.js index 0d556a2..6e8ec93 100644 --- a/src/editor/modules/data/data.js +++ b/src/editor/modules/data/data.js @@ -196,6 +196,12 @@ return function(sandbox) { 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); diff --git a/src/editor/views/dialog/dialog.js b/src/editor/views/dialog/dialog.js index 7d9f775..0e45dd7 100644 --- a/src/editor/views/dialog/dialog.js +++ b/src/editor/views/dialog/dialog.js @@ -70,7 +70,10 @@ define(function(require) { (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', { diff --git a/src/editor/views/dialog/templates/checkbox.html b/src/editor/views/dialog/templates/checkbox.html index a6ad457..8d80d8c 100644 --- a/src/editor/views/dialog/templates/checkbox.html +++ b/src/editor/views/dialog/templates/checkbox.html @@ -1,5 +1,7 @@ -
-
<%= label %>:
- +
+ <%= description %>
\ No newline at end of file -- 2.20.1