diff --git a/CHANGELOG.md b/CHANGELOG.md index 936c71ca..c5f6f673 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Production Decomposition mode allows controlling interoperability productions as individual files for each host (#469) +- Added saving settings as system default for new namespaces (#535) ## [2.7.1] - 2024-11-13 diff --git a/cls/SourceControl/Git/Settings.cls b/cls/SourceControl/Git/Settings.cls index ed533baa..2171b9f0 100644 --- a/cls/SourceControl/Git/Settings.cls +++ b/cls/SourceControl/Git/Settings.cls @@ -243,6 +243,7 @@ ClassMethod CreateNamespaceTempFolder() As %Status ClassMethod Configure() As %Boolean [ CodeMode = objectgenerator ] { do %code.WriteLine(" set inst = ..%New()") + do %code.WriteLine(" do inst.RetrieveDefaults()") set defaultPromptFlag = $$$DisableBackupCharMask + $$$TrapCtrlCMask + $$$EnableQuitCharMask + $$$DisableHelpCharMask + $$$DisableHelpContextCharMask + $$$TrapErrorMask set property = "" for { @@ -483,4 +484,25 @@ Method ConfigureBinPath(ByRef path As %String) As %Boolean return 1 } +Method RetrieveDefaults() As %Boolean +{ + do ##class(%zpkg.isc.sc.git.Defaults).GetDefaultSettings(.settings) + set iterator = settings.%GetIterator() + while iterator.%GetNext(.key, .value) { + set $property($this,key) = value + } + return $$$OK +} + +Method SaveDefaults() As %Boolean +{ + set defaults = {} + set items = $lb("gitBinPath", "pullEventClass", "percentClassReplace", "environmentName", "systemBasicMode", "defaultMergeBranch", "mappedItemsReadOnly", "compileOnImport") + for i=1:1:$LISTLENGTH(items) { + set property = $listget(items,i) + do defaults.%Set(property, $property($this, property)) + } + return ##class(%zpkg.isc.sc.git.Defaults).SetDefaultSettings(defaults) +} + } diff --git a/cls/_zpkg/isc/sc/git/Defaults.cls b/cls/_zpkg/isc/sc/git/Defaults.cls new file mode 100644 index 00000000..4ce7dc7c --- /dev/null +++ b/cls/_zpkg/isc/sc/git/Defaults.cls @@ -0,0 +1,62 @@ +Class %zpkg.isc.sc.git.Defaults +{ + +ClassMethod GetDefaults() As %Library.DynamicObject [ NotInheritable, Private ] +{ + set defaults = {} + set storage = "^%SYS(""SourceControl"",""Git"",""defaults"")" + $$$AddAllRoleTemporary + + set key = $order(@storage@("")) + while key '= "" { + do defaults.%Set(key, $get(@storage@(key))) + set key = $order(@storage@(key)) + } + return defaults +} + +ClassMethod GetDefaultSettings(ByRef defaults As %Library.DynamicObject) As %Status +{ + try { + set defaults = ..GetDefaults() + } catch e { + return e.AsStatus() + } + return $$$OK +} + +ClassMethod SetDefaults(defaults As %Library.DynamicObject) As %Status [ NotInheritable, Private ] +{ + + $$$AddAllRoleTemporary + set storage = "^%SYS(""SourceControl"",""Git"",""defaults"")" + k @storage + set iterator = defaults.%GetIterator() + + while iterator.%GetNext(.key, .value) { + set @storage@(key) = value + } + + return $$$OK +} + +ClassMethod SetDefaultSettings(defaults As %Library.DynamicObject) As %Status [ NotInheritable ] +{ + + set newDefaults = {} + + set iterator = defaults.%GetIterator() + + while iterator.%GetNext(.key, .value) { + do newDefaults.%Set(key, value) + } + + try { + do ..SetDefaults(newDefaults) + } catch e { + return e.AsStatus() + } + return $$$OK +} + +} \ No newline at end of file diff --git a/csp/gitprojectsettings.csp b/csp/gitprojectsettings.csp index 19d5f9cd..8264b3fa 100644 --- a/csp/gitprojectsettings.csp +++ b/csp/gitprojectsettings.csp @@ -165,6 +165,10 @@ body { } set settings.favoriteNamespaces = contexts + + if ($get(%request.Data("proxySubmitButton",1)) = "saveDefaults") { + do settings.SaveDefaults() + } } set err = "" try { @@ -226,7 +230,7 @@ body {