Skip to content

Commit

Permalink
prompt for rename of filter change
Browse files Browse the repository at this point in the history
  • Loading branch information
JFriel committed Apr 29, 2024
1 parent 4cc364c commit 3f2fd35
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# Changelog
All notable changes to this project will be documented in this file.

Expand All @@ -9,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Changed

- Add Microsoft.Bcl.AsyncInterfaces 6.0.0 for plugin dependancy tree
- Add prompt to reanem container when adding a cohort filter

## [8.1.5] - 2024-04-03

Expand Down
9 changes: 8 additions & 1 deletion Rdmp.Core/ReusableLibraryCode/Settings/UserSettings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) The University of Dundee 2018-2019
// Copyright (c) The University of Dundee 2018-2024
// This file is part of the Research Data Management Platform (RDMP).
// RDMP is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
// RDMP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
Expand Down Expand Up @@ -171,6 +171,13 @@ public static bool EnableCommits
}


public static bool PromptRenameOnCohortFilterChange
{
get => AppSettings.GetValueOrDefault("PromptRenameOnCohortFilterChange", true);
set => AppSettings.AddOrUpdateValue("PromptRenameOnCohortFilterChange", value);
}


#region Catalogue flag visibility settings

public static bool ShowInternalCatalogues
Expand Down
4 changes: 3 additions & 1 deletion Rdmp.UI/SimpleControls/ObjectSaverButton.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) The University of Dundee 2018-2019
// Copyright (c) The University of Dundee 2018-2024
// This file is part of the Research Data Management Platform (RDMP).
// RDMP is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
// RDMP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
Expand Down Expand Up @@ -237,4 +237,6 @@ public void CheckForUnsavedChangesAnOfferToSave()
else
_o.RevertToDatabaseState();
}

public bool IsEnabled => _isEnabled;
}
15 changes: 15 additions & 0 deletions Rdmp.UI/SimpleDialogs/UserSettingsUI.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Rdmp.UI/SimpleDialogs/UserSettingsUI.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) The University of Dundee 2018-2019
// Copyright (c) The University of Dundee 2018-2024
// This file is part of the Research Data Management Platform (RDMP).
// RDMP is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
// RDMP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
Expand Down Expand Up @@ -103,6 +103,7 @@ public UserSettingsFileUI(IActivateItems activator)
RegisterCheckbox(cbAlwaysJoinEverything, nameof(UserSettings.AlwaysJoinEverything));
RegisterCheckbox(cbAutoRunSqlQueries, nameof(UserSettings.AutoRunSqlQueries));
RegisterCheckbox(cbExpandAllInCohortBuilder, nameof(UserSettings.ExpandAllInCohortBuilder));
RegisterCheckbox(cbPromptFilterRename, nameof(UserSettings.PromptRenameOnCohortFilterChange));
RegisterCheckbox(cbUseAliasInsteadOfTransformInGroupByAggregateGraphs,
nameof(UserSettings.UseAliasInsteadOfTransformInGroupByAggregateGraphs));
RegisterCheckbox(cbUseLocalFileSystem, nameof(UserSettings.UseLocalFileSystem));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) The University of Dundee 2018-2019
// Copyright (c) The University of Dundee 2018-2024
// This file is part of the Research Data Management Platform (RDMP).
// RDMP is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
// RDMP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
Expand All @@ -12,7 +12,12 @@
using Rdmp.Core.CommandExecution;
using Rdmp.Core.CommandExecution.AtomicCommands;
using Rdmp.Core.Curation.Data;
using Rdmp.Core.Curation.Data.Aggregation;
using Rdmp.Core.Curation.Data.Cohort;
using Rdmp.Core.MapsDirectlyToDatabaseTable;
using Rdmp.Core.Repositories;
using Rdmp.Core.ReusableLibraryCode.Settings;
using Rdmp.UI.ExtractionUIs.FilterUIs;
using Rdmp.UI.ItemActivation;
using Rdmp.UI.Refreshing;
using Rdmp.UI.Rules;
Expand Down Expand Up @@ -128,6 +133,11 @@ public virtual void SetDatabaseObject(IActivateItems activator, T databaseObject
ObjectSaverButton1.BeforeSave += BeforeSave_FinishCommitInProgressIfAny;
ObjectSaverButton1.AfterSave += AfterSave_BeginNewCommitIfApplicable;
}
if (this.GetType() == typeof(ExtractionFilterUI) && UserSettings.PromptRenameOnCohortFilterChange)
{
ObjectSaverButton1.BeforeSave -= BeforeSave_PromptRenameOfExtractionFilterContainer;
ObjectSaverButton1.BeforeSave += BeforeSave_PromptRenameOfExtractionFilterContainer;
}

ObjectSaverButton1.SetupFor(this, databaseObject, activator);
}
Expand All @@ -141,6 +151,32 @@ public virtual void SetDatabaseObject(IActivateItems activator, T databaseObject
}
}

protected bool BeforeSave_PromptRenameOfExtractionFilterContainer(DatabaseEntity _)
{
if (!ObjectSaverButton1.IsEnabled) return true;
AggregateFilter af;
try
{
af = (AggregateFilter)_;
}
catch (Exception)
{
//DatabaseEntity was not an aggregateFilter
return true;
}
AggregateFilterContainer afc = af.CatalogueRepository.GetAllObjectsWhere<AggregateFilterContainer>("ID", af.FilterContainer_ID).FirstOrDefault();
if (afc != null)
{
AggregateConfiguration ac = afc.GetAggregate();
if (ac != null)
{
var rename = new ExecuteCommandRename(Activator, ac);
rename.Execute();
}
}
return true;
}


protected bool BeforeSave_FinishCommitInProgressIfAny(DatabaseEntity _)
{
Expand Down Expand Up @@ -308,6 +344,7 @@ protected override void Dispose(bool disposing)
if (ObjectSaverButton1 != null)
{
ObjectSaverButton1.BeforeSave -= BeforeSave_FinishCommitInProgressIfAny;
ObjectSaverButton1.BeforeSave -= BeforeSave_PromptRenameOfExtractionFilterContainer;
ObjectSaverButton1.AfterSave -= AfterSave_BeginNewCommitIfApplicable;
}
}
Expand Down

0 comments on commit 3f2fd35

Please sign in to comment.