Last active
August 29, 2015 14:21
-
-
Save gregwiechec/6fa6dd40c92d00ce3e77 to your computer and use it in GitHub Desktop.
EPiServer - Nullable 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", | |
"dojo/_base/lang", | |
"dojo/dom-style", | |
"dojo/dom-construct", | |
"dojo/keys", | |
"dojo/on", | |
"epi/shell/widget/DateTimeSelectorDropDown" | |
], | |
function( | |
declare, | |
lang, | |
domStyle, | |
domConstruct, | |
keys, | |
on, | |
DateTimeSelectorDropDown | |
) { | |
return declare("alloy.editors.nullableDateTimeSelectorDropDown", [DateTimeSelectorDropDown], { | |
clearLinkNode: null, | |
postMixInProperties: function() { | |
this.inherited(arguments); | |
this.clearNode = domConstruct.create("a", { innerHTML: "Clear value", title: "CTRL + DEL" }); | |
domStyle.set(this.clearNode, { | |
'float': 'right', | |
'margin': '-20px -90px 0 0', | |
'cursor': 'pointer' | |
}); | |
}, | |
postCreate: function() { | |
this.inherited(arguments); | |
on(this.clearNode, "click", lang.hitch(this, this._clearValue)); | |
on(this, "keypress", function (evt) { | |
if (evt.keyCode == keys.DELETE && evt.ctrlKey) { | |
this._clearValue(); | |
} | |
}); | |
dojo.place(this.clearNode, this.domNode); | |
}, | |
_clearValue: function() { | |
this.set("value", null); | |
}, | |
_setReadOnlyAttr: function(readOnly) { | |
this.inherited(arguments); | |
if (this.clearNode != null) { | |
domStyle.set(this.clearNode, "display", "none"); | |
} | |
domStyle.set(this.clearNode, "display", readOnly ? "none" : "block"); | |
} | |
}); | |
}); |
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
using System; | |
using EPiServer.Shell.ObjectEditing.EditorDescriptors; | |
namespace EpiServerThumbnail.Business.EditorDescriptors | |
{ | |
[EditorDescriptorRegistration(TargetType = typeof(DateTime?), UIHint = UIHint)] | |
public class NullableDateEditorDescriptor : DateTimeEditorDescriptor | |
{ | |
public const string UIHint = "nullable-date"; | |
public NullableDateEditorDescriptor() | |
{ | |
this.ClientEditingClass = "alloy.editors.nullableDateTimeSelectorDropDown"; | |
} | |
} | |
} |
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
[Display(Name="Nullable date", GroupName = SystemTabNames.Content, Order = 340)] | |
[UIHint(NullableDateEditorDescriptor.UIHint)] | |
public virtual DateTime? NullableDate { get; set; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment