implemented date promoted attribute

This commit is contained in:
azivner 2018-08-06 15:58:59 +02:00
parent 12031d369f
commit 21551d7b77
2 changed files with 22 additions and 12 deletions

View file

@ -26,8 +26,7 @@ function AttributesModel() {
{ text: "Text", value: "text" },
{ text: "Number", value: "number" },
{ text: "Boolean", value: "boolean" },
{ text: "Date", value: "date" },
{ text: "DateTime", value: "datetime" }
{ text: "Date", value: "date" }
];
this.multiplicityTypes = [

View file

@ -254,7 +254,7 @@ async function loadAttributes() {
}
for (const valueAttr of valueAttrs) {
const inputId = "promoted-input-" + idx;
const inputId = "promoted-input-" + (idx++);
const $tr = $("<tr>");
const $labelCell = $("<th>").append(valueAttr.name);
const $input = $("<input>")
@ -268,6 +268,10 @@ async function loadAttributes() {
const $inputCell = $("<td>").append($input);
$tr.append($labelCell).append($inputCell);
$promotedAttributesContainer.append($tr);
if (valueAttr.type === 'label') {
if (definition.labelType === 'text') {
$input.prop("type", "text");
@ -282,19 +286,26 @@ async function loadAttributes() {
$input.prop("checked", "checked");
}
}
else if (definitionAttr.labelType === 'date') {
else if (definition.labelType === 'date') {
$input.prop("type", "text");
$input.addClass("date");
$input.datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "yy-mm-dd"
});
const $todayButton = $("<button>").text("Today").click(() => {
$input.val(utils.formatDateISO(new Date()));
$input.trigger("change");
});
$tr.append($("<tr>").append($todayButton));
}
else if (definitionAttr.labelType === 'datetime') {
$input.prop("type", "text");
$input.addClass("datetime");
else {
messagingService.logError("Unknown labelType=" + definitionAttr.labelType);
}
}
$tr.append($labelCell).append($inputCell);
$promotedAttributesContainer.append($tr);
}
}
}