Fixes the estimation total

main
Paul Schneider 9 years ago
parent dc8dba47c8
commit 90bc2ddc2e
9 changed files with 54 additions and 47 deletions

@ -24,6 +24,7 @@
<Color x:Key="BackgroundColor">#30AAAAFA</Color> <Color x:Key="BackgroundColor">#30AAAAFA</Color>
<Color x:Key="LabelBackgroundColor">#30FAFAFA</Color>
<Color x:Key="OddColor">#207AFAFA</Color> <Color x:Key="OddColor">#207AFAFA</Color>
<Color x:Key="TextColor">#FF103010</Color> <Color x:Key="TextColor">#FF103010</Color>
<Color x:Key="LabelColor">#FF303010</Color> <Color x:Key="LabelColor">#FF303010</Color>
@ -44,8 +45,11 @@
</Style> </Style>
<Style x:Key="LabelStyle" TargetType="Label"> <Style x:Key="LabelStyle" TargetType="Label">
<Setter Property="TextColor" Value="{StaticResource TextColor}" /> <Setter Property="TextColor" Value="{StaticResource LabelColor}" />
<Setter Property="BackgroundColor" Value="{StaticResource LabelBackgroundColor}" />
<Setter Property="LineBreakMode" Value="WordWrap" /> <Setter Property="LineBreakMode" Value="WordWrap" />
<Setter Property="Margin" Value="2,4,2,4" />
</Style> </Style>
<Style x:Key="BigLabel" BasedOn="{StaticResource LabelStyle}" TargetType="Label"> <Style x:Key="BigLabel" BasedOn="{StaticResource LabelStyle}" TargetType="Label">
@ -73,8 +77,8 @@
<Setter Property="HorizontalOptions" Value="Center" /> <Setter Property="HorizontalOptions" Value="Center" />
<Setter Property="VerticalOptions" Value="CenterAndExpand" /> <Setter Property="VerticalOptions" Value="CenterAndExpand" />
<Setter Property="BorderColor" Value="Lime" /> <Setter Property="BorderColor" Value="Lime" />
<Setter Property="BorderRadius" Value="5" /> <Setter Property="BorderRadius" Value="15" />
<Setter Property="BorderWidth" Value="5" /> <Setter Property="BorderWidth" Value="10" />
<Setter Property="WidthRequest" Value="200" /> <Setter Property="WidthRequest" Value="200" />
<Setter Property="TextColor" Value="Teal" /> <Setter Property="TextColor" Value="Teal" />
</Style> </Style>
@ -83,6 +87,8 @@
<Setter Property="Padding" Value="5,5,5,5" /> <Setter Property="Padding" Value="5,5,5,5" />
<Setter Property="BackgroundColor" Value="{StaticResource PageBackgroundColor}" /> <Setter Property="BackgroundColor" Value="{StaticResource PageBackgroundColor}" />
</Style> </Style>
</ResourceDictionary> </ResourceDictionary>
</Application.Resources> </Application.Resources>
</Application> </Application>

@ -10,7 +10,9 @@ namespace BookAStar
public class LocalEntity<V, K> : ObservableCollection<V>, ILocalEntity<V, K> where K : IEquatable<K> public class LocalEntity<V, K> : ObservableCollection<V>, ILocalEntity<V, K> where K : IEquatable<K>
{ {
public V CurrentItem { get; protected set; } public V CurrentItem { get; protected set; }
public Func<V, K> GetKey { get; set; } public Func<V, K> GetKey { get; set; }
public LocalEntity(Func<V, K> getKey) : base() public LocalEntity(Func<V, K> getKey) : base()
{ {
if (getKey == null) throw new InvalidOperationException(); if (getKey == null) throw new InvalidOperationException();
@ -28,6 +30,7 @@ namespace BookAStar
Add(item); Add(item);
CurrentItem = item; CurrentItem = item;
} }
public V LocalGet(K key) public V LocalGet(K key)
{ {
CurrentItem = this.Single(x => GetKey(x).Equals(key)); CurrentItem = this.Single(x => GetKey(x).Equals(key));
@ -38,6 +41,11 @@ namespace BookAStar
{ {
this.Populate<V>(); this.Populate<V>();
} }
public void Load(string subKey)
{
this.Populate<V>(subKey);
}
} }
} }

@ -33,7 +33,6 @@ namespace BookAStar
#region Setting Constants #region Setting Constants
public static readonly string SettingsDefault = string.Empty; public static readonly string SettingsDefault = string.Empty;
public static readonly string EntityDataSettingsPrefix = "Ed"; public static readonly string EntityDataSettingsPrefix = "Ed";
public static readonly string EntityCursorSettingsPrefix = "Ec";
private const string userNameKey = "user_id"; private const string userNameKey = "user_id";
private const string PushNotificationsKey = "pushNotifs"; private const string PushNotificationsKey = "pushNotifs";
private const string AllowGPSUsageKey = "allowGPSUsage"; private const string AllowGPSUsageKey = "allowGPSUsage";

@ -5,9 +5,9 @@ namespace BookAStar.Model.Interfaces
{ {
public interface IEstimate public interface IEstimate
{ {
List<string> AttachedFiles { get; set; } IList<string> AttachedFiles { get; set; }
List<string> AttachedGraphics { get; } IList<string> AttachedGraphics { get; }
List<BillingLine> Bill { get; set; } IList<BillingLine> Bill { get; set; }
string ClientId { get; set; } string ClientId { get; set; }
long? CommandId { get; set; } long? CommandId { get; set; }
string CommandType { get; set; } string CommandType { get; set; }

@ -7,6 +7,11 @@ namespace BookAStar
void Load(); void Load();
} }
public interface IPersistentOnDemand : ILoadable
{
void Save();
}
public interface ILocalEntity<V, K> : ILoadable where K : IEquatable<K> public interface ILocalEntity<V, K> : ILoadable where K : IEquatable<K>
{ {
V CurrentItem { get; } V CurrentItem { get; }

@ -14,7 +14,7 @@ namespace BookAStar.Model.Workflow
public string Description { get; set; } public string Description { get; set; }
public int? Status { get; set; } public int? Status { get; set; }
public string Title { get; set; } public string Title { get; set; }
public List<BillingLine> Bill { get; set; } public IList<BillingLine> Bill { get; set; }
/// <summary> /// <summary>
/// List of attached graphic files /// List of attached graphic files
/// to this estimate, as relative pathes to /// to this estimate, as relative pathes to
@ -22,7 +22,7 @@ namespace BookAStar.Model.Workflow
/// In db, they are separated by <c>:</c> /// In db, they are separated by <c>:</c>
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public List<string> AttachedGraphics { get; set; } public IList<string> AttachedGraphics { get; set; }
public string AttachedGraphicsString public string AttachedGraphicsString
{ {
@ -36,7 +36,7 @@ namespace BookAStar.Model.Workflow
/// In db, they are separated by <c>:</c> /// In db, they are separated by <c>:</c>
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public List<string> AttachedFiles { get; set; } public IList<string> AttachedFiles { get; set; }
public string AttachedFilesString public string AttachedFilesString
{ {
get { return AttachedFiles == null ? null : string.Join(":", AttachedFiles); } get { return AttachedFiles == null ? null : string.Join(":", AttachedFiles); }

@ -37,8 +37,9 @@
></views:MarkdownView> ></views:MarkdownView>
<ListView x:Name="BillListView" ItemsSource="{Binding Bill}" > <ListView x:Name="BillListView" ItemsSource="{Binding Bill}"
<ListView.ItemTemplate RowHeight="20"> VerticalOptions="End" MinimumHeightRequest="30" >
<ListView.ItemTemplate>
<DataTemplate > <DataTemplate >
<ViewCell> <ViewCell>
<ViewCell.View> <ViewCell.View>
@ -54,51 +55,20 @@
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Label Text="{Binding Description}" <Label Text="{Binding Description}"
Grid.Row="0" Grid.Column="0" ></Label> Grid.Row="0" Grid.Column="0" ></Label>
<Label Text="{Binding Duration}" <Label Text="{Binding Duration, StringFormat=\{0\}}"
Grid.Row="0" Grid.Column="1" ></Label> Grid.Row="0" Grid.Column="1" ></Label>
<Label Text="{Binding Count}" <Label Text="{Binding Count}"
Grid.Row="0" Grid.Column="2" ></Label> Grid.Row="0" Grid.Column="2" ></Label>
<Label Text="{Binding UnitaryCost}" <Label Text="{Binding UnitaryCost}"
Grid.Row="0" Grid.Column="3" ></Label> Grid.Row="0" Grid.Column="3"
FontFamily="Monospace"></Label>
</Grid> </Grid>
</ViewCell.View> </ViewCell.View>
</ViewCell> </ViewCell>
</DataTemplate> </DataTemplate>
</ListView.ItemTemplate> </ListView.ItemTemplate>
</ListView> </ListView>
<!--
<ListView x:Name="BillListView" View.VerticalOptions="End"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height Factor=.4}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}">
<ListView.ItemTemplate RowHeight="20">
<DataTemplate >
<ViewCell>
<ViewCell.View>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="30" />
<ColumnDefinition Width="90" />
</Grid.ColumnDefinitions>
<Label Text="{Binding Description}"
Grid.Row="0" Grid.Column="0" ></Label>
<Label Text="{Binding Duration}"
Grid.Row="0" Grid.Column="1" ></Label>
<Label Text="{Binding Count}"
Grid.Row="0" Grid.Column="2" ></Label>
<Label Text="{Binding UnitaryCost}"
Grid.Row="0" Grid.Column="3" ></Label>
</Grid>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView> -->
<Button Text="Ajouter une ligne de facture" Clicked="OnNewCommanLine"></Button> <Button Text="Ajouter une ligne de facture" Clicked="OnNewCommanLine"></Button>
<Label FormattedText="{Binding FormattedTotal}"/> <Label FormattedText="{Binding FormattedTotal}"/>
<Button Text="Valider ce devis"></Button> <Button Text="Valider ce devis"></Button>

@ -25,6 +25,18 @@ namespace BookAStar.Pages
BindingContext = model; BindingContext = model;
} }
protected override void OnBindingContextChanged()
{
base.OnBindingContextChanged();
((EditEstimateViewModel)BindingContext).PropertyChanged += EditEstimatePage_PropertyChanged;
}
private void EditEstimatePage_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
}
protected void OnNewCommanLine(object sender, EventArgs e) protected void OnNewCommanLine(object sender, EventArgs e)
{ {
var com = new BillingLine() { Count = 1, UnitaryCost = 0.01m }; var com = new BillingLine() { Count = 1, UnitaryCost = 0.01m };

@ -18,6 +18,13 @@ namespace BookAStar.ViewModels
AttachedFiles = new ObservableCollection<string>(data.AttachedFiles); AttachedFiles = new ObservableCollection<string>(data.AttachedFiles);
AttachedGraphicList = new ObservableCollection<string>(data.AttachedGraphics); AttachedGraphicList = new ObservableCollection<string>(data.AttachedGraphics);
Bill = new ObservableCollection<BillingLine>(data.Bill); Bill = new ObservableCollection<BillingLine>(data.Bill);
Bill.CollectionChanged += Bill_CollectionChanged;
}
private void Bill_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
Data.Bill = Bill;
NotifyPropertyChanged("FormattedTotal");
} }
public Estimate Data { get; protected set; } public Estimate Data { get; protected set; }

Loading…