i forget the opposite of @{}

This commit is contained in:
adam 2025-01-06 00:14:56 -05:00
parent 8b857b82c9
commit c0cfa90874
2 changed files with 40 additions and 9 deletions

View File

@ -1,5 +1,6 @@
using System.ComponentModel;
using System.Diagnostics;
using System.Text;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using vassago.Models;
@ -44,6 +45,25 @@ public class ChannelsController : Controller
ViewData["breadcrumbs"];
walker = walker.ParentChannel;
}
var sb = new StringBuilder();
sb.Append("[");
sb.Append("{text: \"channels\", nodes: [");
var first=true;
foreach(var subChannel in channel.SubChannels)
{
if(!first)
{
sb.Append(',');
}
else
{
first = false;
}
sb.Append($"{{\"text\": \"<a href=\\\"{Url.ActionLink(action: "Details", controller: "Channels", values: new {id = subChannel.Id})}\\\">{subChannel.DisplayName}</a>\"");
}
sb.Append("]");
ViewData.Add("channelsTree", sb.ToString());
return View(
new Tuple<Channel, Enumerations.LewdnessFilterLevel, Enumerations.MeannessFilterLevel>(
channel, channel.EffectivePermissions.LewdnessFilterLevel, channel.EffectivePermissions.MeannessFilterLevel

View File

@ -7,7 +7,7 @@
var IfInheritedMeannessFilterLevel = Model.Item3;
}
<a href="/">home</a>/
@Html.Raw(ViewData["breadcrumbs"])
<table class="table">
@ -78,7 +78,16 @@
</tr>
<tr>
<th scope="row">Sub Channels</th>
<td>@(ThisChannel.SubChannels?.Count ?? 0)</td>
<td>
@if((ThisChannel.SubChannels?.Count ?? 0) > 0)
{
@Html.Raw("<div id=\"channelsTree\"></div>");
}
else
{
@Html.Raw("0")
}
</td>
</tr>
<tr>
<th scope="row">Accounts</th>
@ -87,7 +96,6 @@
</tbody>
</table>
@section Scripts{
<script type="text/javascript">
@{
@ -109,12 +117,15 @@
console.log(channelNow);
return channelNow;
}
function getTree() {
var tree = @Html.Raw(ViewData["treeString"]);
console.log(tree);
return tree;
@if((ThisChannel.SubChannels?.Count ?? 0) > 0)
{
/*
function channelsTree() {
var tree = @Html.Raw(ViewData["treeString"]);
return tree;
}
$('#tree').bstreeview({ data: getTree() });
$('#channelsTree').bstreeview({ data: channelsTree() });
*/
}
</script>
}