From fcf6141cdead9752219283597e84cc90825edd4a Mon Sep 17 00:00:00 2001 From: azivner Date: Mon, 6 Aug 2018 17:24:35 +0200 Subject: [PATCH] support for promoted multi value attributes --- .../javascripts/services/note_detail.js | 149 +++++++++++------- src/public/stylesheets/style.css | 6 +- src/routes/api/attributes.js | 16 ++ src/routes/routes.js | 1 + 4 files changed, 118 insertions(+), 54 deletions(-) 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 = $("