Skip to content

Commit

Permalink
prace
Browse files Browse the repository at this point in the history
  • Loading branch information
martinrotter committed Mar 25, 2024
1 parent 37aecf9 commit bc9eab3
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 24 deletions.
2 changes: 1 addition & 1 deletion ZZZO/ZZZO.Common/API/Zasedani.cs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ public byte[] ToJson()
string json = JsonConvert.SerializeObject(this, new JsonSerializerSettings
{
DateTimeZoneHandling = DateTimeZoneHandling.Local,
DateFormatString = "yyyy-MM-ddThh:mm",
DateFormatString = "yyyy-MM-ddTHH:mm",
Formatting = Formatting.Indented
});

Expand Down
44 changes: 27 additions & 17 deletions ZZZO/ZZZO.Common/Generators/GeneratorHtml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Documents;
using System.Xml;
using ZZZO.Common.API;

Expand Down Expand Up @@ -154,13 +155,15 @@ private void GenerateBody(XmlElement html, Zasedani zas, IProgress<int> progress
.OrderBy(zs => zs.Prijmeni)
.Select(zs => zs.Jmeno + " " + zs.Prijmeni))}.";

string nepritJmena = string.Join(
", ",
zas.Zastupitele
.Where(zs => !zs.JePritomen)
.OrderBy(zs => zs.Prijmeni)
.Select(zs => zs.Jmeno + " " + zs.Prijmeni));

body.AppendElem("p").InnerText =
$"Nepřítomní zastupitelé: {string.Join(
", ",
zas.Zastupitele
.Where(zs => !zs.JePritomen)
.OrderBy(zs => zs.Prijmeni)
.Select(zs => zs.Jmeno + " " + zs.Prijmeni))}.";
$"Nepřítomní zastupitelé: {(string.IsNullOrWhiteSpace(nepritJmena) ? "-" : nepritJmena + ".")}";

body.AppendElem("p").InnerText = $"Zasedání ZO navštívilo {zas.PocetHostu} " +
$"{Sklonovat("host", "hosté", "hostů", zas.PocetHostu)} z řad veřejnosti.";
Expand Down Expand Up @@ -338,22 +341,29 @@ private string GenerateResolution(
return null;
}

IEnumerable<HlasovaniZastupitele> choiceFor = resolution.VolbyZastupitelu.Where(vol =>
int countOfPresentVoters = zas.Zastupitele.Count(vol => vol.JePritomen);
List<HlasovaniZastupitele> choiceFor = resolution.VolbyZastupitelu.Where(vol =>
vol.Zastupitel.JePritomen &&
vol.Volba == HlasovaniZastupitele.VolbaHlasovani.Pro);
vol.Volba == HlasovaniZastupitele.VolbaHlasovani.Pro).ToList();

IEnumerable<HlasovaniZastupitele> choiceAgainst = resolution.VolbyZastupitelu.Where(vol =>
List<HlasovaniZastupitele> choiceAgainst = resolution.VolbyZastupitelu.Where(vol =>
vol.Zastupitel.JePritomen &&
vol.Volba == HlasovaniZastupitele.VolbaHlasovani.Proti);
vol.Volba == HlasovaniZastupitele.VolbaHlasovani.Proti).ToList();

IEnumerable<HlasovaniZastupitele> choiceDontKnow = resolution.VolbyZastupitelu.Where(vol =>
List<HlasovaniZastupitele> choiceDontKnow = resolution.VolbyZastupitelu.Where(vol =>
vol.Zastupitel.JePritomen &&
vol.Volba == HlasovaniZastupitele.VolbaHlasovani.ZdrzujeSe);

string choiceForStr = choiceFor.Count() + (choiceFor.Any() ? $" ({string.Join(", ", choiceFor.Select(ch => ch.Zastupitel.Jmeno + " " + ch.Zastupitel.Prijmeni))})" : string.Empty);
string choiceAgainstStr = choiceAgainst.Count() + (choiceAgainst.Any() ? $" ({string.Join(", ", choiceAgainst.Select(ch => ch.Zastupitel.Jmeno + " " + ch.Zastupitel.Prijmeni))})" : string.Empty);
string choiceDontKnowStr = choiceDontKnow.Count() + (choiceDontKnow.Any() ? $" ({string.Join(", ", choiceDontKnow.Select(ch => ch.Zastupitel.Jmeno + " " + ch.Zastupitel.Prijmeni))})" : string.Empty);
bool accepted = choiceFor.Count() > zas.Zastupitele.Count / 2;
vol.Volba == HlasovaniZastupitele.VolbaHlasovani.ZdrzujeSe).ToList();

string choiceForStr = choiceFor.Count() + ((choiceFor.Any() && choiceFor.Count < countOfPresentVoters)
? $" ({string.Join(", ", choiceFor.Select(ch => ch.Zastupitel.Jmeno + " " + ch.Zastupitel.Prijmeni))})"
: string.Empty);
string choiceAgainstStr = choiceAgainst.Count() + ((choiceAgainst.Any() && choiceAgainst.Count < countOfPresentVoters)
? $" ({string.Join(", ", choiceAgainst.Select(ch => ch.Zastupitel.Jmeno + " " + ch.Zastupitel.Prijmeni))})"
: string.Empty);
string choiceDontKnowStr = choiceDontKnow.Count() + ((choiceDontKnow.Any() && choiceDontKnow.Count < countOfPresentVoters)
? $" ({string.Join(", ", choiceDontKnow.Select(ch => ch.Zastupitel.Jmeno + " " + ch.Zastupitel.Prijmeni))})"
: string.Empty);
bool accepted = choiceFor.Count() > countOfPresentVoters / 2;

XmlElement div = root.AppendElem("div").AppendClass("resolution-vote-box").AppendClass(accepted ? "success" : "failure");

Expand Down
2 changes: 2 additions & 0 deletions ZZZO/ZZZO/Controls/ProgramEntry.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
Grid.Column="0"
Orientation="Vertical">
<TextBox materialDesign:HintAssist.Hint="Nadpis bodu programu"
Height="75"
TextWrapping="Wrap"
Text="{Binding ProgramEntry.Nadpis, UpdateSourceTrigger=PropertyChanged}" />
<GroupBox Header="Text bodu programu">
<local:TinyMceEditor Margin="-14 -14 0 0"
Expand Down
17 changes: 16 additions & 1 deletion ZZZO/ZZZO/Controls/Resolution.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
IsEnabled="{Binding ElementName=CbBereNaVedomi, Path=IsChecked, Converter={StaticResource CollapseOnTrueConverter}}"
Text="{Binding Text, UpdateSourceTrigger=PropertyChanged}" />
<GroupBox Header="Hlasování">
<DataGrid materialDesign:DataGridAssist.CellPadding="4 2 2 2"
<StackPanel Orientation="Vertical">
<DataGrid materialDesign:DataGridAssist.CellPadding="4 2 2 2"
materialDesign:DataGridAssist.ColumnHeaderPadding="4 2 2 2"
Height="250"
CanUserDeleteRows="False"
Expand Down Expand Up @@ -88,6 +89,20 @@
Binding="{Binding Poznamka}" />
</DataGrid.Columns>
</DataGrid>

<WrapPanel Grid.Row="1"
Orientation="Horizontal">
<Button Command="{Binding AddProgramEntryCmd}"
ToolTip="Všichni jsou PRO">
<materialDesign:PackIcon Kind="CheckAll" />
</Button>

<Button Command="{Binding RemoveProgramEntryCmd}"
ToolTip="Všichni jsou PROTI">
<materialDesign:PackIcon Kind="CloseBoxMultiple" />
</Button>
</WrapPanel>
</StackPanel>
</GroupBox>
</StackPanel>
</UserControl>
11 changes: 6 additions & 5 deletions ZZZO/ZZZO/ViewModels/ProgramViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,17 @@ public ProgramViewModel(ZzzoCore core)

private void AddProgramEntry()
{
Core.Zasedani.Program.BodyProgramu.Add(new BodProgramu
int targetIdx = ChosenProgramEntry != null
? Core.Zasedani.Program.BodyProgramu.IndexOf(ChosenProgramEntry) + 1
: Core.Zasedani.Program.BodyProgramu.Count;

Core.Zasedani.Program.BodyProgramu.Insert(targetIdx, new BodProgramu
{
Nadpis = "Nový bod programu",
Text = "Text bodu programu"
});

if (Core.Zasedani.Program.BodyProgramu.Count == 1)
{
ChosenProgramEntry = Core.Zasedani.Program.BodyProgramu[0];
}
ChosenProgramEntry = Core.Zasedani.Program.BodyProgramu[targetIdx];
}

private void MoveProgramEntryDown()
Expand Down

0 comments on commit bc9eab3

Please sign in to comment.