Forms code improvements

pull/1/head
yflory 3 years ago
parent 2df0f6df9b
commit 5d04cd0f4f

@ -2147,11 +2147,12 @@ define([
$container.hide(); $container.hide();
if (viewOnly) { if (viewOnly) {
$formContainer.find('.cp-form-send-container .cp-open').hide(); $formContainer.find('.cp-form-send-container .cp-open').hide();
Object.keys(APP.blocks).forEach(function (uid) { if (Array.isArray(APP.formBlocks)) {
var b = APP.blocks[uid]; APP.formBlocks.forEach(function (b) {
if (!b.setEditable) { return; } if (!b.setEditable) { return; }
b.setEditable(false); b.setEditable(false);
}); });
}
} }
}); });
@ -2453,7 +2454,7 @@ define([
name = user.name; name = user.name;
} }
var data = APP.blocks[uid] = model.get(block.opts, _answers, name, evOnChange); var data = model.get(block.opts, _answers, name, evOnChange);
if (!data) { return; } if (!data) { return; }
data.uid = uid; data.uid = uid;
if (answers && answers[uid] && data.setValue) { data.setValue(answers[uid]); } if (answers && answers[uid] && data.setValue) { data.setValue(answers[uid]); }
@ -2577,7 +2578,7 @@ define([
$(editButtons).show(); $(editButtons).show();
UI.log(Messages.saved); UI.log(Messages.saved);
_answers = getBlockAnswers(APP.answers, uid); _answers = getBlockAnswers(APP.answers, uid);
data = APP.blocks[uid] = model.get(newOpts, _answers, null, evOnChange); data = model.get(newOpts, _answers, null, evOnChange);
if (!data) { data = {}; } if (!data) { data = {}; }
$oldTag.before(data.tag).remove(); $oldTag.before(data.tag).remove();
}); });
@ -2640,7 +2641,7 @@ define([
framework.localChange(); framework.localChange();
var $oldTag = $(data.tag); var $oldTag = $(data.tag);
framework._.cpNfInner.chainpad.onSettle(function () { framework._.cpNfInner.chainpad.onSettle(function () {
data = APP.blocks[uid] = model.get(block.opts, _answers, null, evOnChange); data = model.get(block.opts, _answers, null, evOnChange);
$oldTag.before(data.tag).remove(); $oldTag.before(data.tag).remove();
}); });
}); });

Loading…
Cancel
Save