UI Enhancements in IT Service Request, Announcements, Workforce and notification fixes

This commit is contained in:
2026-03-22 18:00:10 +08:00
parent 049ab2c794
commit 872c2aab87
15 changed files with 1290 additions and 183 deletions
+44 -3
View File
@@ -11,6 +11,10 @@ class Announcement {
this.templateId,
required this.createdAt,
required this.updatedAt,
required this.bannerEnabled,
this.bannerShowAt,
this.bannerHideAt,
this.pushIntervalMinutes,
});
final String id;
@@ -23,6 +27,29 @@ class Announcement {
final DateTime createdAt;
final DateTime updatedAt;
/// Whether a persistent banner is shown at the top of the announcements screen.
final bool bannerEnabled;
/// When the banner should start showing. [null] means immediately.
final DateTime? bannerShowAt;
/// When the banner should stop showing. [null] means it requires a manual
/// turn-off by the poster or an admin.
final DateTime? bannerHideAt;
/// How often (in minutes) a scheduled push notification is sent while the
/// banner is active. [null] means no scheduled push. Max is 1440 (daily).
final int? pushIntervalMinutes;
/// Whether the banner is currently active (visible) based on the current time.
bool get isBannerActive {
if (!bannerEnabled) return false;
final now = AppTime.now();
if (bannerShowAt != null && now.isBefore(bannerShowAt!)) return false;
if (bannerHideAt != null && now.isAfter(bannerHideAt!)) return false;
return true;
}
@override
bool operator ==(Object other) =>
identical(this, other) ||
@@ -34,6 +61,10 @@ class Announcement {
body == other.body &&
isTemplate == other.isTemplate &&
templateId == other.templateId &&
bannerEnabled == other.bannerEnabled &&
bannerShowAt == other.bannerShowAt &&
bannerHideAt == other.bannerHideAt &&
pushIntervalMinutes == other.pushIntervalMinutes &&
createdAt == other.createdAt &&
updatedAt == other.updatedAt;
@@ -45,15 +76,17 @@ class Announcement {
body,
isTemplate,
templateId,
bannerEnabled,
bannerShowAt,
bannerHideAt,
pushIntervalMinutes,
createdAt,
updatedAt,
);
factory Announcement.fromMap(Map<String, dynamic> map) {
final rolesRaw = map['visible_roles'];
final roles = rolesRaw is List
? rolesRaw.cast<String>()
: <String>[];
final roles = rolesRaw is List ? rolesRaw.cast<String>() : <String>[];
return Announcement(
id: map['id'] as String,
@@ -65,6 +98,14 @@ class Announcement {
templateId: map['template_id'] as String?,
createdAt: AppTime.parse(map['created_at'] as String),
updatedAt: AppTime.parse(map['updated_at'] as String),
bannerEnabled: map['banner_enabled'] as bool? ?? false,
bannerShowAt: map['banner_show_at'] != null
? AppTime.parse(map['banner_show_at'] as String)
: null,
bannerHideAt: map['banner_hide_at'] != null
? AppTime.parse(map['banner_hide_at'] as String)
: null,
pushIntervalMinutes: map['push_interval_minutes'] as int?,
);
}
}