diff --git a/src/public/javascripts/services/note_detail.js b/src/public/javascripts/services/note_detail.js index a869b3f10..2d3dd6ce8 100644 --- a/src/public/javascripts/services/note_detail.js +++ b/src/public/javascripts/services/note_detail.js @@ -236,13 +236,99 @@ async function loadAttributes() { let idx = 1; + async function createRow(definitionAttr, valueAttr) { + const definition = definitionAttr.value; + const inputId = "promoted-input-" + (idx++); + const $tr = $(""); + const $labelCell = $("").append(valueAttr.name); + const $input = $("") + .prop("id", inputId) + .prop("attribute-id", valueAttr.attributeId) + .prop("attribute-type", valueAttr.type) + .prop("attribute-name", valueAttr.name) + .prop("value", valueAttr.value) + .addClass("form-control") + .addClass("promoted-attribute-input"); + + const $inputCell = $("").append($input); + + const $actionCell = $(""); + const $multiplicityCell = $(""); + + $tr + .append($labelCell) + .append($inputCell) + .append($actionCell) + .append($multiplicityCell); + + if (valueAttr.type === 'label') { + if (definition.labelType === 'text') { + $input.prop("type", "text"); + } + else if (definition.labelType === 'number') { + $input.prop("type", "number"); + } + else if (definition.labelType === 'boolean') { + $input.prop("type", "checkbox"); + + if (valueAttr.value === "true") { + $input.prop("checked", "checked"); + } + } + else if (definition.labelType === 'date') { + $input.prop("type", "text"); + + $input.datepicker({ + changeMonth: true, + changeYear: true, + dateFormat: "yy-mm-dd" + }); + + const $todayButton = $("