Skip to content

Commit

Permalink
Merge pull request #15 from doyle-johnpaul/DateStringControl
Browse files Browse the repository at this point in the history
Update custom_ROToolbox.js
  • Loading branch information
doyle-johnpaul authored Jul 29, 2021
2 parents 6c4660a + c60ee5a commit 6708857
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions custom_ROToolbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ function transformRO() {
createDateRange("@DateRange", $(this))
});
}
$("p:contains('@DateString')").closest(".row").each(function() {
customDateStringPicker("@DateString", $(this))
});
$("p:contains('@QueryList')").parent().parent().each(function() {
buildQueryList("@QueryList", $(this))
});
Expand Down Expand Up @@ -477,6 +480,41 @@ function buildQueryList(tag, tagElement) {
});
};

function customDateStringPicker(tag, tagElement) {
tagElement.hide();
var dateFormat = 'd';
var userDefined = parseOptions(tag, tagElement);
if (typeof userDefined.format != 'undefined') { dateFormat = userDefined.format;};
var textInputRow = tagElement.next();
var textInputType = textInputRow.find("input[value='String']");
if (textInputType.length == 0) {
tagElement.remove();
return;
}
var textInputId = textInputRow.find("input.question-answer-id").val();
textInputRow.find("textarea").hide();

textInputRow.find(".col-md-6").addClass("col-md-4").removeClass("col-md-6");

var newHtmlForDatePicker ="<input id='dateStringPicker_" + textInputId + "' style='width: 100%;' />";
textInputRow.find(".form-group").append(newHtmlForDatePicker);

var updateDateStringInput = function () {
var that = this;
var textInputId = that.dateView.options.id.split("_").pop();
var input = $('#textArea' + textInputId);
var hiddenInput = $('#' + textInputId);
input.val(kendo.toString(that.value(), that.dateView.options.format));
hiddenInput.val(kendo.toString(that.value(), that.dateView.options.format));
input.change();
};

$("#dateStringPicker_" + textInputId).kendoDatePicker({
change: updateDateStringInput,
format: dateFormat
});
};

function customDatePicker(tag, tagElement) {
tagElement.hide();
var dateElement = tagElement.next().find("input[value='DateTime']");
Expand Down

0 comments on commit 6708857

Please sign in to comment.