DeliveryScheduleAdminWindow: Add Attribute, Cultivation and IsCancelled
All checks were successful
Test / Run tests (push) Successful in 1m37s
All checks were successful
Test / Run tests (push) Successful in 1m37s
This commit is contained in:
@ -9,7 +9,7 @@ namespace Elwig.Helpers {
|
||||
public static class AppDbUpdater {
|
||||
|
||||
// Don't forget to update value in Tests/fetch-resources.bat!
|
||||
public static readonly int RequiredSchemaVersion = 28;
|
||||
public static readonly int RequiredSchemaVersion = 29;
|
||||
|
||||
private static int VersionOffset = 0;
|
||||
|
||||
|
@ -32,6 +32,12 @@ namespace Elwig.Models.Entities {
|
||||
[NotMapped]
|
||||
public string Identifier => $"{Date:dd.MM.} - {ZwstId} - {Description}";
|
||||
|
||||
[Column("attrid")]
|
||||
public string? AttrId { get; set; }
|
||||
|
||||
[Column("cultid")]
|
||||
public string? CultId { get; set; }
|
||||
|
||||
[Column("max_weight")]
|
||||
public int? MaxWeight { get; set; }
|
||||
[NotMapped]
|
||||
@ -39,6 +45,9 @@ namespace Elwig.Models.Entities {
|
||||
[NotMapped]
|
||||
public double? Percent => (double)AnnouncedWeight / MaxWeight * 100;
|
||||
|
||||
[Column("cancelled")]
|
||||
public bool IsCancelled { get; set; }
|
||||
|
||||
[Column("ancmt_from")]
|
||||
public long? AncmtFromUnix { get; set; }
|
||||
[NotMapped]
|
||||
@ -61,6 +70,12 @@ namespace Elwig.Models.Entities {
|
||||
[ForeignKey("ZwstId")]
|
||||
public virtual Branch Branch { get; private set; } = null!;
|
||||
|
||||
[ForeignKey("AttrId")]
|
||||
public virtual WineAttr? Attribute { get; private set; }
|
||||
|
||||
[ForeignKey("CultId")]
|
||||
public virtual WineCult? Cultivation { get; private set; }
|
||||
|
||||
[InverseProperty(nameof(DeliveryScheduleWineVar.Schedule))]
|
||||
public virtual ICollection<DeliveryScheduleWineVar> Varieties { get; private set; } = null!;
|
||||
|
||||
|
23
Elwig/Resources/Sql/28-29.sql
Normal file
23
Elwig/Resources/Sql/28-29.sql
Normal file
@ -0,0 +1,23 @@
|
||||
-- schema version 28 to 29
|
||||
|
||||
ALTER TABLE delivery_schedule ADD COLUMN attrid TEXT DEFAULT NULL;
|
||||
ALTER TABLE delivery_schedule ADD COLUMN cultid TEXT DEFAULT NULL;
|
||||
ALTER TABLE delivery_schedule ADD COLUMN cancelled INTEGER NOT NULL CHECK (cancelled IN (TRUE, FALSE)) DEFAULT FALSE;
|
||||
UPDATE delivery_schedule SET cultid = 'B' WHERE UPPER(description) LIKE '%BIO%';
|
||||
UPDATE delivery_schedule SET cancelled = TRUE WHERE zwstid = 'M' AND date IN ('2024-09-14', '2024-09-16');
|
||||
|
||||
PRAGMA writable_schema = ON;
|
||||
|
||||
UPDATE sqlite_schema SET sql = REPLACE(sql, '
|
||||
) STRICT', ',
|
||||
CONSTRAINT fk_delivery_schedule_wine_attribute FOREIGN KEY (attrid) REFERENCES wine_attribute (attrid)
|
||||
ON UPDATE CASCADE
|
||||
ON DELETE RESTRICT,
|
||||
CONSTRAINT fk_delivery_schedule_wine_cultivation FOREIGN KEY (cultid) REFERENCES wine_cultivation (cultid)
|
||||
ON UPDATE CASCADE
|
||||
ON DELETE RESTRICT
|
||||
) STRICT')
|
||||
WHERE type = 'table' AND name = 'delivery_schedule';
|
||||
|
||||
PRAGMA schema_version = 2801;
|
||||
PRAGMA writable_schema = OFF;
|
@ -26,6 +26,7 @@ namespace Elwig.Services {
|
||||
vm.Branch = (Branch?)ControlUtils.GetItemFromSourceWithPk(vm.BranchSource, s.ZwstId);
|
||||
vm.Description = s.Description;
|
||||
vm.MaxWeight = s.MaxWeight;
|
||||
vm.IsCancelled = s.IsCancelled;
|
||||
vm.MainVarieties.Clear();
|
||||
foreach (var v in s.Varieties.Where(v => v.Priority == 1)) {
|
||||
vm.MainVarieties.Add((WineVar)ControlUtils.GetItemFromSourceWithPk(vm.MainVarietiesSource, v.SortId)!);
|
||||
@ -34,6 +35,8 @@ namespace Elwig.Services {
|
||||
foreach (var v in s.Varieties.Where(v => v.Priority != 1)) {
|
||||
vm.OtherVarieties.Add((WineVar)ControlUtils.GetItemFromSourceWithPk(vm.OtherVarietiesSource, v.SortId)!);
|
||||
}
|
||||
vm.Attribute = ControlUtils.GetItemFromSourceWithPk(vm.AttributeSource, s.AttrId) as WineAttr;
|
||||
vm.Cultivation = ControlUtils.GetItemFromSourceWithPk(vm.CultivationSource, s.CultId) as WineCult;
|
||||
vm.AncmtFrom = s.AncmtFrom;
|
||||
vm.AncmtTo = s.AncmtTo?.AddSeconds(-1);
|
||||
}
|
||||
@ -156,7 +159,10 @@ namespace Elwig.Services {
|
||||
DateString = $"{vm.Date:yyyy-MM-dd}",
|
||||
ZwstId = vm.Branch!.ZwstId,
|
||||
Description = vm.Description,
|
||||
AttrId = vm.Attribute?.AttrId,
|
||||
CultId = vm.Cultivation?.CultId,
|
||||
MaxWeight = vm.MaxWeight,
|
||||
IsCancelled = vm.IsCancelled,
|
||||
AncmtFrom = vm.AncmtFrom,
|
||||
AncmtTo = vm.AncmtTo?.AddMinutes(1),
|
||||
};
|
||||
|
@ -47,12 +47,30 @@ namespace Elwig.ViewModels {
|
||||
get => int.TryParse(MaxWeightString, out var w) ? w : null;
|
||||
set => MaxWeightString = $"{value}";
|
||||
}
|
||||
[ObservableProperty]
|
||||
private bool _isCancelled;
|
||||
public ObservableCollection<WineVar> MainVarieties { get; set; } = [];
|
||||
[ObservableProperty]
|
||||
private IEnumerable<WineVar> _mainVarietiesSource = [];
|
||||
public ObservableCollection<WineVar> OtherVarieties { get; set; } = [];
|
||||
[ObservableProperty]
|
||||
private IEnumerable<WineVar> _otherVarietiesSource = [];
|
||||
[ObservableProperty]
|
||||
private IEnumerable<object> _attributeSource = [];
|
||||
[ObservableProperty]
|
||||
private object? _attributeObj;
|
||||
public WineAttr? Attribute {
|
||||
get => AttributeObj as WineAttr;
|
||||
set => AttributeObj = value ?? AttributeSource.FirstOrDefault();
|
||||
}
|
||||
[ObservableProperty]
|
||||
private IEnumerable<object> _cultivationSource = [];
|
||||
[ObservableProperty]
|
||||
private object? _cultivationObj;
|
||||
public WineCult? Cultivation {
|
||||
get => CultivationObj as WineCult;
|
||||
set => CultivationObj = value ?? CultivationSource.FirstOrDefault();
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
private string _ancmtFromDateString = "";
|
||||
|
@ -195,29 +195,34 @@
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="110"/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label Content="Datum/Zwst.:" Margin="10,10,0,10"/>
|
||||
<TextBox x:Name="DateInput" Text="{Binding DateString, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
Margin="0,10,10,10" Width="77" Grid.Column="1" HorizontalAlignment="Left" TextAlignment="Right"
|
||||
Margin="0,10,10,10" Width="77" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Left" TextAlignment="Right"
|
||||
TextChanged="ScheduleDateInput_TextChanged" LostFocus="DateInput_LostFocus"/>
|
||||
<ComboBox x:Name="BranchInput" SelectedItem="{Binding Branch, Mode=TwoWay}" ItemsSource="{Binding BranchSource, Mode=TwoWay}"
|
||||
DisplayMemberPath="Name" TextSearch.TextPath="Name"
|
||||
Margin="82,10,10,10" Width="150" Grid.Column="1" HorizontalAlignment="Left"/>
|
||||
Margin="82,10,10,10" Width="150" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Left"/>
|
||||
|
||||
<Label Content="Beschreibung:" Margin="10,40,0,10"/>
|
||||
<TextBox x:Name="DescriptionInput" Text="{Binding Description, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
Margin="0,40,10,10" Grid.Column="1"
|
||||
Margin="0,40,10,10" Grid.Column="1" Grid.ColumnSpan="2"
|
||||
TextChanged="TextBox_TextChanged"/>
|
||||
|
||||
<Label Content="Max. Gewicht:" Margin="10,70,0,10"/>
|
||||
<ctrl:UnitTextBox x:Name="MaxWeightInput" Unit="kg" Text="{Binding MaxWeightString, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
Margin="0,70,10,10" Grid.Column="1" Width="68" HorizontalAlignment="Left"
|
||||
Margin="0,70,10,10" Grid.Column="1" Grid.ColumnSpan="2" Width="68" HorizontalAlignment="Left"
|
||||
TextChanged="MaxWeightInput_TextChanged"/>
|
||||
|
||||
<CheckBox x:Name="CancelledInput" Content="Abgesagt" IsChecked="{Binding IsCancelled, Mode=TwoWay}"
|
||||
Grid.Column="1" Grid.ColumnSpan="2" Margin="80,75,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"
|
||||
Checked="CheckBox_Changed" Unchecked="CheckBox_Changed"/>
|
||||
|
||||
<Label Content="Sorten:" Margin="10,100,0,10"/>
|
||||
<ctrl:CheckComboBox x:Name="MainWineVarietiesInput" SelectedItems="{Binding MainVarieties}" ItemsSource="{Binding MainVarietiesSource, Mode=TwoWay}"
|
||||
Grid.Column="1" Margin="0,100,10,10"
|
||||
Grid.Column="1" Grid.ColumnSpan="2" Margin="0,100,10,10"
|
||||
Delimiter=", " AllItemsSelectedContent="Alle Sorten" ListDisplayMemberPath="SortId" TextSearch.TextPath="Name">
|
||||
<ctrl:CheckComboBox.ItemTemplateSelector>
|
||||
<ctrl:WineVarietyTemplateSelector/>
|
||||
@ -226,12 +231,20 @@
|
||||
|
||||
<Label Content="Weitere Sorten:" Margin="10,130,0,10"/>
|
||||
<ctrl:CheckComboBox x:Name="OtherWineVarietiesInput" SelectedItems="{Binding OtherVarieties}" ItemsSource="{Binding OtherVarietiesSource, Mode=TwoWay}"
|
||||
Grid.Column="1" Margin="0,130,10,10"
|
||||
Grid.Column="1" Grid.ColumnSpan="2" Margin="0,130,10,10"
|
||||
Delimiter=", " AllItemsSelectedContent="Alle Sorten" ListDisplayMemberPath="SortId" TextSearch.TextPath="Name">
|
||||
<ctrl:CheckComboBox.ItemTemplateSelector>
|
||||
<ctrl:WineVarietyTemplateSelector/>
|
||||
</ctrl:CheckComboBox.ItemTemplateSelector>
|
||||
</ctrl:CheckComboBox>
|
||||
|
||||
<Label Content="Attribut/Bewirt.:" Margin="10,160,0,10"/>
|
||||
<ComboBox x:Name="AttributeInput" SelectedItem="{Binding AttributeObj, Mode=TwoWay}" ItemsSource="{Binding AttributeSource, Mode=TwoWay}"
|
||||
Grid.Column="1" Margin="0,160,5,10"
|
||||
DisplayMemberPath="Name"/>
|
||||
<ComboBox x:Name="CultivationInput" SelectedItem="{Binding CultivationObj, Mode=TwoWay}" ItemsSource="{Binding CultivationSource, Mode=TwoWay}"
|
||||
Grid.Column="2" Margin="0,160,10,10"
|
||||
DisplayMemberPath="Name"/>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
|
||||
|
@ -103,6 +103,12 @@ namespace Elwig.Windows {
|
||||
var varieties = await ctx.WineVarieties.OrderBy(v => v.Name).ToListAsync();
|
||||
ControlUtils.RenewItemsSource(MainWineVarietiesInput, varieties);
|
||||
ControlUtils.RenewItemsSource(OtherWineVarietiesInput, varieties);
|
||||
var attrList = await ctx.WineAttributes.OrderBy(a => a.Name).Cast<object>().ToListAsync();
|
||||
attrList.Insert(0, new NullItem("- Keine Angabe -"));
|
||||
ControlUtils.RenewItemsSource(AttributeInput, attrList, null, ControlUtils.RenewSourceDefault.First);
|
||||
var cultList = await ctx.WineCultivations.OrderBy(a => a.Name).Cast<object>().ToListAsync();
|
||||
cultList.Insert(0, new NullItem("- Kein Angabe -"));
|
||||
ControlUtils.RenewItemsSource(CultivationInput, cultList, null, ControlUtils.RenewSourceDefault.First);
|
||||
|
||||
await RefreshList();
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
curl --fail -s -L "https://elwig.at/files/create.sql?v=28" -u "elwig:ganzGeheim123!" -o "Resources\Sql\Create.sql"
|
||||
curl --fail -s -L "https://elwig.at/files/create.sql?v=29" -u "elwig:ganzGeheim123!" -o "Resources\Sql\Create.sql"
|
||||
|
Reference in New Issue
Block a user