public void InitItems(IEnumerable items, TableItemNode pnode, bool show) { foreach (DBItem item in items) { if (item == pnode.Item) { Helper.OnException(new Exception($"Warning - self reference!({item})")); } if (show && (!Current || ((DBStatus.Actual | DBStatus.Edit | DBStatus.New | DBStatus.Error) & item.Status) != DBStatus.Empty) && (!Access || item.Access.GetFlag(AccessType.Read, GuiEnvironment.User))) { var node = InitItem(item); node.Group = pnode; } else { var node = Nodes.Find(GetName(item)); if (node != null) { node.Hide(); } } } }
private void IncrementNode(TableItemNode node, int d) { while (node != null) { node.Count = (int)node.Count + d; node = node.Group as TableItemNode; } }
public TableItemNode InitItem(IDBTableContent item) { var name = GetName(item); if (!(Nodes.Find(name) is TableItemNode node)) { node = new TableItemNode { Name = name, Item = item, IsCompaund = true }; } return(node); }
public void CheckSave(TableItemNode node, AccessType type, bool?value) { if (node.Access == null) { return; } if (node.Access.GetFlag(AccessType.Update, GuiEnvironment.User) || node.Access.GetFlag(AccessType.Admin, GuiEnvironment.User)) { var access = node.Access.Get(Group); if (value.Value) { access.Access |= type; } else { access.Access &= ~type; } node.Access.Add(access); } var item = node.Item; if (!(item is DBItem dbItem)) { return; } dbItem.Access = node.Access; if (dbItem.IsChanged) { if (!changes.Contains(dbItem)) { changes.Add(dbItem); } } else { changes.Remove(dbItem); } CheckSave(); foreach (TableItemNode subNode in node.Nodes) { CheckSave(subNode, type, value); } }
public override void CheckNode(TableItemNode node) { base.CheckNode(node); var item = (DBItem)node.Item; if (item is Template) { InitItems(((Template)item).Datas, node, ShowTemplateData); } else if (item is Work) { InitItems(((Work)item).GetStages(), node, ShowStage); } else if (item is Stage) { InitItems(((Stage)item).GetParams(), node, ShowStageParam); } }
public virtual void CheckNode(TableItemNode node) { var item = (DBItem)node.Item; if (item is Position) { InitItems(((Position)item).GetUsers(), node, ShowUser); } else if (item.Table.GroupKey != null && item.PrimaryId != null) { InitItems(item.Table.SelectItems(item.Table.GroupKey, CompareType.Equal, item.PrimaryId), node, node.Visible); } if (item is Department) { InitItems(((Department)item).GetUsers(), node, ShowUser && !ShowPosition); InitItems(((Department)item).GetPositions(), node, ShowPosition); } node.IsCompaund = node.Nodes.Count > 0; node.CheckNodes = true; }
public DocumentFilterView() { toolFilter = new ToolSearchEntry() { Name = "Filter", FillWidth = true }; fields = new LayoutList() { EditMode = EditModes.ByClick, GenerateFields = false, GenerateColumns = false, FieldInfo = new LayoutFieldInfo( new LayoutField { Name = nameof(DocumentFilter.IsWork) }, new LayoutField { Name = nameof(DocumentFilter.IsCurrent) }, new LayoutField { Name = nameof(DocumentFilter.Number) }, new LayoutField { Name = nameof(DocumentFilter.Title) }, new LayoutField { Name = nameof(DocumentFilter.Customer) }, new LayoutField { Name = nameof(DocumentFilter.DateType) }, new LayoutField { Name = nameof(DocumentFilter.Date) } ), Name = "Basic" }; templates = new FlowTree { ShowListNode = false, FlowKeys = FlowTreeKeys.Template, Name = "Templates", FilterEntry = toolFilter.Entry }; templates.ListInfo.Columns.Add( new LayoutColumn { Name = nameof(TableItemNode.Count), Width = 35, Style = GuiEnvironment.Theme["CellFar"], Invoker = countInvoker }); works = new FlowTree { ShowListNode = false, FlowKeys = FlowTreeKeys.Work | FlowTreeKeys.Stage, Name = "Works_Stage" }; //dates = new VBox(); //dates.PackStart(dateType) users = new UserTree() { ShowListNode = false, UserKeys = UserTreeKeys.Department | UserTreeKeys.Position | UserTreeKeys.User | UserTreeKeys.Current, Name = "Users" }; box = new GroupBox( new GroupBoxItem { Widget = templates, Name = "Document Type", FillWidth = true, FillHeight = true }, //new GroupBoxItem { Widget = fields, Row = 1, Name = "Parameters", FillWidth = true, Height = 160, Autosize = false, Expand = false }, new GroupBoxItem { Widget = works, Row = 2, Name = "Workflow & Stage", FillWidth = true, FillHeight = true, Expand = false }, new GroupBoxItem { Widget = users, Row = 3, Name = "Staff", FillWidth = true, FillHeight = true, Expand = false }) { Name = "Map" }; PackStart(box, true, true); MinWidth = 330; var nodeSend = new TableItemNode() { Name = "Send", Tag = new DocumentFilter() { Staff = (User)GuiEnvironment.User, DateType = DocumentSearchDate.WorkEnd, Date = new DateInterval(DateTime.Today), IsWork = CheckedState.Unchecked } }; GuiService.Localize(nodeSend, "DocumentWorker", nodeSend.Name); var nodeRecent = new TableItemNode() { Name = "Recent", Tag = new DocumentFilter() { Staff = (User)GuiEnvironment.User, DateType = DocumentSearchDate.WorkEnd, Date = new DateInterval(DateTime.Today) } }; GuiService.Localize(nodeRecent, "DocumentWorker", nodeRecent.Name); var nodeSearch = new TableItemNode() { Name = "Search", Tag = new DocumentFilter() { } }; GuiService.Localize(nodeSearch, "DocumentWorker", nodeSearch.Name); Name = nameof(DocumentFilterView); }
public void InitItem(IDBTableView view, bool show, GlyphType glyph, Color glyphColor) { if (view == null) { return; } TableItemNode node = null; if (show) { view.CollectionChanged += OnCollectionChanged; view.ItemPropertyChanged += OnItemPropertyChanged; views.Add(view); if (ShowListNode) { node = InitItem((IDBTableContent)view); node.Glyph = glyph; node.GlyphColor = glyphColor; node.CheckNodes = true; node.Localize(); } IEnumerable enumer = view; if (view.Table.GroupKey != null) { enumer = view.Table.SelectItems(view.Table.GroupKey, CompareType.Is, null); } foreach (DBItem item in enumer) { if ((!Current || ((DBStatus.Actual | DBStatus.Edit | DBStatus.New | DBStatus.Error) & item.Status) != DBStatus.Empty) && (!Access || item.Access.GetFlag(AccessType.Read, GuiEnvironment.User))) { var element = InitItem(item); if (ShowListNode) { element.Group = node; } else { Nodes.Add(element); } } } if (ShowListNode) { Nodes.Add(node); } } else { view.CollectionChanged -= OnCollectionChanged; view.ItemPropertyChanged -= OnItemPropertyChanged; views.Remove(view); node = (TableItemNode)Nodes.Find(GetName(view)); if (node != null) { node.Hide(); } } }