diff --git a/BeWoPlanerMobil/Controllers/MainController.cs b/BeWoPlanerMobil/Controllers/MainController.cs index f8bb24ea0..a83084a18 100644 --- a/BeWoPlanerMobil/Controllers/MainController.cs +++ b/BeWoPlanerMobil/Controllers/MainController.cs @@ -640,9 +640,10 @@ namespace BeWoPlanerMobil.Controllers { if (tm.Text == null) { - tm.Text = ""; + tm.Text = string.Empty; } } + if(!MobileSessionFacade.CheckForUserRight(UserRightType.TextbausteineAlleAnsehen)) { textbausteine = textbausteine.Where(w => w.Employee.EmployeeOid == Model.Employee.EmployeeOid).ToList(); @@ -659,13 +660,25 @@ namespace BeWoPlanerMobil.Controllers if(item.ParentOid != null) { var parent = displayItems.FirstOrDefault(f => f.Oid == item.ParentOid); - parent?.nodes.AddIfNotIn(item); + + if (parent != null) + { + if (parent.nodes == null) + { + parent.nodes = new List(); + } + + parent.nodes.AddIfNotIn(item); + } } } displayItems = displayItems.Where(w => w.ParentOid == null).ToList(); - return SerializeObject(displayItems); + return JsonConvert.SerializeObject(displayItems, Formatting.None, new JsonSerializerSettings + { + NullValueHandling = NullValueHandling.Ignore + }); } catch(Exception exception) { diff --git a/BeWoPlanerMobil/Util/TextbausteinDisplayItem.cs b/BeWoPlanerMobil/Util/TextbausteinDisplayItem.cs index 09270ac15..ef3da2804 100644 --- a/BeWoPlanerMobil/Util/TextbausteinDisplayItem.cs +++ b/BeWoPlanerMobil/Util/TextbausteinDisplayItem.cs @@ -5,14 +5,13 @@ namespace BeWoPlanerMobil.Util { public class TextbausteinDisplayItem { - // selectable, text (name), nodes (child elements) - public bool selectable => false; + public bool selectable { get; } public string text { get; set; } - public List nodes { get; set; } = new List(); + public List nodes { get; set; } - public List tags { get; set; } = new List(); + public List tags { get; set; } [JsonIgnore] public string Name { get; set; } @@ -28,23 +27,13 @@ namespace BeWoPlanerMobil.Util [JsonIgnore] public List Children { get; set; } - public TextbausteinDisplayItem(long pOid, string pName, long? pParentOid, bool pIsParent, string pText) - { - Oid = pOid; - Name = pName; - ParentOid = pParentOid; - IsParent = pIsParent; - Text = pText; - - Children = new List(); - } - public TextbausteinDisplayItem(string pText, List pTags, long? pParentOid, long pOid) { text = pText; tags = pTags; ParentOid = pParentOid; Oid = pOid; + selectable = pParentOid.HasValue; } } } \ No newline at end of file