浏览代码

Merge remote-tracking branch 'origin/nick' into frank

Frank van den Bos 2 年之前
父节点
当前提交
897972cd94

+ 1 - 1
prs.desktop/prsdesktop.iss

@@ -5,7 +5,7 @@
 #pragma verboselevel 9
 
 #define MyAppName "PRS Desktop"
-#define MyAppVersion "7.06"
+#define MyAppVersion "7.07"
 #define MyAppPublisher "PRS Digital"
 #define MyAppURL "https://www.prs-software.com.au"
 #define MyAppExeName "PRSDesktop.exe"

+ 2 - 2
prs.mobile/comal.timesheets.iOS/Info.plist

@@ -9,9 +9,9 @@
 	<key>CFBundleName</key>
 	<string>TimeBench</string>
 	<key>CFBundleShortVersionString</key>
-	<string>4.40.4</string>
+	<string>4.41.1</string>
 	<key>CFBundleVersion</key>
-	<string>4.40.4</string>
+	<string>4.41.1</string>
 	<key>NSBluetoothAlwaysUsageDescription</key>
 	<string>Bluetooth access is needed to locate equipment items</string>
 	<key>NSBluetoothPeripheralUsageDescription</key>

+ 2 - 1
prs.mobile/comal.timesheets/DigitalForms/CustomUserControls/CustomPickeriOS.xaml

@@ -8,7 +8,8 @@
                 <RowDefinition Height="50" x:Name="buttonRow"/>
                 <RowDefinition Height="0" x:Name="listViewRow"/>
             </Grid.RowDefinitions>
-            <Button Grid.Row="0" x:Name="selectBtn" Text="Select an Option" Clicked="SelectBtn_Clicked" TextColor="White" BackgroundColor="#15C7C1" VerticalOptions="FillAndExpand"/>
+            <Button Grid.Row="0" x:Name="selectBtn" Text="Select an Option" CornerRadius="10"
+                    Clicked="SelectBtn_Clicked" TextColor="White" BackgroundColor="#15C7C1" VerticalOptions="FillAndExpand"/>
             <ListView Grid.Row="1" x:Name="listView" HasUnevenRows="True" IsVisible="false">
                 <ListView.ItemTemplate>
                     <DataTemplate>

+ 7 - 1
prs.mobile/comal.timesheets/DigitalForms/CustomUserControls/CustomPickeriOS.xaml.cs

@@ -44,7 +44,7 @@ namespace comal.timesheets
             selectBtn.BackgroundColor = color;
         }
 
-        public void AddItems(List<string> items)
+        public void AddItems(List<string> items, string defaultText = "")
         {
             foreach (string s in items)
             {
@@ -53,6 +53,12 @@ namespace comal.timesheets
                 Options.Add(option);
             }
             listView.ItemsSource = Options;
+
+            if (!string.IsNullOrWhiteSpace(defaultText))
+            {
+                selectBtn.Text = defaultText;
+                SelectedItem = defaultText;
+            }
         }
 
         void SelectBtn_Clicked(object sender, EventArgs e)

+ 4 - 4
prs.mobile/comal.timesheets/JobDocsFilterPage.xaml

@@ -32,22 +32,22 @@
                     <RowDefinition Height="auto"/>
                 </Grid.RowDefinitions>
 
-                <Label Grid.Row="0" FontSize="Medium" HorizontalOptions="Center" FontAttributes="Bold"
+                <Label Grid.Row="0" FontSize="Medium" HorizontalOptions="Center" FontAttributes="Bold" Margin="5, 10, 5, 0"
                 Text="Discipline"/>
                 <timesheets:CustomPickeriOS Grid.Row="1" Margin="5"
                                         x:Name="disciplinePicker"/>
 
-                <Label Grid.Row="2" FontSize="Medium" HorizontalOptions="Center" FontAttributes="Bold"
+                <Label Grid.Row="2" FontSize="Medium" HorizontalOptions="Center" FontAttributes="Bold" Margin="0"
                 Text="Type"/>
                 <timesheets:CustomPickeriOS Grid.Row="3" Margin="5"
                                         x:Name="typePicker"/>
 
-                <Label Grid.Row="4" FontSize="Medium" HorizontalOptions="Center" FontAttributes="Bold"
+                <Label Grid.Row="4" FontSize="Medium" HorizontalOptions="Center" FontAttributes="Bold" Margin="0"
                 Text="Category"/>
                 <timesheets:CustomPickeriOS Grid.Row="5" Margin="5"
                                         x:Name="categoryPicker"/>
 
-                <Label Grid.Row="6" FontSize="Medium" HorizontalOptions="Center" FontAttributes="Bold"
+                <Label Grid.Row="6" FontSize="Medium" HorizontalOptions="Center" FontAttributes="Bold" Margin="0"
                 Text="Area"/>
                 <timesheets:CustomPickeriOS Grid.Row="7" Margin="5"
                                         x:Name="areaPicker"/>

+ 12 - 5
prs.mobile/comal.timesheets/JobDocsFilterPage.xaml.cs

@@ -23,13 +23,15 @@ namespace comal.timesheets
         List<string> Types = new List<string>();
         List<string> Categories = new List<string>();
         List<string> Areas = new List<string>();
+        Dictionary<JobDocFilterType, string> Filters = new Dictionary<JobDocFilterType, string>();
 
         public event JobDocFiltersPicked OnJobDocFiltersPicked;
-        public JobDocsFilterPage(Guid jobid)
+        public JobDocsFilterPage(Guid jobid, Dictionary<JobDocFilterType, string> filters)
         {
             InitializeComponent();
             NavigationPage.SetHasBackButton(this, false);
             JobID = jobid;
+            Filters = filters;
             LoadFilters();
         }
 
@@ -76,10 +78,15 @@ namespace comal.timesheets
 
         private void PopulateLists()
         {
-            disciplinePicker.AddItems(Disciplines);
-            typePicker.AddItems(Types);
-            categoryPicker.AddItems(Categories);
-            areaPicker.AddItems(Areas);
+            disciplinePicker.AddItems(Disciplines, CheckNotBlank(JobDocFilterType.Discipline));
+            typePicker.AddItems(Types, CheckNotBlank(JobDocFilterType.Type));
+            categoryPicker.AddItems(Categories, CheckNotBlank(JobDocFilterType.Category));
+            areaPicker.AddItems(Areas, CheckNotBlank(JobDocFilterType.Area));
+        }
+
+        private string CheckNotBlank(JobDocFilterType type)
+        {
+            return Filters.ContainsKey(type) ? Filters[type] : "";
         }
 
         private void CategoriseTag(JobDocumentSetTag tag)

+ 0 - 1
prs.mobile/comal.timesheets/Main/MainPageUtils.cs

@@ -17,7 +17,6 @@ using Plugin.LocalNotification;
 using comal.timesheets.Tasks;
 using System.IO;
 using static comal.timesheets.CustomControls.JobShell;
-using static Android.Graphics.Paint;
 using static InABox.Mobile.LocationServices;
 
 namespace comal.timesheets

+ 2 - 2
prs.mobile/comal.timesheets/Site/JobDocViewer.xaml

@@ -22,7 +22,7 @@
             <Grid RowSpacing="0">
                 <Grid.RowDefinitions>
                     <RowDefinition Height="auto"/>
-                    <RowDefinition Height="45"/>
+                    <RowDefinition Height="65"/>
                     <RowDefinition Height="auto"/>
                     <RowDefinition Height="*"/>
                 </Grid.RowDefinitions>
@@ -85,7 +85,7 @@
                                     AlignItems="Start"
                                     AlignContent="Start"/>
 
-                        <Image Grid.Column="2" Source="filter.png"
+                        <Image Grid.Column="2" Source="filter.png" IsEnabled="False" x:Name="filterBtn"
                                HorizontalOptions="Center" VerticalOptions="Center" HeightRequest="40" WidthRequest="40">
                             <Image.GestureRecognizers>
                                 <TapGestureRecognizer Tapped="FilterButton_Tapped"/>

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

@@ -33,6 +33,7 @@ namespace comal.timesheets
         bool foldersLoaded = false;
         bool filesLoaded = false;
         bool specificQueryLoading = false;
+        Dictionary<JobDocFilterType, string> filters = new Dictionary<JobDocFilterType, string>();
         Guid jobID = Guid.Empty;
         List<Guid> loadedFolders = new List<Guid>();
         List<MileStoneShell> mileStoneShells = new List<MileStoneShell>();
@@ -67,7 +68,7 @@ namespace comal.timesheets
 
         private void FilterButton_Tapped(object sender, EventArgs e)
         {
-            var page = new JobDocsFilterPage(jobID);
+            var page = new JobDocsFilterPage(jobID, filters);
             page.OnJobDocFiltersPicked += Page_OnJobDocFiltersPicked;
             Navigation.PushAsync(page);
         }
@@ -75,32 +76,126 @@ namespace comal.timesheets
         private void Page_OnJobDocFiltersPicked(string discipline, string type, string category, string area)
         {
             filterLayout.Children.Clear();
+            filteredShells.Clear();
+            filters.Clear();
 
             if (!string.IsNullOrWhiteSpace(discipline))
                 AddFilter(discipline, JobDocFilterType.Discipline);
             if (!string.IsNullOrWhiteSpace(type))
                 AddFilter(type, JobDocFilterType.Type);
-            if (!string.IsNullOrWhiteSpace(discipline))
+            if (!string.IsNullOrWhiteSpace(category))
                 AddFilter(category, JobDocFilterType.Category);
             if (!string.IsNullOrWhiteSpace(area))
                 AddFilter(area, JobDocFilterType.Area);
+
+            DisplayFolderContents();
         }
 
         private void AddFilter(string text, JobDocFilterType type)
         {
+            if (!filters.ContainsKey(type))
+                filters.Add(type, text);
+
             JobDocFilterItem item = new JobDocFilterItem();
             item.Init(text, type);
-            item.OnJobDocFilterClosed += ((filter, type) => 
+            item.OnJobDocFilterClosed += ((filter, type) =>
             {
                 filterLayout.Children.Remove(item);
+                filters.Remove(type);
+                RemoveShells(filter, type);
+                DisplayFolderContents();
             });
             filterLayout.Children.Add(item);
+
+            FilterList(text, type);
+        }
+
+        private void FilterList(string text, JobDocFilterType type)
+        {
+            if (type == JobDocFilterType.Discipline)
+            {
+                var list = fullListShells.Where(x => x.DocSetDiscipline.Equals(text));
+                foreach (var v in list)
+                    CheckDuplicateAndAdd(v);
+            }
+            else if (type == JobDocFilterType.Type)
+            {
+                var list = fullListShells.Where(x => x.DocSetType.Equals(text));
+                foreach (var v in list)
+                    CheckDuplicateAndAdd(v);
+            }
+            else if (type == JobDocFilterType.Category)
+            {
+                var list = fullListShells.Where(x => x.DocSetCategory.Equals(text));
+                foreach (var v in list)
+                    CheckDuplicateAndAdd(v);
+            }
+            else if (type == JobDocFilterType.Area)
+            {
+                var list = fullListShells.Where(x => x.DocSetArea.Equals(text));
+                foreach (var v in list)
+                    CheckDuplicateAndAdd(v);
+            }
+        }
+
+        private void CheckDuplicateAndAdd(JobDocSetFileShell v)
+        {
+            var duplicate = filteredShells.FirstOrDefault(x => x.ID == v.ID);
+            if (duplicate == null)
+                filteredShells.Add(v);
+        }
+
+        private void RemoveShells(string filter, JobDocFilterType type)
+        {
+            if (type == JobDocFilterType.Discipline)
+            {
+                while (filteredShells.Find(x => x.DocSetDiscipline == filter) != null)
+                {
+                    var shell = filteredShells.FirstOrDefault(x => x.DocSetDiscipline == filter);
+                    filteredShells.Remove(shell);
+                }
+            }
+            else if (type == JobDocFilterType.Type)
+            {
+                while (filteredShells.Find(x => x.DocSetType == filter) != null)
+                {
+                    var shell = filteredShells.FirstOrDefault(x => x.DocSetType == filter);
+                    filteredShells.Remove(shell);
+                }
+            }
+            else if (type == JobDocFilterType.Category)
+            {
+                while (filteredShells.Find(x => x.DocSetCategory == filter) != null)
+                {
+                    var shell = filteredShells.FirstOrDefault(x => x.DocSetCategory == filter);
+                    filteredShells.Remove(shell);
+                }
+            }
+            else if (type == JobDocFilterType.Area)
+            {
+                while (filteredShells.Find(x => x.DocSetArea == filter) != null)
+                {
+                    var shell = filteredShells.FirstOrDefault(x => x.DocSetArea == filter);
+                    filteredShells.Remove(shell);
+                }
+            }
         }
         #endregion
 
         #region TreeView / Folder Interaction
         void Folder_Tapped(object sender, EventArgs e)
         {
+            DisplayFolderContents();
+        }
+
+        private void DisplayFolderContents()
+        {
+            if (treeView.SelectedItem == null)
+            {
+                DisplayAlert("Info", "Please select a folder or All folders", "OK");
+                return;
+            }
+
             var folder = treeView.SelectedItem as FolderViewItem;
             if (folder.Documents == 0)
                 return;
@@ -112,12 +207,23 @@ namespace comal.timesheets
             {
                 if (folder.ItemName == "All")
                 {
-                    AddSearchItems(fullListShells);
+                    if (filters.Count != 0)
+                        AddSearchItems(filteredShells);
+                    else
+                        AddSearchItems(fullListShells);
                 }
                 else
                 {
-                    var list = fullListShells.Where(x => x.FolderID == folder.ID);
-                    AddSearchItems(list);
+                    if (filters.Count != 0)
+                    {
+                        var list = filteredShells.Where(x => x.FolderID == folder.ID);
+                        AddSearchItems(list);
+                    }
+                    else
+                    {
+                        var list = fullListShells.Where(x => x.FolderID == folder.ID);
+                        AddSearchItems(list);
+                    }
                 }
             }
             else if (loadedFolders.Contains(folder.ID))
@@ -233,6 +339,7 @@ namespace comal.timesheets
             displayList = new ObservableCollection<FolderViewItem>(displayList.OrderBy(x => x.ItemName));
             treeView.ItemsSource = displayList;
             foldersLoaded = true;
+            filterBtn.IsEnabled = true;
         }
 
         private async void LoadFiles(Filter<JobDocumentSetMileStone> filter, bool specificQuery = false, Guid loadFolder = new Guid())
@@ -312,6 +419,7 @@ namespace comal.timesheets
             CoreTable table = new Client<JobDocumentSetMileStoneFile>().Query(
                 filter,
                 new Columns<JobDocumentSetMileStoneFile>(
+                    x => x.ID,
                     x => x.DocumentLink.ID,
                     x => x.Thumbnail,
                     x => x.DocumentLink.FileName,
@@ -347,9 +455,10 @@ namespace comal.timesheets
         {
             JobDocSetFileShell file = new JobDocSetFileShell
             {
-                DocLinkID = filerow.Get<Guid>("DocumentLink.ID"),
-                FileName = filerow.Get<string>("DocumentLink.FileName"),
-                MileStoneID = filerow.Get<Guid>("EntityLink.ID")
+                ID = filerow.Get<JobDocumentSetMileStoneFile, Guid>(x => x.ID),
+                DocLinkID = filerow.Get<JobDocumentSetMileStoneFile, Guid>(x => x.DocumentLink.ID),
+                FileName = filerow.Get<JobDocumentSetMileStoneFile, string>(x => x.DocumentLink.FileName),
+                MileStoneID = filerow.Get<JobDocumentSetMileStoneFile, Guid>(x => x.EntityLink.ID)
             };
 
             MileStoneShell mileStone = mileStoneShells.Find(x => x.ID == file.MileStoneID);
@@ -589,6 +698,7 @@ namespace comal.timesheets
 
     public class JobDocSetFileShell
     {
+        public Guid ID { get; set; }
         public Guid DocLinkID { get; set; }
         public string FileName { get; set; }
         public string FolderName { get; set; }
@@ -610,6 +720,7 @@ namespace comal.timesheets
 
         public JobDocSetFileShell()
         {
+            ID = Guid.Empty;
             DocLinkID = Guid.Empty;
             FileName = "";
             FolderName = "";

+ 1 - 1
prs.server/PRSServer.iss

@@ -5,7 +5,7 @@
 #pragma verboselevel 9
 
 #define MyAppName "PRS Server"
-#define MyAppVersion "7.06"
+#define MyAppVersion "7.07"
 #define MyAppPublisher "PRS Digital"
 #define MyAppURL "https://www.prs-software.com.au"
 #define MyAppExeName "PRSServer.exe"