Merge
This commit is contained in:
@@ -9,11 +9,15 @@ namespace umbraco.editorControls.numberfield
|
||||
{
|
||||
public DataInteger(cms.businesslogic.datatype.BaseDataType DataType) : base(DataType) {}
|
||||
|
||||
public override void MakeNew(int PropertyId) {
|
||||
public override void MakeNew(int PropertyId)
|
||||
{
|
||||
this.PropertyId = PropertyId;
|
||||
string defaultValue = ((DefaultPrevalueEditor) _dataType.PrevalueEditor).Prevalue;
|
||||
|
||||
if (defaultValue.Trim() != "")
|
||||
this.Value = defaultValue;
|
||||
{
|
||||
this.Value = defaultValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,30 +13,42 @@ namespace umbraco.editorControls.numberfield
|
||||
|
||||
public override string DataTypeName
|
||||
{
|
||||
get {return "Integer";}
|
||||
get
|
||||
{
|
||||
return "Integer";
|
||||
}
|
||||
}
|
||||
|
||||
public override Guid Id
|
||||
{
|
||||
get {return new Guid("1413afcb-d19a-4173-8e9a-68288d2a73b8");}
|
||||
get
|
||||
{
|
||||
return new Guid("1413afcb-d19a-4173-8e9a-68288d2a73b8");
|
||||
}
|
||||
}
|
||||
|
||||
public override interfaces.IDataPrevalue PrevalueEditor
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_prevalueeditor == null)
|
||||
_prevalueeditor = new DefaultPrevalueEditor(this,true);
|
||||
return _prevalueeditor;
|
||||
}
|
||||
}
|
||||
public override interfaces.IDataPrevalue PrevalueEditor
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_prevalueeditor == null)
|
||||
{
|
||||
_prevalueeditor = new DefaultPrevalueEditor(this, false);
|
||||
}
|
||||
|
||||
return _prevalueeditor;
|
||||
}
|
||||
}
|
||||
|
||||
public override interfaces.IDataEditor DataEditor
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_Editor == null)
|
||||
_Editor = new numberField(Data);
|
||||
if (_Editor == null)
|
||||
{
|
||||
_Editor = new numberField(Data);
|
||||
}
|
||||
|
||||
return _Editor;
|
||||
}
|
||||
}
|
||||
@@ -45,11 +57,13 @@ namespace umbraco.editorControls.numberfield
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_baseData == null)
|
||||
_baseData = new DataInteger(this);
|
||||
if (_baseData == null)
|
||||
{
|
||||
_baseData = new DataInteger(this);
|
||||
}
|
||||
|
||||
return _baseData;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,62 +1,85 @@
|
||||
using System;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace umbraco.editorControls
|
||||
{
|
||||
public class numberField : System.Web.UI.WebControls.TextBox, interfaces.IDataEditor
|
||||
public class numberField : TextBox, interfaces.IDataEditor
|
||||
{
|
||||
private interfaces.IData _data;
|
||||
public numberField(interfaces.IData Data) {
|
||||
|
||||
public numberField(interfaces.IData Data)
|
||||
{
|
||||
_data = Data;
|
||||
}
|
||||
|
||||
|
||||
public Control Editor {
|
||||
get{return this;}
|
||||
|
||||
public Control Editor
|
||||
{
|
||||
get
|
||||
{
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool TreatAsRichTextEditor
|
||||
{
|
||||
get {return false;}
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShowLabel
|
||||
{
|
||||
get {return true;}
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
if (Text.Trim() != "")
|
||||
_data.Value = Text;
|
||||
{
|
||||
_data.Value = Text;
|
||||
}
|
||||
else
|
||||
{
|
||||
_data.Value = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnInit(EventArgs e)
|
||||
{
|
||||
base.OnInit (e);
|
||||
CssClass = "umbEditorNumberField";
|
||||
|
||||
this.CssClass = "umbEditorNumberField";
|
||||
|
||||
// load data
|
||||
if (_data != null && _data.Value != null)
|
||||
this.Text = _data.Value.ToString();
|
||||
}
|
||||
|
||||
public override string Text
|
||||
{
|
||||
get { return base.Text; }
|
||||
set {
|
||||
try {
|
||||
if (value != null)
|
||||
base.Text = Convert.ToInt32(value).ToString();
|
||||
}
|
||||
catch {
|
||||
base.Text = "";
|
||||
System.Web.HttpContext.Current.Trace.Warn("Numberfield", "Value has to be an integer (" + value + ")");
|
||||
}
|
||||
}
|
||||
if (_data != null && _data.Value != null)
|
||||
{
|
||||
this.Text = _data.Value.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The setter ensures that only valid integers are saved - this is to prevent invalid types from being saved into an int db field
|
||||
/// </summary>
|
||||
public override string Text
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
int integer;
|
||||
|
||||
if (int.TryParse(value, out integer))
|
||||
{
|
||||
base.Text = integer.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user