WIP estimate

This commit is contained in:
2016-11-25 17:57:49 +01:00
parent 5d98c1d306
commit becbd75705
8 changed files with 42 additions and 17 deletions

View File

@ -63,4 +63,8 @@
<uses-permission android:name="android.permission.PERSISTENT_ACTIVITY" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_SOCIAL_STREAM" />
</manifest>

View File

@ -258,11 +258,12 @@ namespace BookAStar
masterDetail.ToolbarItems.Add(tiSetts);
masterDetail.ToolbarItems.Add(tiPubChat);
this.MainPage = masterDetail;
NavigationService = new NavigationService(masterDetail.Detail.Navigation);
}
public static Task<string> DisplayActionSheet(string title, string cancel, string destruction, string [] buttons)
{
var currentPage = ((NavigationPage)Current.MainPage).CurrentPage;
var currentPage = CurrentApp.masterDetail.Detail.Navigation.NavigationStack.Last();
return currentPage.DisplayActionSheet(title, cancel, destruction, buttons);
}

View File

@ -29,9 +29,9 @@
<maps:Map x:Name="map" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"></maps:Map>
<StackLayout Orientation="Horizontal">
<Button Text="{x:Static local:Strings.ViewEstimate}"
BorderRadius="10" BorderWidth="2" BorderColor="Aqua" x:Name ="btn"
BorderRadius="50" BorderWidth="2" BorderColor="Aqua" x:Name ="btn"
IsEnabled="{Binding EstimationDone}"
Clicked="OnViewEstimate" Image="exclam.png"/>
Clicked="OnViewEstimate" Image="exclam.png" />
<Button Text="{Binding EditEstimateButtonText}" Clicked="OnEditEstimate" />
</StackLayout>
</StackLayout>

View File

@ -92,11 +92,18 @@ namespace BookAStar.Pages
}
private void OnViewEstimate(object sender, EventArgs ev)
private async void OnViewEstimate(object sender, EventArgs ev)
{
var bookQueryViewModel = (BookQueryViewModel) BindingContext;
App.NavigationService.NavigateTo<ViewEstimatePage>(true,
new EditEstimateViewModel(bookQueryViewModel.Estimate));
var buttons = bookQueryViewModel.Estimates.Select(e => $"{e.Id} / {e.Title} / {e.Total}").ToArray();
var action = await App.DisplayActionSheet("Estimations validées", "Annuler", null, buttons);
if (buttons.Contains(action))
{
var index = Array.IndexOf(buttons,action);
var estimate = bookQueryViewModel.Estimates[index];
App.NavigationService.NavigateTo<ViewEstimatePage>(true,
new EditEstimateViewModel(estimate));
}
}
protected override void OnSizeAllocated(double width, double height)

View File

@ -102,12 +102,12 @@
Converter={StaticResource boolToStyleImage}}" />
</StackLayout>
<StackLayout Orientation="Horizontal">
<Button Text="Supprimer"
Command="{Binding DeleteCommand}"
Clicked="OnDeleteClicked"></Button>
<Button Text="Términé"
Command="{Binding ValidateCommand}"
Clicked="OnValidateClicked"></Button>
<Button Text="Supprimer"
Command="{Binding DeleteCommand}"
Clicked="OnDeleteClicked"></Button>
</StackLayout>
</StackLayout>
</ScrollView>

View File

@ -49,6 +49,7 @@ namespace BookAStar.Pages
bill.Add(com);
DataManager.Current.EstimationCache.SaveEntity();
})};
lineView.PropertyChanged += LineView_PropertyChanged;
App.NavigationService.NavigateTo<EditBillingLinePage>(
true, lineView );
}
@ -62,11 +63,14 @@ namespace BookAStar.Pages
DataManager.Current.EstimationCache.SaveEntity();
})
};
lineView.PropertyChanged += LineView_PropertyChanged;
lineView.PropertyChanged += LineView_PropertyChanged;
App.NavigationService.NavigateTo<EditBillingLinePage>(
true, lineView );
}
private void LineView_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
DataManager.Current.EstimationCache.SaveEntity();

View File

@ -10,6 +10,7 @@ namespace BookAStar.ViewModels.EstimateAndBilling
using Model;
using Model.Social;
using Model.Workflow;
using System.Collections.ObjectModel;
using System.Linq;
class BookQueryViewModel : ViewModel, IBookQueryData
@ -26,6 +27,10 @@ namespace BookAStar.ViewModels.EstimateAndBilling
EventDate = data.EventDate;
Previsionnal = data.Previsionnal;
Id = data.Id;
estimates = new ObservableCollection<Estimate>(
DataManager.Current.Estimates.Where(
e => e.Query.Id == Id
));
this.data = data;
}
private BookQueryData data;
@ -47,19 +52,17 @@ namespace BookAStar.ViewModels.EstimateAndBilling
return DataManager.Current.EstimationCache.LocalGet(this.Id);
}
}
public Estimate Estimate { get
{
return DataManager.Current.Estimates.FirstOrDefault(
e=>e.Query.Id == Id
);
private ObservableCollection<Estimate> estimates;
public ObservableCollection<Estimate> Estimates {
get {
return estimates;
} }
public bool EstimationDone
{
get
{
return Estimate != null;
return Estimates != null && Estimates.Count>0;
}
}

View File

@ -32,10 +32,11 @@ namespace BookAStar.ViewModels.EstimateAndBilling
{
Data.Bill = new List<BillingLine>( Bill );
NotifyPropertyChanged("FormattedTotal");
NotifyPropertyChanged("Bill");
}
private Estimate data;
public Estimate Data { get { return data; } set {
data = value;
SetProperty<Estimate>(ref data, value);
if (data.AttachedFiles == null) data.AttachedFiles = new List<string>();
if (data.AttachedGraphics == null) data.AttachedGraphics = new List<string>();
if (data.Bill == null) data.Bill = new List<BillingLine>();
@ -43,6 +44,11 @@ namespace BookAStar.ViewModels.EstimateAndBilling
AttachedGraphicList = new ObservableCollection<string>(data.AttachedGraphics);
Bill = new ObservableCollection<BillingLine>(data.Bill);
Bill.CollectionChanged += Bill_CollectionChanged;
Title = Data.Title;
Description = Data.Description;
NotifyPropertyChanged("FormattedTotal");
NotifyPropertyChanged("Query");
NotifyPropertyChanged("CLient");
} }
[JsonIgnore]