Fix labels and input types
This commit is contained in:
parent
a780f97578
commit
779942ab62
|
@ -62,8 +62,10 @@ function msgSet (m) {
|
|||
for (let i = 0; i < parts.length - 1; i++) {
|
||||
o = o[parts[i]];
|
||||
}
|
||||
o[parts[parts.length - 1]] = m.v;
|
||||
if (debug) console.log ("Set", node, parts, m.v);
|
||||
const lastPart = parts[parts.length - 1];
|
||||
const value = lastPart === "htmlFor" ? m.v.id : m.v;
|
||||
o[lastPart] = value;
|
||||
if (debug) console.log ("Set", node, parts, value);
|
||||
}
|
||||
|
||||
function msgCall (m) {
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace Ooui
|
||||
{
|
||||
|
@ -77,37 +80,61 @@ namespace Ooui
|
|||
protected override bool TriggerEventFromMessage (Message message)
|
||||
{
|
||||
if (message.TargetId == Id && message.MessageType == MessageType.Event && message.Key == "change") {
|
||||
Value = message.Value != null ? Convert.ToString (message.Value) : "";
|
||||
return true;
|
||||
// Don't need to notify here because the base implementation will fire the event
|
||||
val = message.Value != null ? Convert.ToString (message.Value) : "";
|
||||
}
|
||||
return base.TriggerEventFromMessage (message);
|
||||
}
|
||||
}
|
||||
|
||||
[JsonConverter (typeof (StringEnumConverter))]
|
||||
public enum InputType
|
||||
{
|
||||
[EnumMember (Value = "text")]
|
||||
Text,
|
||||
[EnumMember (Value = "date")]
|
||||
Date,
|
||||
[EnumMember (Value = "week")]
|
||||
Week,
|
||||
[EnumMember (Value = "datetime")]
|
||||
Datetime,
|
||||
[EnumMember (Value = "datetimelocal")]
|
||||
DatetimeLocal,
|
||||
[EnumMember (Value = "time")]
|
||||
Time,
|
||||
[EnumMember (Value = "month")]
|
||||
Month,
|
||||
[EnumMember (Value = "range")]
|
||||
Range,
|
||||
[EnumMember (Value = "number")]
|
||||
Number,
|
||||
[EnumMember (Value = "hidden")]
|
||||
Hidden,
|
||||
[EnumMember (Value = "search")]
|
||||
Search,
|
||||
[EnumMember (Value = "email")]
|
||||
Email,
|
||||
[EnumMember (Value = "tel")]
|
||||
Tel,
|
||||
[EnumMember (Value = "url")]
|
||||
Url,
|
||||
[EnumMember (Value = "password")]
|
||||
Password,
|
||||
[EnumMember (Value = "color")]
|
||||
Color,
|
||||
[EnumMember (Value = "checkbox")]
|
||||
Checkbox,
|
||||
[EnumMember (Value = "radio")]
|
||||
Radio,
|
||||
[EnumMember (Value = "file")]
|
||||
File,
|
||||
[EnumMember (Value = "submit")]
|
||||
Submit,
|
||||
[EnumMember (Value = "reset")]
|
||||
Reset,
|
||||
[EnumMember (Value = "image")]
|
||||
Image,
|
||||
[EnumMember (Value = "button")]
|
||||
Button,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,8 @@ namespace Ooui
|
|||
protected override bool TriggerEventFromMessage (Message message)
|
||||
{
|
||||
if (message.TargetId == Id && message.MessageType == MessageType.Event && message.Key == "change") {
|
||||
Value = message.Value != null ? Convert.ToString (message.Value) : "";
|
||||
// Don't need to notify here because the base implementation will fire the event
|
||||
val = message.Value != null ? Convert.ToString (message.Value) : "";
|
||||
}
|
||||
return base.TriggerEventFromMessage (message);
|
||||
}
|
||||
|
|
|
@ -6,16 +6,33 @@ namespace Samples
|
|||
{
|
||||
public class TodoSample
|
||||
{
|
||||
List items = new List ();
|
||||
|
||||
Element MakeItem (string text)
|
||||
{
|
||||
var li = new ListItem ();
|
||||
var check = new Input {
|
||||
Type = InputType.Checkbox,
|
||||
};
|
||||
var label = new Label {
|
||||
Text = text,
|
||||
For = check
|
||||
};
|
||||
li.AppendChild (check);
|
||||
li.AppendChild (label);
|
||||
return li;
|
||||
}
|
||||
|
||||
Element MakeTodo ()
|
||||
{
|
||||
var items = new List ();
|
||||
{
|
||||
var input = new Input ();
|
||||
var button = new Button ("Add the item");
|
||||
button.Clicked += (s, e) => {
|
||||
items.AppendChild (new ListItem {
|
||||
Text = input.Value
|
||||
});
|
||||
if (string.IsNullOrWhiteSpace (input.Value))
|
||||
return;
|
||||
var item = MakeItem (input.Value);
|
||||
items.AppendChild (item);
|
||||
input.Value = "";
|
||||
};
|
||||
var app = new Div ();
|
||||
app.AppendChild (input);
|
||||
|
|
Loading…
Reference in New Issue