浏览代码

PRS MOBILE - fix to job docs viewer when duplicate foldernames are present / folder is a child of "All Items"

Nick-PRSDigital@bitbucket.org 2 年之前
父节点
当前提交
ed66971564
共有 2 个文件被更改,包括 32 次插入15 次删除
  1. 26 9
      prs.mobile/comal.timesheets/Site/JobDocViewer.xaml.cs
  2. 6 6
      prs.mobile/comal.timesheets/Site/Site.xaml

+ 26 - 9
prs.mobile/comal.timesheets/Site/JobDocViewer.xaml.cs

@@ -33,7 +33,7 @@ namespace comal.timesheets
         bool filesLoaded = false;
         bool specificQueryLoading = false;
         Guid jobID = Guid.Empty;
-        List<String> loadedFolders = new List<string>();
+        List<Guid> loadedFolders = new List<Guid>();
         List<MileStoneShell> mileStoneShells = new List<MileStoneShell>();
         List<JobDocSetFileShell> shells = new List<JobDocSetFileShell>();
         List<JobDocSetFileShell> searchList = new List<JobDocSetFileShell>();
@@ -82,24 +82,24 @@ namespace comal.timesheets
                 }
                 else
                 {
-                    var list = shells.Where(x => x.FolderName == folder.ItemName);
+                    var list = shells.Where(x => x.FolderID == folder.ID);
                     AddSearchItems(list);
                 }
             }
-            else if (loadedFolders.Contains(folder.ItemName))
+            else if (loadedFolders.Contains(folder.ID))
             {
-                var list = specificQueryFileShells.Where(x => x.FolderName == folder.ItemName);
+                var list = specificQueryFileShells.Where(x => x.FolderID == folder.ID);
                 AddSearchItems(list);
             }
             else
-                LoadFilesForFolder(folder.ItemName);
+                LoadFilesForFolder(folder.ID);
         }
-        private async void LoadFilesForFolder(string itemName)
+        private async void LoadFilesForFolder(Guid folderID)
         {
             currentQueryFileShells.Clear();
             specificQueryLoading = true;
             ShowLoading();
-            LoadFiles(new Filter<JobDocumentSetMileStone>(x => x.DocumentSet.Folder.Name).IsEqualTo(itemName), true, itemName);
+            LoadFiles(new Filter<JobDocumentSetMileStone>(x => x.DocumentSet.Folder.ID).IsEqualTo(folderID), true, folderID);
         }
         void Expand_Tapped(object sender, EventArgs e)
         {
@@ -174,6 +174,7 @@ namespace comal.timesheets
             e.Height = e.GetActualNodeHeight();
             e.Handled = true;
         }
+
         private void LoadFolders(Guid jobid)
         {
             CoreTable table = new Client<JobDocumentSetFolder>().Query(new Filter<JobDocumentSetFolder>(x => x.Job.ID).IsEqualTo(jobid),
@@ -192,13 +193,15 @@ namespace comal.timesheets
             foreach (var folder in folderList)
             {
                 folder.List = folderList;
-                if (folder.ParentID == Guid.Empty)
+                if (folder.ParentID == Guid.Empty || folder.ParentID == CoreUtils.FullGuid)
                     displayList.Add(folder);
             }
+            displayList = new ObservableCollection<FolderViewItem>(displayList.OrderBy(x => x.ItemName));
             treeView.ItemsSource = displayList;
             foldersLoaded = true;
         }
-        private async void LoadFiles(Filter<JobDocumentSetMileStone> filter, bool specificQuery = false, string loadFolder = "")
+
+        private async void LoadFiles(Filter<JobDocumentSetMileStone> filter, bool specificQuery = false, Guid loadFolder = new Guid())
         {
             await Task.Run(() =>
             {
@@ -210,6 +213,7 @@ namespace comal.timesheets
                                 new Columns<JobDocumentSetMileStone>(
                                 x => x.ID,
                                 x => x.DocumentSet.Folder.Name,
+                                x => x.DocumentSet.Folder.ID,
                                 x => x.Submitted,
                                 x => x.Employee.Name,
                                 x => x.Type.Description,
@@ -258,6 +262,7 @@ namespace comal.timesheets
                 }
             });
         }
+
         private CoreTable QueryFiles(CoreTable milestones, bool specificQuery = false)
         {
             Filter<JobDocumentSetMileStoneFile> filter = new Filter<JobDocumentSetMileStoneFile>(x => x.EntityLink.ID).IsEqualTo(milestones.Rows.FirstOrDefault().Get<Guid>("ID"));
@@ -276,6 +281,7 @@ namespace comal.timesheets
                   ));
             return table;
         }
+
         private Guid AddMileStoneShell(CoreRow milestonerow, bool specificQuery = false)
         {
             Guid id = milestonerow.Get<Guid>("ID");
@@ -283,6 +289,7 @@ namespace comal.timesheets
             {
                 ID = milestonerow.Get<Guid>("ID"),
                 FolderName = milestonerow.Get<string>("DocumentSet.Folder.Name"),
+                FolderID = milestonerow.Get<Guid>("DocumentSet.Folder.ID"),
                 EmployeeName = milestonerow.Get<string>("Employee.Name"),
                 Type = milestonerow.Get<string>("Type.Description"),
                 DocSetDescription = milestonerow.Get<string>("DocumentSet.Description"),
@@ -294,6 +301,7 @@ namespace comal.timesheets
                 mileStoneShells.Add(shell);
             return id;
         }
+
         private void AddFileShell(CoreRow filerow, bool specificQuery = false)
         {
             JobDocSetFileShell file = new JobDocSetFileShell
@@ -305,10 +313,12 @@ namespace comal.timesheets
 
             MileStoneShell mileStone = mileStoneShells.Find(x => x.ID == file.MileStoneID);
             file.FolderName = mileStone.FolderName;
+            file.FolderID = mileStone.FolderID;
             file.EmployeeName = mileStone.EmployeeName;
             file.Type = mileStone.Type;
             file.DocSetDescription = mileStone.DocSetDescription;
             file.Issued = mileStone.Issued;
+            
             file.TrimmedIssued = TrimWhiteSpace(file.Issued);
 
             byte[] data = filerow.Get<byte[]>("Thumbnail");
@@ -331,6 +341,7 @@ namespace comal.timesheets
             else
                 shells.Add(file);
         }
+
         private void ShowFiles()
         {
             Device.BeginInvokeOnMainThread(() =>
@@ -344,6 +355,7 @@ namespace comal.timesheets
                 filesColumn.Width = new GridLength(1, GridUnitType.Star);
             });
         }
+
         private void ShowLoading()
         {
             Device.BeginInvokeOnMainThread(async () =>
@@ -373,6 +385,7 @@ namespace comal.timesheets
                 loadingLbl.RotateTo(360, number);
             });
         }
+
         static string TrimWhiteSpace(string s)
         {
             s = String.Concat(s.Where(c => !Char.IsWhiteSpace(c)));
@@ -484,6 +497,7 @@ namespace comal.timesheets
     {
         public Guid ID { get; set; }
         public string FolderName { get; set; }
+        public Guid FolderID { get; set; }
         public string EmployeeName { get; set; }
         public string Type { get; set; }
         public string DocSetDescription { get; set; }
@@ -491,6 +505,7 @@ namespace comal.timesheets
         public MileStoneShell()
         {
             ID = Guid.Empty;
+            FolderID = Guid.Empty;
             FolderName = "";
             EmployeeName = "";
             Type = "";
@@ -504,6 +519,7 @@ namespace comal.timesheets
         public Guid DocLinkID { get; set; }
         public string FileName { get; set; }
         public string FolderName { get; set; }
+        public Guid FolderID { get; set; }
         public string EmployeeName { get; set; }
         public string Type { get; set; }
         public string DocSetDescription { get; set; }
@@ -530,6 +546,7 @@ namespace comal.timesheets
             WidthRequest = 200;
             Thumbnail = null;
             MileStoneID = Guid.Empty;
+            FolderID = Guid.Empty;
         }
     }
     #endregion

+ 6 - 6
prs.mobile/comal.timesheets/Site/Site.xaml

@@ -20,15 +20,15 @@
     </NavigationPage.TitleView>
     <ContentPage.Content>
         <ScrollView>
-            <StackLayout x:Name="siteStackLayout">
+            <StackLayout x:Name="siteStackLayout" Spacing="0">
 
                 <Button Clicked="SelectJobBtn_Clicked" x:Name="selectJobBtn" 
-                Text="Select Job" FontSize="Medium" FontAttributes="Bold" TextColor="White" BackgroundColor="#15C7C1" CornerRadius="10" Margin="10"
+                Text="Select Job" FontSize="Medium" FontAttributes="Bold" TextColor="White" BackgroundColor="#15C7C1" CornerRadius="10"  Margin="10, 10, 10, 5"
                 HorizontalOptions="FillAndExpand" VerticalOptions="Start"
                 />
 
                 <!--ITP Module-->
-                <Frame BorderColor="#15C7C1"  Margin="7" CornerRadius="15"  Padding="5" HasShadow="False">
+                <Frame BorderColor="#15C7C1"  Margin="10, 5, 10, 5" CornerRadius="15"  Padding="5" HasShadow="False">
                     <Frame.GestureRecognizers>
                         <TapGestureRecognizer Tapped="ITPs_Tapped"/>
                     </Frame.GestureRecognizers>
@@ -55,7 +55,7 @@
                 </Frame>
 
                 <!--Shop Drawings-->
-                <Frame x:Name="JobDocumentsFrame" BorderColor="#15C7C1"  Margin="5" CornerRadius="15"  Padding="5" HasShadow="False">
+                <Frame x:Name="JobDocumentsFrame" BorderColor="#15C7C1"  Margin="10, 5, 10, 5" CornerRadius="15"  Padding="5" HasShadow="False">
                     <Frame.GestureRecognizers>
                         <TapGestureRecognizer Tapped="JobDocs_Tapped"/>
                     </Frame.GestureRecognizers>
@@ -84,7 +84,7 @@
 
 
                 <!--Job Forms-->
-                <Frame BorderColor="#15C7C1"  Margin="5" CornerRadius="15"  Padding="5" HasShadow="False">
+                <Frame BorderColor="#15C7C1"  Margin="10, 5, 10, 5" CornerRadius="15"  Padding="5" HasShadow="False">
                     <Frame.GestureRecognizers>
                         <TapGestureRecognizer Tapped="JobForms_Tapped"/>
                     </Frame.GestureRecognizers>
@@ -111,7 +111,7 @@
                 </Frame>
 
                 <!--General Documents-->
-                <Frame x:Name="GeneralDocumentsFrame" BorderColor="#15C7C1"  Margin="5" CornerRadius="15"  Padding="5" HasShadow="False">
+                <Frame x:Name="GeneralDocumentsFrame" BorderColor="#15C7C1"  Margin="10, 5, 10, 5" CornerRadius="15"  Padding="5" HasShadow="False">
                     <Frame.GestureRecognizers>
                         <TapGestureRecognizer Tapped="SiteDocs_Tapped"/>
                     </Frame.GestureRecognizers>