Przeglądaj źródła

More work on issues.

Kenric Nugteren 8 miesięcy temu
rodzic
commit
83da39aaca

+ 25 - 5
prs.desktop/Forms/Issues/IssuesGrid.cs

@@ -3,6 +3,7 @@ using InABox.Clients;
 using InABox.Configuration;
 using InABox.Core;
 using InABox.DynamicGrid;
+using InABox.Wpf.Editors;
 using InABox.WPF;
 using System;
 using System.Collections.Generic;
@@ -33,6 +34,12 @@ public class IssuesGrid : DynamicGrid<Kanban>, ISpecificGrid
 
     public Guid CustomerID { get; set; }
 
+    private CustomProperty CustomerProperty = new CustomProperty
+    {
+        Name = "CustomerID",
+        PropertyType = typeof(string)
+    };
+
     public IssuesGrid() : base()
     {
         var cols = LookupFactory.DefineColumns<Kanban>();
@@ -67,25 +74,38 @@ public class IssuesGrid : DynamicGrid<Kanban>, ISpecificGrid
     public override Kanban CreateItem()
     {
         var item = base.CreateItem();
-        // item.UserProperties["CustomerID"] = CustomerID.ToString();
+        item.UserProperties["CustomerID"] = CustomerID.ToString();
+        // item.Status = KanbanStatus.Open;
         return item;
     }
 
     private void AddNote_Click(CoreRow row)
     {
         var kanban = row.ToObject<Kanban>();
+        var text = "";
+
+        if(TextEdit.Execute("Enter note:", ref text))
+        {
+            text = string.Format("{0:yyyy-MM-dd HH:mm:ss}: {1}", DateTime.Now, text);
+            kanban.Notes = kanban.Notes.Concatenate([text]);
+            SaveItem(kanban);
+            Refresh(false, true);
+        }
     }
 
     private void CloseTask_Click(CoreRow row)
     {
+        var kanban = row.ToObject<Kanban>();
+        kanban.Closed = DateTime.Now;
+        SaveItem(kanban);
+        Refresh(false, true);
     }
 
     private Column<Kanban>[] AllowedColumns = [
         new(x => x.Number),
         new(x => x.Title),
         new(x => x.Description),
-        new(x => x.Notes),
-        new(x => x.Type.ID)];
+        new(x => x.Notes)];
 
     protected override void CustomiseEditor(Kanban[] items, DynamicGridColumn column, BaseEditor editor)
     {
@@ -178,7 +198,6 @@ public class IssuesGrid : DynamicGrid<Kanban>, ISpecificGrid
         var columns = new DynamicGridColumns<Kanban>();
         columns.Add(x => x.Number);
         columns.Add(x => x.Title);
-        columns.Add(x => x.Type.Code);
         return columns;
     }
 
@@ -195,7 +214,8 @@ public class IssuesGrid : DynamicGrid<Kanban>, ISpecificGrid
         Filters<Kanban> criteria, Columns<Kanban> columns, ref SortOrder<Kanban>? sort,
         CancellationToken token, Action<CoreTable?, Exception?> action)
     {
-        // criteria.Add(new Filter<Kanban>("CustomerID").IsEqualTo(CustomerID.ToString()));
+        criteria.Add(new Filter<Kanban>(x => x.Closed).IsNotEqualTo(Guid.Empty));
+        // criteria.Add(new Filter<Kanban>(CustomerProperty).IsEqualTo(CustomerID.ToString()));
         if(Options.PageSize > 0)
         {
             var inSort = sort;

+ 16 - 0
prs.desktop/Forms/Issues/IssuesWindow.xaml.cs

@@ -1,5 +1,6 @@
 using Comal.Classes;
 using InABox.Clients;
+using InABox.Core;
 using InABox.Rpc;
 using InABox.Wpf;
 using System;
@@ -39,6 +40,20 @@ public partial class IssuesWindow : Window
 
     public static void Execute()
     {
+        var license = Client.Query(new Filter<License>().All(), Columns.None<License>().Add(x => x.Data))
+            .ToObjects<License>().FirstOrDefault();
+
+        var customerID = Guid.Empty;
+        if(license is not null && LicenseUtils.TryDecryptLicense(license.Data, out var result, out var error))
+        {
+            customerID = result.CustomerID;
+        }
+        if(customerID == Guid.Empty)
+        {
+            MessageWindow.ShowMessage("Could not load issues: no customer ID", "Error");
+            return;
+        }
+
         var transport = new RpcClientSocketTransport(["remote.prsdigital.com.au:8006"]);
         var client = new RpcClient<Kanban>(transport);
         if(client.Validate("ADMIN", "admin", Guid.Empty).Status != InABox.Clients.ValidationStatus.VALID)
@@ -47,6 +62,7 @@ public partial class IssuesWindow : Window
             return;
         }
         var issues = new IssuesWindow();
+        issues.Grid.CustomerID = customerID;
         issues.ClientFactory = x => (Activator.CreateInstance(typeof(RpcClient<>).MakeGenericType(x), transport) as IClient)!;
         issues.ShowDialog();
     }

+ 8 - 1
prs.desktop/MainWindow.xaml.cs

@@ -3603,6 +3603,13 @@ public partial class MainWindow : IPanelHostControl
 
     private void Issues_Click(object sender, RoutedEventArgs e)
     {
-        IssuesWindow.Execute();
+        try
+        {
+            IssuesWindow.Execute();
+        }
+        catch(Exception err)
+        {
+            MessageWindow.ShowError("Could not load issues.", err);
+        }
     }
 }