Skip to content

Commit 413d68e

Browse files
committed
Add ComboBoxExamples
1 parent 89672fa commit 413d68e

4 files changed

Lines changed: 60 additions & 4 deletions

File tree

Gallery.Server/Configure.AppHost.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,27 @@ public override void Configure(Container container)
5252
EnableRequestBodyTracking = true,
5353
});
5454
Plugins.AddIfDebug(new ProfilingFeature());
55-
ScriptContext.Args["AppData"] = AppData.Instance;
55+
56+
57+
ScriptContext.Args[nameof(AppData)] = new AppData
58+
{
59+
Currencies = NumberCurrency.All,
60+
AlphaValues = new() {
61+
"Alpha", "Bravo", "Charlie"
62+
},
63+
AlphaDictionary = new()
64+
{
65+
["A"] = "Alpha",
66+
["B"] = "Bravo",
67+
["C"] = "Charlie",
68+
},
69+
AlphaKeyValuePairs = new()
70+
{
71+
new("A","Alpha"),
72+
new("B","Bravo"),
73+
new("C","Charlie"),
74+
},
75+
};
5676
}
5777

5878
public void Configure(IWebHostBuilder builder) => builder
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using ServiceStack;
2+
using MyApp.ServiceModel;
3+
4+
namespace MyApp.ServiceInterface;
5+
6+
public class FormServices : Service
7+
{
8+
public object Any(ComboBoxExamples request) => request;
9+
}

Gallery.Server/ServiceModel/AppData.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ namespace MyApp.ServiceModel;
33

44
public class AppData
55
{
6-
public static AppData Instance { get; } = new();
7-
8-
public string[] Currencies => NumberCurrency.All;
6+
public string[] Currencies { get; set; }
7+
public List<string> AlphaValues { get; set; }
8+
public Dictionary<string, string> AlphaDictionary { get; set; }
9+
public List<KeyValuePair<string, string>> AlphaKeyValuePairs { get; set; }
910
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using ServiceStack;
2+
using System.Collections.Generic;
3+
4+
namespace MyApp.ServiceModel;
5+
6+
[Tag("Forms")]
7+
public class ComboBoxExamples : IReturn<ComboBoxExamples>, IPost
8+
{
9+
[Input(Type = "combobox", Options = "{ allowableValues:['Alpha','Bravo','Charlie'] }")]
10+
public string? SingleClientValues { get; set; }
11+
12+
[Input(Type = "combobox", Options = "{ allowableValues:['Alpha','Bravo','Charlie'] }", Multiple = true)]
13+
public List<string>? MultipleClientValues { get; set; }
14+
15+
[Input(Type = "combobox", EvalAllowableValues = "['Alpha','Bravo','Charlie']")]
16+
public string? SingleServerValues { get; set; }
17+
18+
[Input(Type = "combobox", EvalAllowableValues = "AppData.AlphaValues", Multiple = true)]
19+
public List<string>? MultipleServerValues { get; set; }
20+
21+
[Input(Type = "combobox", EvalAllowableEntries = "{ A:'Alpha', B:'Bravo', C:'Charlie' }")]
22+
public string? SingleServerEntries { get; set; }
23+
24+
[Input(Type = "combobox", EvalAllowableEntries = "AppData.AlphaDictionary", Multiple = true)]
25+
public List<string>? MultipleServerEntries { get; set; }
26+
}

0 commit comments

Comments
 (0)