Skip to content

Commit 4121cb6

Browse files
committed
various js .Dyn samples
1 parent 27aac41 commit 4121cb6

File tree

6 files changed

+45
-25
lines changed

6 files changed

+45
-25
lines changed

js/data/Snip-Rest-Get.Dyn.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Tut.Tabs=file:.././200-get-data.js
1919

2020
@* This tutorial uses turnOn, see turnOn tutorials *@
2121
@Kit.Page.TurnOn("window.sxcDataTutorial200.init()", data: new {
22-
moduleId = MyContext.Module.Id
22+
moduleId = CmsContext.Module.Id
2323
})
2424

2525
<script src="@App.Path/js/200-get-data.js" @Kit.Page.AssetAttributes()></script>
Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
@inherits Custom.Hybrid.Razor14
22
@using ToSic.Razor.Blade;
3-
@*!
4-
Tut.Tabs=file:.././230-query-parameters.js
5-
!*@
3+
@{/*! Tut.Tabs=file:.././230-query-parameters.js,ViewConfig */
4+
var viewCnf = DynamicModel.Tutorial.ViewConfig;
5+
var Data = viewCnf.Query(query: "AuthorsWithBooks") as ToSic.Eav.DataSource.IDataSource;
6+
/*!*/}
67
@* Make sure anonymous users have the 2sxc JS API *@
78
@Kit.Page.Activate("2sxc.JsCore")
9+
@{ var btnPrefix = "mod-" + CmsContext.Module.Id; }
810

9-
<button id="[email protected]" type="button" class="btn btn-primary">Get Query with parameters (object)</button>
10-
<button id="[email protected]" type="button" class="btn btn-primary">Get Query with parameters (string)</button>
11-
<button id="[email protected]" type="button" class="btn btn-primary">Get Query Stream with parameters</button>
12-
<button id="[email protected]" type="button" class="btn btn-primary">Get Query Streams with parameters</button>
11+
<button id="@btnPrefix-object" type="button" class="btn btn-primary">
12+
Get Query with parameters (object)
13+
</button>
14+
<button id="@btnPrefix-string" type="button" class="btn btn-primary">
15+
Get Query with parameters (string)
16+
</button>
17+
<button id="@btnPrefix-stream-params" type="button" class="btn btn-primary">
18+
Get Query Stream with parameters
19+
</button>
20+
<button id="@btnPrefix-streams-params" type="button" class="btn btn-primary">
21+
Get Query Streams with parameters
22+
</button>
1323

14-
@* This tutorial uses turnOn, see turnOn tutorials *@
24+
@* This tutorial uses turnOn, see turnOn tutorials *@
1525
@{
16-
var demoAuthorId = AsList(Data["RandomAuthor"]).FirstOrDefault().EntityId;
26+
var demoAuthorId = Data["RandomAuthor"].List.FirstOrDefault().EntityId;
1727
var data = new {
1828
moduleId = CmsContext.Module.Id,
1929
demoAuthorId = demoAuthorId,
@@ -22,4 +32,4 @@ Tut.Tabs=file:.././230-query-parameters.js
2232

2333
@Kit.Page.TurnOn("window.tutQueryParameters.init()", data: data)
2434

25-
<script src="@CmsContext.View.Path/230-query-parameters.js"></script>
35+
<script src="@App.Path/js/230-query-parameters.js"></script>
Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
@inherits Custom.Hybrid.RazorTyped
22
@using ToSic.Razor.Blade;
3-
@*!
4-
Tut.Tabs=file:.././230-query-parameters.js
5-
!*@
3+
@{/*! Tut.Tabs=file:.././230-query-parameters.js,ViewConfig */
4+
var viewCnf = MyModel.Code("Tutorial").ViewConfig;
5+
var MyData = viewCnf.Query(query: "AuthorsWithBooks") as ToSic.Eav.DataSource.IDataSource;
6+
/*!*/}
67
@* Make sure anonymous users have the 2sxc JS API *@
78
@Kit.Page.Activate("2sxc.JsCore")
9+
@{ var btnPrefix = "mod-" + MyContext.Module.Id; }
810

9-
<button id="[email protected]" type="button" class="btn btn-primary">Get Query with parameters (object)</button>
10-
<button id="[email protected]" type="button" class="btn btn-primary">Get Query with parameters (string)</button>
11-
<button id="[email protected]" type="button" class="btn btn-primary">Get Query Stream with parameters</button>
12-
<button id="[email protected]" type="button" class="btn btn-primary">Get Query Streams with parameters</button>
11+
<button id="@btnPrefix-object" type="button" class="btn btn-primary">
12+
Get Query with parameters (object)
13+
</button>
14+
<button id="@btnPrefix-string" type="button" class="btn btn-primary">
15+
Get Query with parameters (string)
16+
</button>
17+
<button id="@btnPrefix-stream-params" type="button" class="btn btn-primary">
18+
Get Query Stream with parameters
19+
</button>
20+
<button id="@btnPrefix-streams-params" type="button" class="btn btn-primary">
21+
Get Query Streams with parameters
22+
</button>
1323

14-
@* This tutorial uses turnOn, see turnOn tutorials *@
24+
@* This tutorial uses turnOn, see turnOn tutorials *@
1525
@{
16-
var demoAuthorId = AsItem(MyData["RandomAuthor"]).Id;
26+
var demoAuthorId = AsItem(MyData.GetStream("RandomAuthor")).Id;
1727
var data = new {
1828
moduleId = MyContext.Module.Id,
1929
demoAuthorId = demoAuthorId,
@@ -22,5 +32,5 @@ Tut.Tabs=file:.././230-query-parameters.js
2232

2333
@Kit.Page.TurnOn("window.tutQueryParameters.init()", data: data)
2434

25-
<script src="@MyContext.View.Path/230-query-parameters.js"></script>
35+
<script src="@App.Folder.Url/js/230-query-parameters.js"></script>
2636

js/data/Snip-Rest-Query.Dyn.cshtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Tut.Tabs=file:.././220-query.js
1212

1313
@* This tutorial uses turnOn, see turnOn tutorials *@
1414
@Kit.Page.TurnOn("window.tutQuery.init()", data: new {
15-
moduleId = MyContext.Module.Id
15+
moduleId = CmsContext.Module.Id
1616
})
1717

18-
<script src="@CmsContext.View.Path/220-query.js"></script>
18+
<script src="@App.Path/js/220-query.js"></script>

shared/Helpers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
public class Helpers: Custom.Hybrid.CodeTyped
99
{
1010
public string TutorialSectionType = "TutorialSection";
11-
public string TutViewMetadataType = "TutorialViewMetadata";
11+
// public string TutViewMetadataType = "TutorialViewMetadata";
1212

1313
public Helpers Init(Razor14 page) {
1414
Path = page.Path;

shared/InfoSectionPart.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private string NewItemType() {
103103
switch (section) {
104104
case SectResources: return "TutorialResource";
105105
case SectRequirements: return "TutorialRequirement";
106-
case SectRelated: return "TutorialViewMetadata";
106+
case SectRelated: return "TutorialSnippet";
107107
default: return null;
108108
}
109109
}

0 commit comments

Comments
 (0)