public static WebSharper.UI.Doc MainDoc(View <CalculatorViewModel> viewCalculator, Var <CalculatorViewModel> varCalculator) { // Page visibility without state machine var page = Var.Create(Single); // Setup the reactive ViewState storage and the test button. var viewState = Var.Create(""); var testSummary = new ListModel <string, string>(s => s); return(WebSharper.UI.Doc.ConcatMixed( input(viewState, attr.type("hidden")) , new Template.Index.Main() // Test button with result summary .Test(async(el, ev) => { var result = await RemoteTestRunner.Run("asptest.websharper.spa"); testSummary.Clear(); testSummary.AppendMany(result.Summary); if (!result.Passed) { JS.Window.Location.Assign(TestResultSite.ResultXmlPath); } }) .TestSummaryContainer( testSummary.View.DocSeqCached((string x) => new Template.Index.TestSummaryItem().Line(x).Doc() ) ) .ResultXmlPath(TestResultSite.ResultXmlPath) .Doc() , Page(page, viewCalculator, varCalculator) )); }
/// <summary> /// Main page as template. /// </summary> /// <returns></returns> public static WebSharper.UI.Doc IndexDoc() { var testSummary = new ListModel <string, string>(s => s); return(new Template.Index.Main() // Links to sub-pages .WithStatic((el, ev) => { WithStaticDoc().RunById("page"); }) .WithStorage((el, ev) => { WithStorageDoc().RunById("page"); }) // Test button with result summary .Test(async(el, ev) => { var result = await RemoteTestRunner.Run("minimaltest.websharper.spa"); testSummary.Clear(); testSummary.AppendMany(result.Summary); if (!result.Passed) { JS.Window.Location.Assign(TestResultSite.ResultXmlPath); } }) .TestSummaryContainer( testSummary.View.DocSeqCached((string x) => new Template.Index.TestSummaryItem().Line(x).Doc() ) ) .ResultXmlPath(TestResultSite.ResultXmlPath) .Doc()); }