|
|
|
@ -1470,7 +1470,9 @@ define([
|
|
|
|
|
if (!Array.isArray(opts.values)) { return; }
|
|
|
|
|
var map = {};
|
|
|
|
|
var invMap = {};
|
|
|
|
|
var els = opts.values.map(function (data, i) {
|
|
|
|
|
var sorted = false;
|
|
|
|
|
Util.shuffleArray(opts.values);
|
|
|
|
|
var els = opts.values.map(function (data) {
|
|
|
|
|
var uid = Util.uid();
|
|
|
|
|
map[uid] = data;
|
|
|
|
|
invMap[data] = uid;
|
|
|
|
@ -1479,7 +1481,7 @@ define([
|
|
|
|
|
h('i.fa.fa-ellipsis-v'),
|
|
|
|
|
h('i.fa.fa-ellipsis-v'),
|
|
|
|
|
]),
|
|
|
|
|
h('span.cp-form-sort-order', (i+1)),
|
|
|
|
|
h('span.cp-form-sort-order', '?'),
|
|
|
|
|
h('span', data)
|
|
|
|
|
]);
|
|
|
|
|
$(div).data('val', data);
|
|
|
|
@ -1490,10 +1492,11 @@ define([
|
|
|
|
|
els
|
|
|
|
|
]);
|
|
|
|
|
var $tag = $(tag);
|
|
|
|
|
var reorder = function () {
|
|
|
|
|
var reorder = function (reset) {
|
|
|
|
|
$tag.find('.cp-form-type-sort').each(function (i, el) {
|
|
|
|
|
$(el).find('.cp-form-sort-order').text(i+1);
|
|
|
|
|
$(el).find('.cp-form-sort-order').text(reset ? '?' : i+1);
|
|
|
|
|
});
|
|
|
|
|
sorted = !reset;
|
|
|
|
|
};
|
|
|
|
|
var cursorGetter;
|
|
|
|
|
var setCursorGetter = function (f) { cursorGetter = f; };
|
|
|
|
@ -1516,16 +1519,18 @@ define([
|
|
|
|
|
return {
|
|
|
|
|
tag: tag,
|
|
|
|
|
getValue: function () {
|
|
|
|
|
if (!sorted) { return; }
|
|
|
|
|
return sortable.toArray().map(function (id) {
|
|
|
|
|
return map[id];
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
reset: function () {
|
|
|
|
|
Util.shuffleArray(opts.values);
|
|
|
|
|
var toSort = (opts.values).map(function (val) {
|
|
|
|
|
return invMap[val];
|
|
|
|
|
});
|
|
|
|
|
sortable.sort(toSort);
|
|
|
|
|
reorder();
|
|
|
|
|
reorder(true);
|
|
|
|
|
},
|
|
|
|
|
edit: function (cb, tmp) {
|
|
|
|
|
var v = Util.clone(opts);
|
|
|
|
@ -1885,12 +1890,13 @@ define([
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var send = h('button.cp-open.btn.btn-primary', update ? Messages.form_update : Messages.form_submit);
|
|
|
|
|
var reset = h('button.cp-open.btn.btn-danger-alt', Messages.form_reset);
|
|
|
|
|
var reset = h('button.cp-open.cp-reset-button.btn.btn-danger-alt', Messages.form_reset);
|
|
|
|
|
$(reset).click(function () {
|
|
|
|
|
if (!Array.isArray(APP.formBlocks)) { return; }
|
|
|
|
|
APP.formBlocks.forEach(function (data) {
|
|
|
|
|
if (typeof(data.reset) === "function") { data.reset(); }
|
|
|
|
|
});
|
|
|
|
|
$(reset).attr('disabled', 'disabled');
|
|
|
|
|
});
|
|
|
|
|
var $send = $(send).click(function () {
|
|
|
|
|
$send.attr('disabled', 'disabled');
|
|
|
|
@ -2004,6 +2010,7 @@ define([
|
|
|
|
|
delete _answers._userdata;
|
|
|
|
|
evOnChange.reg(function (noBeforeUnload, isSave) {
|
|
|
|
|
if (noBeforeUnload) { return; }
|
|
|
|
|
$container.find('.cp-reset-button').removeAttr('disabled');
|
|
|
|
|
var results = getFormResults();
|
|
|
|
|
if (isSave) {
|
|
|
|
|
answers = Util.clone(results || {});
|
|
|
|
@ -2356,6 +2363,9 @@ define([
|
|
|
|
|
|
|
|
|
|
// In view mode, add "Submit" and "reset" buttons
|
|
|
|
|
$container.append(makeFormControls(framework, content, Boolean(answers), evOnChange));
|
|
|
|
|
if (!answers) {
|
|
|
|
|
$container.find('.cp-reset-button').attr('disabled', 'disabled');
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var getTempFields = function () {
|
|
|
|
|