diff --git a/src/PKSim.Presentation/Views/Individuals/IExpressionParametersView.cs b/src/PKSim.Presentation/Views/Individuals/IExpressionParametersView.cs index 742389402..6e90ee813 100644 --- a/src/PKSim.Presentation/Views/Individuals/IExpressionParametersView.cs +++ b/src/PKSim.Presentation/Views/Individuals/IExpressionParametersView.cs @@ -10,6 +10,6 @@ public interface IExpressionParametersView : IView expressionParameters); bool EmphasisRelativeExpressionParameters { get; set; } - bool ReadOnly { set; } + bool ReadOnly { get; set; } } } \ No newline at end of file diff --git a/src/PKSim.UI/Views/Individuals/ExpressionParametersView.cs b/src/PKSim.UI/Views/Individuals/ExpressionParametersView.cs index 1bd1a5c66..25ed2fe7c 100644 --- a/src/PKSim.UI/Views/Individuals/ExpressionParametersView.cs +++ b/src/PKSim.UI/Views/Individuals/ExpressionParametersView.cs @@ -48,6 +48,7 @@ public partial class ExpressionParametersView : BaseUse public virtual bool ReadOnly { set => _colParameterValue.ReadOnly = value; + get => _colParameterValue.ReadOnly; } private readonly RepositoryItemProgressBar _progressBarRepository = new RepositoryItemProgressBar @@ -62,7 +63,6 @@ public virtual bool ReadOnly private readonly ScreenBinder> _screenBinder = new ScreenBinder>(); - public ExpressionParametersView(IToolTipCreator toolTipCreator, IImageListRetriever imageListRetriever) { _toolTipCreator = toolTipCreator; @@ -109,7 +109,7 @@ protected virtual bool ShouldMergeCell(GridColumn column, TExpressionParameterDT { //We only merge compartment values if they represent the same organ if (Equals(column, _colCompartment.XtraColumn)) - return representSameOrgan; + return representSameOrgan; return true; } @@ -121,7 +121,7 @@ private void onShowingEditor(object sender, CancelEventArgs e) if (_gridView.FocusedColumn.ReadOnly) e.Cancel = true; - + e.Cancel = !CanEditValueAt(_gridViewBinder.FocusedElement); } @@ -238,7 +238,7 @@ protected void InitializeContainerBinding() .AsReadOnly(); - _colCompartment= _gridViewBinder.AutoBind(item => item.CompartmentPathDTO) + _colCompartment = _gridViewBinder.AutoBind(item => item.CompartmentPathDTO) .WithRepository(dto => configureContainerRepository(dto.CompartmentPathDTO)) .WithCaption(PKSimConstants.UI.Compartment) .AsReadOnly(); @@ -282,9 +282,11 @@ protected override bool ColumnIsValue(GridColumn gridColumn) private RepositoryItem repoForParameter(TExpressionParameterDTO expressionDTO) { - if (_presenter.IsSetByUser(expressionDTO.Parameter)) + //Parameter changed by the user and the view in not readonly, we can show the update button + if (_presenter.IsSetByUser(expressionDTO.Parameter) && !ReadOnly) return _isFixedParameterEditRepository; + //in any other case, standard edit return _standardParameterEditRepository; } diff --git a/tests/PKSim.Tests/Presentation/ExpressionParametersPresenterSpecs.cs b/tests/PKSim.Tests/Presentation/ExpressionParametersPresenterSpecs.cs index ae01ca71c..bc32612c9 100644 --- a/tests/PKSim.Tests/Presentation/ExpressionParametersPresenterSpecs.cs +++ b/tests/PKSim.Tests/Presentation/ExpressionParametersPresenterSpecs.cs @@ -24,22 +24,21 @@ public abstract class concern_for_ExpressionParametersPresenter : ContextSpecifi protected override void Context() { - _view= A.Fake>(); - _editParameterTask= A.Fake(); - sut = new ExpressionParametersPresenter(_view,_editParameterTask); + _view = A.Fake>(); + _editParameterTask = A.Fake(); + sut = new ExpressionParametersPresenter(_view, _editParameterTask); _initialConcentration = createParameter(CoreConstants.Parameters.INITIAL_CONCENTRATION); _relativeExpression = createParameter(CoreConstants.Parameters.REL_EXP); _relativeExpression2 = createParameter(CoreConstants.Parameters.REL_EXP); _fraction_exp_bc = createParameter(CoreConstants.Parameters.FRACTION_EXPRESSED_BLOOD_CELLS); - } private ExpressionParameterDTO createParameter(string parameterName) { return new ExpressionParameterDTO - { Parameter = new ParameterDTO(DomainHelperForSpecs.ConstantParameterWithValue(1).WithName(parameterName)) }; + {Parameter = new ParameterDTO(DomainHelperForSpecs.ConstantParameterWithValue(1).WithName(parameterName))}; } } @@ -52,7 +51,7 @@ protected override void Context() _relativeExpression.Parameter.Parameter.Value = 5; _relativeExpression2.Parameter.Parameter.Value = 10; - sut.Edit(new []{_fraction_exp_bc, _initialConcentration, _relativeExpression, _relativeExpression2, }); + sut.Edit(new[] {_fraction_exp_bc, _initialConcentration, _relativeExpression, _relativeExpression2,}); //Make sure that we in fact update the value of the parameter as the command will not be executed A.CallTo(() => _editParameterTask.SetParameterValue(sut, _relativeExpression.Parameter, 20)) @@ -72,7 +71,6 @@ public void should_also_calculate_the_normalized_value() } } - public class When_switching_the_visibility_of_initial_concentration_parameters_off : concern_for_ExpressionParametersPresenter { private List _allExpressionParameterDTO; @@ -80,11 +78,10 @@ public class When_switching_the_visibility_of_initial_concentration_parameters_o protected override void Context() { base.Context(); - sut.Edit(new[] { _fraction_exp_bc, _initialConcentration, _relativeExpression, _relativeExpression2, }); + sut.Edit(new[] {_fraction_exp_bc, _initialConcentration, _relativeExpression, _relativeExpression2,}); A.CallTo(() => _view.BindTo(A>._)) .Invokes(x => _allExpressionParameterDTO = x.GetArgument>(0).ToList()); - } protected override void Because() @@ -102,10 +99,11 @@ public void should_hide_concentration_parameters() public class When_switching_the_visibility_of_initial_concentration_parameters_on : concern_for_ExpressionParametersPresenter { private List _allExpressionParameterDTO; + protected override void Context() { base.Context(); - sut.Edit(new[] { _fraction_exp_bc, _initialConcentration, _relativeExpression, _relativeExpression2, }); + sut.Edit(new[] {_fraction_exp_bc, _initialConcentration, _relativeExpression, _relativeExpression2,}); A.CallTo(() => _view.BindTo(A>._)) .Invokes(x => _allExpressionParameterDTO = x.GetArgument>(0).ToList()); @@ -123,4 +121,17 @@ public void should_show_concentration_parameters() } } + public class When_disabling_edition_in_the_expression_presenter : concern_for_ExpressionParametersPresenter + { + protected override void Because() + { + sut.DisableEdit(); + } + + [Observation] + public void should_set_the_view_as_readonly() + { + _view.ReadOnly.ShouldBeTrue(); + } + } } \ No newline at end of file