Skip to content

Commit 1cf53d2

Browse files
committed
feat: general improvements
1 parent 7d54a20 commit 1cf53d2

8 files changed

Lines changed: 82 additions & 108 deletions
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.popupnotification {
1+
.wx-popupnotification {
22
position: fixed;
33
z-index: 999;
44
top: 5em;
@@ -7,18 +7,18 @@
77
width: 25em;
88
}
99

10-
.popupnotification > div {
10+
.wx-popupnotification > div {
1111
}
12-
.popupnotification > div > .d-flex {
12+
.wx-popupnotification > div > .d-flex {
1313
align-items: flex-start;
1414
}
1515

16-
.popupnotification > div > .d-flex > img {
16+
.wx-popupnotification > div > .d-flex > img {
1717
max-width: 80px;
1818
padding-top: 0.5em;
1919
padding-right: 1em;
2020
}
2121

22-
.popupnotification > div > .progress {
22+
.wx-popupnotification > div > .progress {
2323
height: 3px;
2424
}

src/WebExpress.WebApp/Assets/js/webexpress.webapp.popupnotification.js

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,36 @@
11
/**
2-
* Popup-Benachrichtigungen
2+
* Control for displaying popup notifications.
33
* The following events are triggered:
44
* - webexpress.webapp.close with parameter id.
55
*/
6-
webexpress.webapp.popupNotificationCtrl = class extends webexpress.webui.events {
7-
_restUri = "";
8-
_container = $("<div class='popupnotification'/>");
6+
webexpress.webapp.PopupNotificationCtrl = class extends webexpress.webui.Ctrl {
7+
_interval = null;
8+
_restUri = null;
99
_activeNotifications = new Map();
1010

1111
/**
12-
* Constructor
13-
* @param settings Options for styling the control:
14-
* - id Sets the id of the control.
15-
* - resturi The uri of the rest api interface that collects the data.
16-
* - intervall The interval determines the timing of the rest api requests.
17-
*/
18-
constructor(settings) {
19-
super();
20-
21-
let id = settings.id;
22-
let interval = settings.interval ?? 10000;
23-
this._restUri = settings.resturi;
12+
* Constructor
13+
* @param {HTMLElement} element - The DOM element associated with the move control.
14+
*/
15+
constructor(element) {
16+
super(element);
2417

25-
this._container.attr("id", id ?? "");
18+
// Initialize structure and parse existing data
19+
this._interval = $(element).data("interval") || 10000;
20+
this._restUri = $(element).data("uri") || null;
2621

2722
setInterval(function () {
2823
this.receiveData();
2924

30-
}.bind(this), interval);
25+
}.bind(this), this._interval);
3126

3227
this.receiveData();
28+
29+
// Clean up the DOM
30+
$(element)
31+
.empty()
32+
.removeAttr("data-interval data-uri")
33+
.addClass("wx-popupnotification");
3334
}
3435

3536
/**
@@ -101,7 +102,7 @@ webexpress.webapp.popupNotificationCtrl = class extends webexpress.webui.events
101102
alert.append($("<div class='progress mt-2'></div>").append(progressbar));
102103
}
103104

104-
this._container.append(alert);
105+
$(this._element).append(alert);
105106

106107
if (!this._activeNotifications.has(id)) {
107108
let data = {
@@ -159,11 +160,7 @@ webexpress.webapp.popupNotificationCtrl = class extends webexpress.webui.events
159160
});
160161
}.bind(this));
161162
}
163+
}
162164

163-
/**
164-
* Returns the control.
165-
*/
166-
get getCtrl() {
167-
return this._container;
168-
}
169-
}
165+
// Register the class in the controller
166+
webexpress.webui.Controller.registerClass("wx-webapp-popupnotification", webexpress.webapp.PopupNotificationCtrl);

src/WebExpress.WebApp/WWW/Api/1/RestPopupNotification.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ public void CreateData(Request request)
4444
/// <returns>A collection of notifications.</returns>
4545
public object GetData(Request request)
4646
{
47-
48-
return _componentHub.GetComponentManager<NotificationManager>()?.GetNotifications(_applicationContext, request);
47+
return _componentHub.GetComponentManager<NotificationManager>()?.GetNotifications
48+
(
49+
_applicationContext, request
50+
);
4951
}
5052

5153
/// <summary>

src/WebExpress.WebApp/WebApiControl/ControlApiNotificationPopup.cs

Lines changed: 0 additions & 64 deletions
This file was deleted.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using WebExpress.WebApp.WWW.Api._1;
2+
using WebExpress.WebCore;
3+
using WebExpress.WebCore.WebHtml;
4+
using WebExpress.WebUI.WebControl;
5+
using WebExpress.WebUI.WebPage;
6+
7+
namespace WebExpress.WebApp.WebApiControl
8+
{
9+
/// <summary>
10+
/// Represents a control for displaying notification popups via API.
11+
/// </summary>
12+
public class ControlApiPopupNotification : Control
13+
{
14+
/// <summary>
15+
/// Initializes a new instance of the <see cref="ControlApiPopupNotification"/> class.
16+
/// </summary>
17+
/// <param name="id">The optional identifier for the control. If not provided, a new GUID will be generated.</param>
18+
public ControlApiPopupNotification(string id = null)
19+
: base(id ?? "26E517F5-56F7-485E-A212-6033618708F3")
20+
{
21+
}
22+
23+
/// <summary>
24+
/// Converts the control to an HTML representation.
25+
/// </summary>
26+
/// <param name="renderContext">The context in which the control is rendered.</param>
27+
/// <param name="visualTree">The visual tree representing the control's structure.</param>
28+
/// <returns>An HTML node representing the rendered control.</returns>
29+
public override IHtmlNode Render(IRenderControlContext renderContext, IVisualTreeControl visualTree)
30+
{
31+
var applicationContext = renderContext?.PageContext?.ApplicationContext;
32+
33+
var html = new HtmlElementTextContentDiv()
34+
{
35+
Id = Id,
36+
Class = Css.Concatenate("wx-webapp-popupnotification", GetClasses()),
37+
Style = GetStyles()
38+
}
39+
.AddUserAttribute("data-uri", WebEx.ComponentHub.SitemapManager.GetUri<RestPopupNotification>(applicationContext).ToString())
40+
.AddUserAttribute("data-intervall", "15000");
41+
42+
return html;
43+
}
44+
}
45+
}

src/WebExpress.WebApp/WebControl/ControlModalFormConfirm.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using WebExpress.WebCore.Internationalization;
44
using WebExpress.WebCore.WebHtml;
55
using WebExpress.WebCore.WebIcon;
6-
using WebExpress.WebCore.WebUri;
76
using WebExpress.WebUI.WebControl;
87
using WebExpress.WebUI.WebPage;
98

@@ -44,24 +43,19 @@ public class ControlModalFormConfirm : ControlModalForm
4443
/// </summary>
4544
private ControlFormItemButtonSubmit SubmitButton { get; } = new ControlFormItemButtonSubmit("submit");
4645

47-
/// <summary>
48-
/// Returns or sets the redirect uri.
49-
/// </summary>
50-
public IUri RedirectUri { get { return Form?.RedirectUri; } set { Form.RedirectUri = value; } }
51-
5246
/// <summary>
5347
/// Initializes a new instance of the class.
5448
/// </summary>
5549
/// <param name="id">The id.</param>
5650
public ControlModalFormConfirm(string id = null, params ControlFormItem[] content)
5751
: base(id, content)
5852
{
59-
Form.ProcessForm += (argument) =>
53+
ProcessForm += (argument) =>
6054
{
6155
OnConfirm(argument.Context);
6256
};
6357

64-
Form.AddPrimaryButton(SubmitButton);
58+
AddPrimaryButton(SubmitButton);
6559
}
6660

6761
/// <summary>
@@ -108,7 +102,7 @@ public override IHtmlNode Render(IRenderControlContext renderContext, IVisualTre
108102
SubmitButtonLabel = I18N.Translate(renderContext.Request, "webexpress.webapp:confirm.label");
109103
}
110104

111-
Form.RedirectUri = RedirectUri ?? renderContext.Request.Uri;
105+
RedirectUri = RedirectUri ?? renderContext.Request.Uri;
112106
SubmitButton.Text = SubmitButtonLabel;
113107

114108
return base.Render(renderContext, visualTree, items);

src/WebExpress.WebApp/WebControl/ControlWebAppHeaderQuickCreate.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public override IHtmlNode Render(IRenderControlContext renderContext, IVisualTre
132132
var nextQuickcreate = quickcreateList.Skip(1);
133133

134134
var quickcreate = nextQuickcreate.Any() ?
135-
(IControl)new ControlSplitButtonLink(Id, nextQuickcreate.Skip(1).ToArray())
135+
(IControl)new ControlSplitButtonLink(Id, [.. nextQuickcreate.Skip(1)])
136136
{
137137
Text = I18N.Translate(renderContext.Request?.Culture, "webexpress.webapp:header.quickcreate.label"),
138138
Uri = firstQuickcreate?.Uri,

src/WebExpress.WebApp/WebPage/VisualTreeWebApp.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public class VisualTreeWebApp : VisualTreeControl
6767
/// <summary>
6868
/// Returns the control for displaying notification popups via API.
6969
/// </summary>
70-
public ControlApiNotificationPopup NotificationPopup { get; protected set; } = new ControlApiNotificationPopup("wx-notificationpopup");
70+
public ControlApiPopupNotification NotificationPopup { get; protected set; } = new ControlApiPopupNotification("wx-notificationpopup");
7171

7272
/// <summary>
7373
/// Initializes a new instance of the class.

0 commit comments

Comments
 (0)