Commit 85b5a479 authored by Thomas's avatar Thomas
Browse files

Remove obsolete code from FormControlPatchView

parent 0cdb38d0
...@@ -10,12 +10,6 @@ namespace pEp.UI.ViewModels ...@@ -10,12 +10,6 @@ namespace pEp.UI.ViewModels
private Patch patch; private Patch patch;
private FlowDocument _DisplayDiff = null;
private bool _IsCommitMessageValid = false;
private bool _IsDiffValid = false;
private bool _IsUriValid = false;
private bool _IsValid = false;
#endregion #endregion
#region Properties #region Properties
...@@ -54,55 +48,13 @@ namespace pEp.UI.ViewModels ...@@ -54,55 +48,13 @@ namespace pEp.UI.ViewModels
/// <summary> /// <summary>
/// Gets the diff of this patch as formatted flow document. /// Gets the diff of this patch as formatted flow document.
/// </summary> /// </summary>
public FlowDocument DisplayDiff { get => this._DisplayDiff; set => SetProperty(ref this._DisplayDiff, value); } public FlowDocument DisplayDiff { get; }
/// <summary> /// <summary>
/// The explanation shown in the UI regarding this patch. /// The explanation shown in the UI regarding this patch.
/// </summary> /// </summary>
public string Explanation { get; } public string Explanation { get; }
/// <summary>
/// Gets whether the Cancel button is visible.
/// </summary>
public bool IsCancelButtonVisible { get; } = true;
/// <summary>
/// Gets or sets whether the commit message is valid.
/// </summary>
public bool IsCommitMessageValid
{
get => this._IsCommitMessageValid;
set
{
if (value != this._IsCommitMessageValid)
{
this._IsCommitMessageValid = value;
this.OnPropertyChanged();
}
}
}
/// <summary>
/// Gets or sets whether the diff is valid.
/// </summary>
public bool IsDiffValid
{
get => this._IsDiffValid;
set
{
if (value != this._IsDiffValid)
{
this._IsDiffValid = value;
this.OnPropertyChanged();
}
}
}
/// <summary>
/// Gets whether the patch in this dialog is editable.
/// </summary>
public bool IsEditable { get; } = false;
/// <summary> /// <summary>
/// Gets whether the OK button is visible. /// Gets whether the OK button is visible.
/// </summary> /// </summary>
...@@ -113,42 +65,10 @@ namespace pEp.UI.ViewModels ...@@ -113,42 +65,10 @@ namespace pEp.UI.ViewModels
/// </summary> /// </summary>
public bool IsRejectButtonVisible { get; } = false; public bool IsRejectButtonVisible { get; } = false;
/// <summary>
/// Gets or sets whether the URI is valid.
/// </summary>
public bool IsUriValid
{
get => this._IsUriValid;
set
{
if (value != this._IsUriValid)
{
this._IsUriValid = value;
this.OnPropertyChanged();
}
}
}
/// <summary>
/// Gets or sets whether this patch is valid.
/// </summary>
public bool IsValid
{
get => this._IsValid;
set
{
if (value != this._IsValid)
{
this._IsValid = value;
this.OnPropertyChanged();
}
}
}
/// <summary> /// <summary>
/// The command to accept the patch dialog. /// The command to accept the patch dialog.
/// </summary> /// </summary>
public RelayCommand OKButtonCommand => new RelayCommand(this.SupportPatch, p => this.IsValid); public RelayCommand OKButtonCommand => new RelayCommand(this.SupportPatch);
/// <summary> /// <summary>
/// Gets the OK button text. /// Gets the OK button text.
...@@ -205,11 +125,9 @@ namespace pEp.UI.ViewModels ...@@ -205,11 +125,9 @@ namespace pEp.UI.ViewModels
/// </summary> /// </summary>
/// <param name="patch">The patch to create the form region with.</param> /// <param name="patch">The patch to create the form region with.</param>
/// <param name="submitter">The submitter of the patch.</param> /// <param name="submitter">The submitter of the patch.</param>
/// <param name="isEditable">Whether this patch is editable.</param> public FormControlPatchViewModel(Patch patch, PEPIdentity submitter)
public FormControlPatchViewModel(Patch patch, PEPIdentity submitter, bool isEditable = false)
{ {
this.patch = patch; this.patch = patch;
this.IsEditable = isEditable;
this.Submitter = submitter; this.Submitter = submitter;
this.Explanation = "New configuration changes pending approval"; this.Explanation = "New configuration changes pending approval";
this.IsRejectButtonVisible = true; this.IsRejectButtonVisible = true;
...@@ -267,11 +185,19 @@ namespace pEp.UI.ViewModels ...@@ -267,11 +185,19 @@ namespace pEp.UI.ViewModels
return document; return document;
} }
/// <summary>
/// Rejects this patch.
/// </summary>
/// <param name="parameter">The command parameter.</param>
private void RejectPatch(object parameter) private void RejectPatch(object parameter)
{ {
Globals.ThisAddIn.DistributedPolicyEngine.Reject(this.patch, new PEPIdentity()); Globals.ThisAddIn.DistributedPolicyEngine.Reject(this.patch, new PEPIdentity());
} }
/// <summary>
/// Supports this patch.
/// </summary>
/// <param name="parameter">The command parameter.</param>
private void SupportPatch(object parameter) private void SupportPatch(object parameter)
{ {
Globals.ThisAddIn.DistributedPolicyEngine.Support(this.patch, new PEPIdentity()); Globals.ThisAddIn.DistributedPolicyEngine.Support(this.patch, new PEPIdentity());
......
...@@ -65,74 +65,56 @@ ...@@ -65,74 +65,56 @@
HorizontalAlignment="Right" HorizontalAlignment="Right"
VerticalAlignment="Center" VerticalAlignment="Center"
Margin="5,5,10,5"/> Margin="5,5,10,5"/>
<!--<Button Grid.Column="1"
Grid.Row="0"
Content="Load from file"
Margin="10"
HorizontalAlignment="Right"
Style="{StaticResource StyleButtonGray}"
Command="{Binding LoadFromFileCommand}"
Visibility="{Binding IsEditable, Converter={StaticResource BoolToVisibility}}"/>-->
<Label Grid.Column="0" <Label Grid.Column="0"
Grid.Row="3" Grid.Row="3"
Content="Diff" Content="Diff"
Margin="10,10,5,10"/> Margin="10,10,5,10"/>
<ui:TextBoxWithPlaceholder Grid.Column="1"
Grid.ColumnSpan="2"
Grid.Row="3"
Text="{Binding Diff, UpdateSourceTrigger=PropertyChanged}"
MultiLine="True"
IsReadOnly="{Binding IsEditable, Converter={StaticResource InvertBool}}"
IsValidInput="{Binding IsDiffValid}"
Placeholder="Please add diff"
Margin="5,10,10,10"
Visibility="{Binding IsEditable, Converter={StaticResource BoolToVisibility}}"/>
<FlowDocumentScrollViewer Grid.Column="1" <FlowDocumentScrollViewer Grid.Column="1"
Grid.ColumnSpan="2" Grid.ColumnSpan="2"
Grid.Row="3" Grid.Row="3"
BorderBrush="Black" BorderBrush="Black"
BorderThickness="1" BorderThickness="1"
Margin="5,10,10,10" Margin="5,10,10,10"
Document="{Binding DisplayDiff}" Document="{Binding DisplayDiff}" />
Visibility="{Binding IsEditable, Converter={StaticResource InvertBoolToVisibility}}"/>
<Label Grid.Column="0" <Label Grid.Column="0"
Grid.Row="4" Grid.Row="4"
Content="Uri" Content="Uri"
Margin="10,10,5,10"/> Margin="10,10,5,10"/>
<ui:TextBoxWithPlaceholder Grid.Column="1" <TextBox Grid.Column="1"
Grid.ColumnSpan="2" Grid.ColumnSpan="2"
Grid.Row="4" Grid.Row="4"
Text="{Binding Uri}" VerticalAlignment="Center"
IsReadOnly="{Binding IsEditable, Converter={StaticResource InvertBool}}" Padding="2"
IsValidInput="{Binding IsUriValid}" Text="{Binding Uri}"
Placeholder="URI" IsReadOnly="True"
MinWidth="400" MinWidth="400"
Margin="5,10,10,10"/> Margin="5,10,10,10"/>
<Label Grid.Column="0" <Label Grid.Column="0"
Grid.Row="5" Grid.Row="5"
Content="Commit message" Content="Commit message"
Margin="10,10,5,10"/> Margin="10,10,5,10"/>
<ui:TextBoxWithPlaceholder Grid.Column="1" <TextBox Grid.Column="1"
Grid.ColumnSpan="2" Grid.ColumnSpan="2"
Grid.Row="5" Grid.Row="5"
Text="{Binding CommitMessage}" VerticalAlignment="Center"
IsReadOnly="{Binding IsEditable, Converter={StaticResource InvertBool}}" Padding="2"
IsValidInput="{Binding IsCommitMessageValid}" Text="{Binding CommitMessage}"
Placeholder="Commit message" IsReadOnly="True"
MinWidth="400" MinWidth="400"
Margin="5,10,10,10"/> Margin="5,10,10,10"/>
<Label Grid.Column="0" <Label Grid.Column="0"
Grid.Row="6" Grid.Row="6"
Content="Tag" Content="Tag"
Margin="10,10,5,10"/> Margin="10,10,5,10"/>
<ui:TextBoxWithPlaceholder Grid.Column="1" <TextBox Grid.Column="1"
Grid.ColumnSpan="2" Grid.ColumnSpan="2"
Grid.Row="6" Grid.Row="6"
Text="{Binding Tag}" VerticalAlignment="Center"
IsReadOnly="{Binding IsEditable, Converter={StaticResource InvertBool}}" Padding="2"
Placeholder="Tag (optional)" Text="{Binding Tag}"
MinWidth="400" IsReadOnly="True"
Margin="5,10,10,10"/> MinWidth="400"
Margin="5,10,10,10"/>
<StackPanel Grid.Column="0" <StackPanel Grid.Column="0"
Grid.ColumnSpan="3" Grid.ColumnSpan="3"
Grid.Row="7" Grid.Row="7"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment