Browse Source

Added way to edit Data Entry note field on PRS Desktop

Kenric Nugteren 1 year ago
parent
commit
d73559070b

+ 15 - 0
prs.desktop/Panels/DataEntry/DataEntryGrid.cs

@@ -307,6 +307,21 @@ public class DataEntryGrid : DynamicDataGrid<DataEntryDocument>
         new Client<DataEntryDocument>().Save(updates.Where(x=>x.IsChanged()),"Updated Tags on Data Entry Panel");
         Refresh(false,true);
     }
+
+    public void DoChangeNote(string note)
+    {
+        var updates = SelectedRows.ToObjects<DataEntryDocument>().ToArray();
+        foreach (var update in updates)
+        {
+            if (!string.Equals(update.Note, note))
+            {
+                update.Note = note;
+            }
+        }
+
+        Client.Save(updates.Where(x => x.IsChanged()), "Updated Note on Data Entry Panel");
+        Refresh(false, true);
+    }
     
     protected override DragDropEffects OnRowsDragStart(CoreRow[] rows)
     {

+ 1 - 0
prs.desktop/Panels/DataEntry/DataEntryList.xaml

@@ -39,6 +39,7 @@
                                 
                                 <Separator x:Name="_changetagseparator"/>
                                 <MenuItem x:Name="_changeTag" Header="Set Tag"/>
+                                <MenuItem x:Name="_changeNote" Header="Set Note" Click="_changeNote_Click"/>
                                 
                                 <Separator x:Name="_archiveseparator"/>
                                 <MenuItem x:Name="_archive" Header="Archive" Click="_remove_OnClick"/>

+ 13 - 0
prs.desktop/Panels/DataEntry/DataEntryList.xaml.cs

@@ -33,6 +33,7 @@ using InABox.Wpf;
 using System.Collections.ObjectModel;
 using System.Windows.Data;
 using PRSDesktop.Panels.DataEntry;
+using InABox.Wpf.Editors;
 
 namespace PRSDesktop;
 
@@ -474,6 +475,9 @@ public partial class DataEntryList : UserControl, ICorePanel, IDockPanel
         _changeTag.Visibility = _dataEntryGrid.SelectedRows.Any() && _tags.Any() && (Security.CanEdit<DataEntryDocument>() || Security.IsAllowed<CanSetupDataEntryTags>())
             ? Visibility.Visible
             : Visibility.Collapsed;
+        _changeNote.Visibility = _dataEntryGrid.SelectedRows.Any() && Security.CanEdit<DataEntryDocument>()
+            ? Visibility.Visible
+            : Visibility.Collapsed;
         
         _changetagseparator.Visibility = _archive.Visibility;
         
@@ -579,6 +583,15 @@ public partial class DataEntryList : UserControl, ICorePanel, IDockPanel
         _historyGrid.DoReopen();
     }
 
+    private void _changeNote_Click(object sender, RoutedEventArgs e)
+    {
+        string note = "";
+        if(TextEdit.Execute("Enter note:", ref note))
+        {
+            _dataEntryGrid.DoChangeNote(note);
+        }
+    }
+
     private void _dataEntryGrid_OnContextMenuOpening(object sender, ContextMenuEventArgs e)
     {