Commit 74b86697 authored by Carsten  Rose's avatar Carsten Rose

Merge remote-tracking branch 'origin/marcTagInputBugFix' into F9517TagInput

parents a7eb4bb8 dbee2e6a
......@@ -1358,6 +1358,7 @@ abstract class AbstractBuildForm {
$attribute .= Support::doAttribute(DATA_TYPEAHEAD_TAG, 'true');
$kk = '[' . ($formElement[FE_TYPEAHEAD_TAG_DELIMITER] ?? '9,44') . ']';
$attribute .= Support::doAttribute(DATA_TYPEAHEAD_TAG_DELIMITER, $kk);
$formElement[FE_INPUT_TYPE] = 'hidden';
// TAG handling expects the '$value' as a JSON string.
$kk = KeyValueStringParser::parse($value, ':', ',', KVP_IF_VALUE_EMPTY_COPY_KEY);
......
......@@ -18,6 +18,8 @@
"use strict";
var disableHiddenUpdate = false;
var defaults = {
prefilled: null,
CapitalizeFirstLetter: false,
......@@ -302,14 +304,16 @@
},
refreshHiddenTagList: function () {
var $self = $(this), tlis = $self.data("tlis"), lhiddenTagList = $self.data("lhiddenTagList");
if (!disableHiddenUpdate) {
var $self = $(this), tlis = $self.data("tlis"), lhiddenTagList = $self.data("lhiddenTagList");
if (lhiddenTagList) {
$(lhiddenTagList).val(tlis.join($self.data('opts').baseDelimiter)).change();
$self.trigger('tm:hiddenUpdate', [tlis, $(lhiddenTagList)]);
}
if (lhiddenTagList) {
$(lhiddenTagList).val(tlis.join($self.data('opts').baseDelimiter)).change();
$self.trigger('tm:hiddenUpdate', [tlis, $(lhiddenTagList)]);
}
$self.trigger('tm:refresh', tlis.join($self.data('opts').baseDelimiter));
$self.trigger('tm:refresh', tlis.join($self.data('opts').baseDelimiter));
}
},
killEvent: function (e) {
......@@ -542,6 +546,8 @@
return publicMethods[method].apply($self, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === 'object' || !method) {
return privateMethods.init.apply(this, arguments);
} else if (method === 'disableHiddenUpdate') {
disableHiddenUpdate = arguments[1];
} else {
$.error('Method ' + method + ' does not exist.');
return false;
......
......@@ -79,6 +79,16 @@ var QfqNS = QfqNS || {};
}
});
$element.off('keyup change');
$element.on('keypress keyup change', function (e) {
var code = e.keyCode || e.which;
if (code === 13) {
e.preventDefault();
return false;
}
});
// list to keep tracks of existing tags and those added during the current session
// expected JSON format: [{value: "Alaska", key: "AK"}, {value: "Alabama", key: "AL"}]
var existingTags = $element.val() !== '' ? JSON.parse($element.val()) : [];
......@@ -126,17 +136,21 @@ var QfqNS = QfqNS || {};
// if value of hidden field is changed externally, update tagManager
$element.on('qfqChange', function () {
existingTags = $element.val() !== '' ? JSON.parse($element.val()) : [];
tagApi.tagsManager('empty');
$.each(existingTags, function (i, tag) {
tagApi.tagsManager('disableHiddenUpdate', true);
existingTags = $element.val() !== '' ? JSON.parse($element.val()) : [];
tagApi.tagsManager('empty');
$.each(existingTags, function (i, tag) {
tagApi.tagsManager('pushTag', tag.value);
});
});
tagApi.tagsManager('disableHiddenUpdate', false);
});
// add existing tags
tagApi.tagsManager('disableHiddenUpdate', true);
$.each(existingTags, function (i, tag) {
tagApi.tagsManager('pushTag', tag.value);
});
tagApi.tagsManager('disableHiddenUpdate', false);
// add typahead
$inputField.typeahead({
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment