Created
December 7, 2023 13:44
-
-
Save gregwiechec/3000f33992979e14364ff1201a846b9a to your computer and use it in GitHub Desktop.
Date property
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define([ | |
"dojo/_base/declare", | |
"epi/shell/widget/DateTimeSelector", | |
"epi/shell/widget/DateTimeSelectorDropDown" | |
], function( | |
declare, | |
DateTimeSelector, | |
DateTimeSelectorDropDown | |
) { | |
function dateToString(date) { | |
if (!date){ | |
return date; | |
} | |
// remove offset | |
const offset = date.getTimezoneOffset(); | |
date = new Date(date.getTime() - (offset*60*1000)); | |
return date.toISOString().split("T")[0]; | |
} | |
var SimpleDateTimeSelector = declare([DateTimeSelector], { | |
buildRendering: function() { | |
this.inherited(arguments); | |
this.domNode.querySelector(".epi-timePickerWrapper").classList.add("dijitHidden"); | |
}, | |
_getValueAttr: function() { | |
var selectedDate = this.calendar.get("value"); | |
if (!selectedDate) { | |
return null; | |
} | |
return dateToString(new Date(selectedDate.getFullYear(), selectedDate.getMonth(), selectedDate.getDate(), 0, 0, 0, 0)); | |
} | |
}); | |
return declare([DateTimeSelectorDropDown], { | |
popupClass: SimpleDateTimeSelector, | |
postMixInProperties: function () { | |
this.inherited(arguments); | |
this.constraints.datePattern = "yyyy-MM-dd"; | |
this.constraints.selector = "date"; | |
}, | |
_getValueAttr: function () { | |
this.constraints.selector = "date"; | |
var result = this.inherited(arguments); | |
return dateToString(result); | |
} | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class StandardPage : SitePageData | |
{ | |
// ... | |
[ClientEditor(ClientEditingClass = "alloy/Editors/DateEditor")] | |
public virtual DateTime CustomDate { get; set; } | |
[ClientEditor(ClientEditingClass = "alloy/Editors/DateEditor")] | |
public virtual DateTime? CustomNullableDate { get; set; } | |
[ClientEditor(ClientEditingClass = "alloy/Editors/DateEditor")] | |
public virtual string CustomDateStr { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment