fixes edition cache
This commit is contained in:
parent
8abec56e8a
commit
5dea4ee707
24 changed files with 269 additions and 102 deletions
|
|
@ -9,7 +9,7 @@ using XLabs.Forms.Mvvm;
|
|||
|
||||
namespace BookAStar.ViewModels
|
||||
{
|
||||
public class BillingLineViewModel : ViewModel, IBillingLine
|
||||
public class BillingLineViewModel : EditingViewModel, IBillingLine
|
||||
{
|
||||
BillingLine data;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using BookAStar.Interfaces;
|
||||
using BookAStar.Data;
|
||||
using BookAStar.Interfaces;
|
||||
using BookAStar.Model;
|
||||
using BookAStar.Model.Social;
|
||||
using System;
|
||||
|
|
@ -23,11 +24,34 @@ namespace BookAStar.ViewModels
|
|||
Location = data.Location;
|
||||
EventDate = data.EventDate;
|
||||
Previsionnal = data.Previsionnal;
|
||||
Id = data.Id;
|
||||
this.data = data;
|
||||
}
|
||||
private BookQueryData data;
|
||||
public BookQueryData Data {
|
||||
get
|
||||
{
|
||||
return data;
|
||||
}
|
||||
}
|
||||
public ClientProviderInfo Client { get; set; }
|
||||
public Location Location { get; set; }
|
||||
public long Id { get; set; }
|
||||
public DateTime EventDate { get; set; }
|
||||
public decimal? Previsionnal { get; set; }
|
||||
public EditEstimateViewModel DraftEstimate
|
||||
{
|
||||
get
|
||||
{
|
||||
return DataManager.Current.EstimationCache.LocalGet(this.Id);
|
||||
}
|
||||
}
|
||||
public string EditEstimateButtonText
|
||||
{
|
||||
get
|
||||
{
|
||||
return DraftEstimate != null ? "Editer le devis" : "Faire un devis" ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +1,32 @@
|
|||
using System.Collections.Generic;
|
||||
using XLabs.Forms.Mvvm;
|
||||
using BookAStar.Model.Workflow;
|
||||
using System.Collections.ObjectModel;
|
||||
using BookAStar.Model;
|
||||
using Xamarin.Forms;
|
||||
using BookAStar.Data;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace BookAStar.ViewModels
|
||||
{
|
||||
public class EditEstimateViewModel : ViewModel
|
||||
public class EditEstimateViewModel : EditingViewModel
|
||||
{
|
||||
public EditEstimateViewModel(Estimate data)
|
||||
/// <summary>
|
||||
/// For deserialization
|
||||
/// </summary>
|
||||
public EditEstimateViewModel()
|
||||
{
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Builds a new view model on estimate,
|
||||
/// sets <c>Data</c> with given value parameter
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="localState"></param>
|
||||
public EditEstimateViewModel(Estimate data, LocalState localState )
|
||||
{
|
||||
Data = data;
|
||||
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>();
|
||||
AttachedFiles = new ObservableCollection<string>(data.AttachedFiles);
|
||||
AttachedGraphicList = new ObservableCollection<string>(data.AttachedGraphics);
|
||||
Bill = new ObservableCollection<BillingLine>(data.Bill);
|
||||
Bill.CollectionChanged += Bill_CollectionChanged;
|
||||
State = localState;
|
||||
}
|
||||
|
||||
private void Bill_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
||||
|
|
@ -26,19 +34,31 @@ namespace BookAStar.ViewModels
|
|||
Data.Bill = Bill;
|
||||
NotifyPropertyChanged("FormattedTotal");
|
||||
}
|
||||
private Estimate data;
|
||||
public Estimate Data { get { return data; } set {
|
||||
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>();
|
||||
AttachedFiles = new ObservableCollection<string>(data.AttachedFiles);
|
||||
AttachedGraphicList = new ObservableCollection<string>(data.AttachedGraphics);
|
||||
Bill = new ObservableCollection<BillingLine>(data.Bill);
|
||||
Bill.CollectionChanged += Bill_CollectionChanged;
|
||||
} }
|
||||
|
||||
public Estimate Data { get; protected set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public ObservableCollection<string> AttachedFiles
|
||||
{
|
||||
get; protected set;
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public ObservableCollection<string> AttachedGraphicList
|
||||
{
|
||||
get; protected set;
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public ObservableCollection<BillingLine> Bill
|
||||
{
|
||||
get; protected set;
|
||||
|
|
@ -46,6 +66,7 @@ namespace BookAStar.ViewModels
|
|||
|
||||
|
||||
string newDesc;
|
||||
[JsonIgnore]
|
||||
public string Description
|
||||
{
|
||||
get
|
||||
|
|
@ -61,6 +82,7 @@ namespace BookAStar.ViewModels
|
|||
}
|
||||
|
||||
private int? status;
|
||||
[JsonIgnore]
|
||||
public int? Status
|
||||
{
|
||||
get
|
||||
|
|
@ -75,6 +97,7 @@ namespace BookAStar.ViewModels
|
|||
}
|
||||
}
|
||||
private string title;
|
||||
[JsonIgnore]
|
||||
public string Title
|
||||
{
|
||||
get
|
||||
|
|
@ -89,10 +112,13 @@ namespace BookAStar.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public ClientProviderInfo Client { get { return Data.Client; } }
|
||||
|
||||
[JsonIgnore]
|
||||
public BookQueryData Query { get { return Data.Query; } }
|
||||
|
||||
[JsonIgnore]
|
||||
public FormattedString FormattedTotal
|
||||
{
|
||||
get
|
||||
|
|
|
|||
29
BookAStar/BookAStar/ViewModels/EditingViewModel.cs
Normal file
29
BookAStar/BookAStar/ViewModels/EditingViewModel.cs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
using BookAStar.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using XLabs.Forms.Mvvm;
|
||||
|
||||
namespace BookAStar.ViewModels
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to make the DataManager know how
|
||||
/// to sync local and remote data
|
||||
/// </summary>
|
||||
public class EditingViewModel: ViewModel
|
||||
{
|
||||
private LocalState state;
|
||||
public LocalState State {
|
||||
get
|
||||
{
|
||||
return state;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.SetProperty<LocalState>(ref state, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue