Skip to content

Commit

Permalink
presun některých atributů
Browse files Browse the repository at this point in the history
  • Loading branch information
martinrotter committed Mar 28, 2024
1 parent 0703be6 commit 2132b20
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 52 deletions.
63 changes: 38 additions & 25 deletions ZZZO/ZZZO.Common/API/BodProgramu.cs
Original file line number Diff line number Diff line change
@@ -1,38 +1,42 @@
using System.Collections.ObjectModel;
using System.ComponentModel;

namespace ZZZO.Common.API;

public class BodProgramu : ObservableObject
{
#region Enumy

public enum TypBoduProgramu
{
[Description("Schvalování zapisovatele/ověřovatelů")]
SchvaleniZapisOver = 0,

[Description("Schvalování programu zasedání")]
SchvaleniProgramu = 1,

[Description("Bod zasedání")]
BodZasedani = 2,

[Description("Doplněný bod zasedání")]
DoplnenyBodZasedani = 3
}

#endregion

#region Proměnné

private bool _jeDoplneny;
private bool _jePodbod;
private string _nadpis;
private string _nadpisPoradi;
private bool _schvalovaniProgramu;
private string _text;
private TypBoduProgramu _typ;
private ObservableCollection<Usneseni> _usneseni = new ObservableCollection<Usneseni>();

#endregion

#region Vlastnosti

public bool JeDoplneny
{
get => _jeDoplneny;
set
{
if (value == _jeDoplneny)
{
return;
}

_jeDoplneny = value;
OnPropertyChanged();
}
}

public bool JePodbod
{
get => _jePodbod;
Expand Down Expand Up @@ -78,32 +82,32 @@ public string NadpisPoradi
}
}

public bool SchvalovaniProgramu
public string Text
{
get => _schvalovaniProgramu;
get => _text;
set
{
if (value == _schvalovaniProgramu)
if (value == _text)
{
return;
}

_schvalovaniProgramu = value;
_text = value;
OnPropertyChanged();
}
}

public string Text
public TypBoduProgramu Typ
{
get => _text;
get => _typ;
set
{
if (value == _text)
if (value == _typ)
{
return;
}

_text = value;
_typ = value;
OnPropertyChanged();
}
}
Expand All @@ -124,4 +128,13 @@ public ObservableCollection<Usneseni> Usneseni
}

#endregion

#region Konstruktory

public BodProgramu()
{
Typ = TypBoduProgramu.BodZasedani;
}

#endregion
}
10 changes: 5 additions & 5 deletions ZZZO/ZZZO.Common/API/HlasovaniZastupitele.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ public class HlasovaniZastupitele : ObservableObject
public enum VolbaHlasovani
{
[Description("Pro")]
Pro,
Pro = 0,

[Description("Proti")]
Proti,
Proti = 1,

[Description("Zdržuje se")]
ZdrzujeSe
ZdrzujeSe = 2
}

#endregion
Expand Down Expand Up @@ -64,9 +64,9 @@ public VolbaHlasovani Volba
}

[JsonIgnore]
public List<VolbaHlasovani> Volby
public IEnumerable<VolbaHlasovani> Volby
{
get => Enum.GetValues<VolbaHlasovani>().ToList();
get => Enum.GetValues<VolbaHlasovani>();
}

[JsonProperty("Zastupitel", IsReference = true)]
Expand Down
23 changes: 18 additions & 5 deletions ZZZO/ZZZO.Common/API/Zasedani.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,25 @@ public Program Program
}
}



/// <summary>
/// Výstupní soubor bez přípony.
/// </summary>
public string VystupniSoubor
{
get
{
return _vystupniSoubor ??= Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
$"zápis-{DatumKonani:yyyy-MM}-zo");
var soubor = _vystupniSoubor;

if (string.IsNullOrWhiteSpace(_vystupniSoubor) || !Directory.Exists(Path.GetDirectoryName(_vystupniSoubor)))
{
_vystupniSoubor = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
$"zápis-{DatumKonani:yyyy-MM}-zo");
}

return _vystupniSoubor;
}

set
Expand Down Expand Up @@ -250,6 +259,10 @@ public ObservableCollection<Zastupitel> Zastupitele
public static Zasedani LoadFromFile(string file)
{
Zasedani zas = JsonConvert.DeserializeObject<Zasedani>(File.ReadAllText(file, Encoding.UTF8));

zas.VystupniSoubor = Path.Combine(
Path.GetDirectoryName(file),
Path.GetFileNameWithoutExtension(file));
return zas;
}

Expand Down Expand Up @@ -392,7 +405,7 @@ public static Zasedani GenerateSample()

var schvaleniProgramu = new BodProgramu
{
SchvalovaniProgramu = true,
Typ = BodProgramu.TypBoduProgramu.SchvaleniProgramu,
Nadpis = "Schvalování programu"
};

Expand Down Expand Up @@ -424,7 +437,7 @@ public static Zasedani GenerateSample()
zas.Program.BodyProgramu.Add(new BodProgramu
{
Nadpis = "Čtvrtý",
JeDoplneny = true
Typ = BodProgramu.TypBoduProgramu.DoplnenyBodZasedani
});

zas.Program.BodyProgramu.Add(new BodProgramu
Expand Down
20 changes: 12 additions & 8 deletions ZZZO/ZZZO.Common/Generators/GeneratorHtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,15 @@ private void GenerateBody(XmlElement html, Zasedani zas, IProgress<int> progress
throw new Exception("nejsou vybráni ověřovatelé");
}

BodProgramu schvaleniProgramu = zas.Program.BodyProgramu.FirstOrDefault(prog => prog.SchvalovaniProgramu);
BodProgramu schvaleniProgramu = zas.Program.BodyProgramu.FirstOrDefault(prog => prog.Typ == BodProgramu.TypBoduProgramu.SchvaleniProgramu);

if (schvaleniProgramu?.Usneseni == null || schvaleniProgramu.Usneseni.Count == 0)
{
throw new Exception("v programu chybí bod a usnesení pro schválení programu jako takového");
}

IEnumerable<BodProgramu> bodyProgramu = zas.Program.BodyProgramu.Where(prog => !prog.SchvalovaniProgramu);
IEnumerable<BodProgramu> bodyProgramu = zas.Program.BodyProgramu.Where(prog => prog.Typ == BodProgramu.TypBoduProgramu.BodZasedani ||
prog.Typ == BodProgramu.TypBoduProgramu.DoplnenyBodZasedani);

XmlElement body = html.AppendElem("body");

Expand Down Expand Up @@ -210,9 +211,10 @@ private void GenerateBody(XmlElement html, Zasedani zas, IProgress<int> progress
"informoval přítomné zastupitele i veřejnost o " +
"projednaných bodech a splněných úkolech.";

foreach (BodProgramu bodProgramu in bodyProgramu.Where(prog => !prog.SchvalovaniProgramu))
foreach (BodProgramu bodProgramu in bodyProgramu.Where(prog => prog.Typ == BodProgramu.TypBoduProgramu.BodZasedani ||
prog.Typ == BodProgramu.TypBoduProgramu.DoplnenyBodZasedani))
{
body.AppendElem(bodProgramu.JePodbod ? "h3" : "h2").InnerText = $"{bodProgramu.NadpisPoradi}{bodProgramu.Nadpis}{(bodProgramu.JeDoplneny ? " (doplněný bod programu)" : string.Empty)}";
body.AppendElem(bodProgramu.JePodbod ? "h3" : "h2").InnerText = $"{bodProgramu.NadpisPoradi}{bodProgramu.Nadpis}{(bodProgramu.Typ == BodProgramu.TypBoduProgramu.DoplnenyBodZasedani ? " (doplněný bod programu)" : string.Empty)}";

if (!string.IsNullOrWhiteSpace(bodProgramu.Text))
{
Expand Down Expand Up @@ -289,7 +291,8 @@ private void GenerateProgramEntries(XmlElement body, IEnumerable<BodProgramu> bo

foreach (BodProgramu thisEntry in bodyProgramu)
{
if (thisEntry.SchvalovaniProgramu)
if (thisEntry.Typ == BodProgramu.TypBoduProgramu.SchvaleniProgramu ||
thisEntry.Typ == BodProgramu.TypBoduProgramu.SchvaleniZapisOver)
{
// Schvalování programu není v "programu" jako takovém.
continue;
Expand All @@ -304,13 +307,13 @@ private void GenerateProgramEntries(XmlElement body, IEnumerable<BodProgramu> bo
}

thisEntry.NadpisPoradi = $"{mainCounter - 1}{nestedCounter++}. ";
nestedOl.AppendElem("li").InnerText = $"{thisEntry.NadpisPoradi}{thisEntry.Nadpis}{(thisEntry.JeDoplneny ? " (doplněný bod programu)" : string.Empty)}";
nestedOl.AppendElem("li").InnerText = $"{thisEntry.NadpisPoradi}{thisEntry.Nadpis}{(thisEntry.Typ == BodProgramu.TypBoduProgramu.DoplnenyBodZasedani ? " (doplněný bod programu)" : string.Empty)}";
}
else
{
nestedOl = null;
thisEntry.NadpisPoradi = $"{mainCounter++}. ";
mainOl.AppendElem("li").InnerText = $"{thisEntry.NadpisPoradi}{thisEntry.Nadpis}{(thisEntry.JeDoplneny ? " (doplněný bod programu)" : string.Empty)}";
mainOl.AppendElem("li").InnerText = $"{thisEntry.NadpisPoradi}{thisEntry.Nadpis}{(thisEntry.Typ == BodProgramu.TypBoduProgramu.DoplnenyBodZasedani ? " (doplněný bod programu)" : string.Empty)}";
}
}
}
Expand All @@ -321,7 +324,8 @@ private string GenerateResolution(
string generatedResolutionTitle = null;
XmlElement root = body.AppendElem("div").AppendClass("resolution-container");

if (!programEntry.SchvalovaniProgramu)
if (programEntry.Typ != BodProgramu.TypBoduProgramu.SchvaleniProgramu &&
programEntry.Typ != BodProgramu.TypBoduProgramu.SchvaleniZapisOver)
{
if (resolution.ZoBereNaVedomi)
{
Expand Down
16 changes: 10 additions & 6 deletions ZZZO/ZZZO/Controls/ProgramEntry.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
d:DesignWidth="500">
<UserControl.Resources>
<converters:NotNullConverter x:Key="NotNullConverter" />
<converters:EnumConverter x:Key="EnumConverter" />
</UserControl.Resources>
<Grid>
<Grid.ColumnDefinitions>
Expand All @@ -22,21 +23,24 @@
<StackPanel Grid.Row="0"
Grid.Column="0"
Orientation="Vertical">
<ComboBox ItemsSource="{Binding TypyBoduProgramu}" SelectedValue="{Binding ProgramEntry.Typ}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Converter={StaticResource EnumConverter}}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBox materialDesign:HintAssist.Hint="Nadpis bodu programu"
Height="75"
TextWrapping="Wrap"
Text="{Binding ProgramEntry.Nadpis, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Content="Podbod předchozího bodu programu"
IsChecked="{Binding ProgramEntry.JePodbod, UpdateSourceTrigger=PropertyChanged}" />
<GroupBox Header="Text bodu programu">
<local:TinyMceEditor Margin="-14 -14 0 0"
HtmlContent="{Binding ProgramEntry.Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Height="400" />
</GroupBox>
<CheckBox Content="Tento bod se týká schvalování programu"
IsChecked="{Binding ProgramEntry.SchvalovaniProgramu, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Content="Podbod předchozího bodu programu"
IsChecked="{Binding ProgramEntry.JePodbod, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Content="Doplněný bod programu"
IsChecked="{Binding ProgramEntry.JeDoplneny, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>

<GroupBox Grid.Row="0"
Expand Down
4 changes: 1 addition & 3 deletions ZZZO/ZZZO/Converters/EnumConverter.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.ComponentModel;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Windows.Data;

Expand Down
5 changes: 5 additions & 0 deletions ZZZO/ZZZO/ViewModels/ProgramEntryViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public ResolutionViewModel ResolutionViewModel
}
}

public IEnumerable<BodProgramu.TypBoduProgramu> TypyBoduProgramu
{
get => Enum.GetValues<BodProgramu.TypBoduProgramu>();
}

public Usneseni ChosenUsneseni
{
get => _chosenUsneseni;
Expand Down

0 comments on commit 2132b20

Please sign in to comment.