mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	implemented date promoted attribute
This commit is contained in:
		| @@ -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 = [ | ||||
|   | ||||
| @@ -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"); | ||||
|                     } | ||||
|                     else if (definitionAttr.labelType === 'datetime') { | ||||
|                         $input.prop("type", "text"); | ||||
|                         $input.addClass("datetime"); | ||||
|                     } | ||||
|                 } | ||||
|  | ||||
|                 $tr.append($labelCell).append($inputCell); | ||||
|                         $input.datepicker({ | ||||
|                             changeMonth: true, | ||||
|                             changeYear: true, | ||||
|                             dateFormat: "yy-mm-dd" | ||||
|                         }); | ||||
|  | ||||
|                 $promotedAttributesContainer.append($tr); | ||||
|                         const $todayButton = $("<button>").text("Today").click(() => { | ||||
|                             $input.val(utils.formatDateISO(new Date())); | ||||
|                             $input.trigger("change"); | ||||
|                         }); | ||||
|  | ||||
|                         $tr.append($("<tr>").append($todayButton)); | ||||
|                     } | ||||
|                     else { | ||||
|                         messagingService.logError("Unknown labelType=" + definitionAttr.labelType); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user