Compare commits
2 Commits
04dabc6455
...
732daae00e
| Author | SHA1 | Date | |
|---|---|---|---|
| 732daae00e | |||
| 037ee04fe6 |
@ -17,7 +17,7 @@ public abstract class WebControl : Control
|
||||
return _NanoId.ToString();
|
||||
}
|
||||
}
|
||||
public string ClientId { get { return String.Format("UWT{0}", NanoIdString); } }
|
||||
public string ClientId { get; set; } = "";
|
||||
public ThemeColorPreset ThemeColorPreset { get; set;} = ThemeColorPreset.Unspecified;
|
||||
|
||||
protected override IEnumerable<string> GetStyleClasses()
|
||||
@ -39,7 +39,14 @@ public abstract class WebControl : Control
|
||||
protected override IDictionary<string, string> GetControlAttributes()
|
||||
{
|
||||
IDictionary<string, string> dict = base.GetControlAttributes();
|
||||
dict["id"] = ClientId;
|
||||
if (String.IsNullOrEmpty(ClientId))
|
||||
{
|
||||
dict["id"] = String.Format("UWT{0}", NanoIdString);
|
||||
}
|
||||
else
|
||||
{
|
||||
dict["id"] = ClientId;
|
||||
}
|
||||
return dict;
|
||||
}
|
||||
}
|
||||
55
src/lib/MBS.Web/UI/WebControls/CommandBar.cs
Normal file
55
src/lib/MBS.Web/UI/WebControls/CommandBar.cs
Normal file
@ -0,0 +1,55 @@
|
||||
// Copyright (C) 2024 Michael Becker <alcexhim@gmail.com>
|
||||
//
|
||||
// This file is part of editor-dotnet.
|
||||
//
|
||||
// editor-dotnet is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// editor-dotnet is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with editor-dotnet. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
|
||||
using System.Xml;
|
||||
using MBS.Core;
|
||||
|
||||
namespace MBS.Web.UI.WebControls;
|
||||
|
||||
public class CommandBar : Container
|
||||
{
|
||||
|
||||
protected override string TagName => "ul";
|
||||
protected override IEnumerable<string> GetStyleClasses()
|
||||
{
|
||||
return new string[] { "uwt-commandbar" };
|
||||
}
|
||||
|
||||
public List<CommandItem> Items { get; } = new List<CommandItem>();
|
||||
|
||||
protected override IList<Control> GetChildControls()
|
||||
{
|
||||
IList<Control> list = base.GetChildControls();
|
||||
foreach (CommandItem item in Items)
|
||||
{
|
||||
if (item is CommandReferenceCommandItem crci)
|
||||
{
|
||||
Command? cmd = Application.Instance?.Commands[crci.CommandID];
|
||||
if (cmd != null)
|
||||
{
|
||||
Button btn = new Button();
|
||||
btn.ClientId = String.Format("{0}-item{1}", ClientId, Items.IndexOf(item));
|
||||
btn.Text = cmd.Title;
|
||||
list.Add(btn);
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@ -42,6 +42,11 @@ public class WebPage : Control
|
||||
return new Control[0];
|
||||
}
|
||||
|
||||
protected virtual IEnumerable<Control> GetBodyControls()
|
||||
{
|
||||
return Controls;
|
||||
}
|
||||
|
||||
protected override string TagName => "html";
|
||||
protected override void RenderBeginTag(XmlWriter writer)
|
||||
{
|
||||
@ -107,7 +112,8 @@ public class WebPage : Control
|
||||
|
||||
protected override void RenderContents(XmlWriter writer)
|
||||
{
|
||||
foreach (Control control in Controls)
|
||||
IEnumerable<Control> ctls = GetBodyControls();
|
||||
foreach (Control control in ctls)
|
||||
{
|
||||
control.Context = Context;
|
||||
control.Render(writer);
|
||||
|
||||
@ -352,6 +352,12 @@ public class WebServer
|
||||
return CoalesceVariables(right.PathTemplate).Length.CompareTo(CoalesceVariables(left.PathTemplate).Length);
|
||||
}));
|
||||
|
||||
int iq = path.IndexOf('?');
|
||||
if (iq > -1)
|
||||
{
|
||||
path = path.Substring(0, iq);
|
||||
}
|
||||
|
||||
foreach (WebRoute route in sortedRoutes)
|
||||
{
|
||||
// !!! FIXME !!! /super/d/~/super/d/login.htmld/... falsely maps to ~/{tenant} route
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user