Skip to content

Commit e76f1d5

Browse files
authored
When nested folder structure is not enabled, files are now mapped into folders corresponding to their extension. No further folder nesting occurs. (#100)
1 parent 605c2f3 commit e76f1d5

File tree

2 files changed

+137
-31
lines changed

2 files changed

+137
-31
lines changed

cls/SourceControl/Git/Utils.cls

Lines changed: 58 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,24 +1239,32 @@ ClassMethod Name(InternalName As %String) As %String
12391239
// Grab the actual name
12401240
set actualName = $classmethod(docclass,"GetOther",InternalName)
12411241
// The actualName is only valid if we get a single .cls as a result
1242-
if actualName'[",",$zconvert($piece(actualName,".",$length(actualName,".")),"U")="CLS" {
1242+
if (actualName'[",") && ($zconvert($piece(actualName,".",$length(actualName,".")),"U")="CLS") {
12431243
// We use what GetOther() gives us, thus Demo.Loan.FindRateProcess.bpl becomes Demo.Loan.FindRateProcess.cls
12441244
set InternalName = actualName
12451245
}
12461246
}
12471247
}
12481248

1249-
if $$CheckProtect^%qccServer(InternalName) quit ""
1250-
set nam=$piece(InternalName,".",1,*-1),ext=$piece(InternalName,".",*),ext=$zconvert(ext,"u")
1251-
if nam=""||(ext="") quit ""
1249+
if $$CheckProtect^%qccServer(InternalName) {
1250+
quit ""
1251+
}
1252+
1253+
set nam=$piece(InternalName,".",1,*-1)
1254+
set ext=$zconvert($piece(InternalName,".",*),"u")
1255+
1256+
if (nam="")||(ext=""){
1257+
quit ""
1258+
}
1259+
12521260
// Any CSP items should be matched against the "/CSP/" mapping in ^Sources
12531261
if InternalName["/" {
12541262
set filename=$$GetFilename^%apiCSP(InternalName)
12551263
//Find if this csp file is located within the ^Sources tree, and return appropriate value
1256-
if $$$isWINDOWS {
1257-
if $zconvert($extract(filename,1,$length($$$SourceRoot)),"l")=$zconvert($$$SourceRoot,"l") quit $extract(filename,$length($$$SourceRoot)+1,*)
1258-
} else {
1259-
if $extract(filename,1,$length($$$SourceRoot))=$$$SourceRoot quit $extract(filename,$length($$$SourceRoot)+1,*)
1264+
if ($$$isWINDOWS) && ($zconvert($extract(filename,1,$length($$$SourceRoot)),"l")=$zconvert($$$SourceRoot,"l")){
1265+
quit $extract(filename,$length($$$SourceRoot)+1,*)
1266+
} elseif $extract(filename,1,$length($$$SourceRoot))=$$$SourceRoot{
1267+
quit $extract(filename,$length($$$SourceRoot)+1,*)
12601268
}
12611269
//Do not support manipulating files in the /itemsetsourcelink* csp app which are not inside of the namespace's ^Sources tree
12621270
if InternalName["itemsetsourcelink" {
@@ -1266,29 +1274,55 @@ ClassMethod Name(InternalName As %String) As %String
12661274
// Any CSP items should be matched against the "/CSP/" mapping if the file is not stored in the ^Sources tree
12671275
set ext="/CSP/"
12681276
}
1269-
if ext="PRJ",nam["Default_" quit ""
1270-
if ext="CLS",$$$defClassKeyGet(nam,$$$cCLASSgeneratedby)'="" quit ""
1271-
set default=0
1272-
set p=$order($$$SourceMapping(ext,nam)) for set p=$order($$$SourceMapping(ext,p),-1) quit:p="" if $extract(nam,1,$length(p))=p,$data(^Sources(ext,p),found) quit
1273-
if $data(found)=0,$data($$$SourceMapping(ext,"*"),found),'$$$GetSourceMapping(ext,"*","NoFolders") set default=1
1274-
if $data(found)=0 quit ""
1277+
1278+
if (ext="PRJ") && (nam["Default_"){
1279+
quit ""
1280+
}
1281+
1282+
if (ext="CLS") && ($$$defClassKeyGet(nam,$$$cCLASSgeneratedby)'=""){
1283+
quit ""
1284+
}
1285+
1286+
set default=1
1287+
set p=$order($$$SourceMapping(ext,nam))
1288+
for{
1289+
set p=$order($$$SourceMapping(ext,p),-1)
1290+
quit:p=""
1291+
if ($extract(nam,1,$length(p))=p) && ($data(^Sources(ext,p),found)){
1292+
quit
1293+
}
1294+
}
1295+
if ($data(found)=0) && ($data($$$SourceMapping(ext,"*"),found)) && ('$$$GetSourceMapping(ext,"*","NoFolders")){
1296+
set default=0
1297+
1298+
} elseif $data(found)=0{
1299+
set found = $zconvert(ext,"L")_"/"
1300+
}
1301+
12751302
if InternalName["/" {
12761303
// If no specific mapping was specified (p=""), then return the whole csp filename; otherwise return the name without the mapped piece
12771304
set InternalName=$extract(InternalName,$length(p)+2,*)
12781305
quit $translate(found_$translate(InternalName,"%","_"),"\","/")
1279-
}
1280-
if (ext="DFI") {
1306+
1307+
} elseif (ext="DFI") {
12811308
// expected format is <folderName>-<itemName>.<itemType>.DFI; will map to an external file named <folderName>/<itemName>.<itemType>.xml
12821309
// replace the first '-' with '/' to translate Item Folder into subfolder on disk and leave the other dashes as dashes; converts spaces to '_'
12831310
quit $translate(found_$replace($translate(nam,"% ","__"),"-","/",1,1)_".xml","\","/")
1284-
}
1285-
if ext="CLS"||(ext="PRJ")||(usertype&&(##class(%RoutineMgr).UserType(InternalName))) {
1311+
1312+
} elseif ext="CLS"||(ext="PRJ")||(usertype&&(##class(%RoutineMgr).UserType(InternalName))) {
12861313
set nam=$translate(nam,"%")
1287-
if '$$$GetSourceMapping(ext,"*","NoFolders") set nam=$translate(nam,".","/")
1314+
if '$$$GetSourceMapping(ext,"*","NoFolders"){
1315+
set nam=$translate(nam,".","/")
1316+
}
12881317
#; If match ends in '`' character use UDL/CLS format rather than XML format
1289-
return $translate(found_nam_".cls","\","/")
1318+
return $translate(found_nam_"."_$zconvert(ext, "l"),"\","/")
1319+
}
1320+
1321+
if ('default){
1322+
quit $translate($get(found)_$translate(nam,"%.","_/")_"."_$zconvert(ext,"l"),"\","/")
1323+
} else {
1324+
quit $translate($get(found)_nam_"."_$zconvert(ext,"l"),"\","/")
12901325
}
1291-
quit $translate($get(found)_$translate(nam,"%.","_/")_"."_$zconvert(ext,"l"),"\","/")
12921326
}
12931327

12941328
/*
@@ -1377,10 +1411,10 @@ ClassMethod NameToInternalName(Name, IgnorePercent = 1, IgnoreNonexistent = 1) A
13771411
}
13781412
if (InternalName="") {
13791413
//take our best guess based on the document extension mapped to that subdirectory
1380-
set nam=$piece(nam,".",1,$length(nam,".")-1)
1414+
set nam=$piece(nam,".",1*-1)
13811415
set nam=$translate(nam,"_/","%.")
1382-
set InternalName=nam_"."_ext
1383-
if (ext="CLS") {
1416+
set InternalName=nam_"."_fileExt
1417+
if (fileExt="cls") {
13841418
// special handling for possible collissions between % and non-% classes of the same name
13851419
set alternateInternalName="%"_InternalName
13861420
set primaryExists=##class(%RoutineMgr).Exists(InternalName), alternateExists=##class(%RoutineMgr).Exists(alternateInternalName)

csp/gitprojectsettings.csp

Lines changed: 79 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ body {
3434
border-radius: 0 0.25rem 0.25rem 0;
3535
}
3636

37+
.custom-switch {
38+
padding: 0.4rem 0.5rem 0 2.75rem;
39+
border: 1px solid #ced4da;
40+
border-left: 0px;
41+
}
42+
3743
hr {
3844
opacity: 0.15
3945
}
@@ -54,7 +60,12 @@ hr {
5460
set param = "MappingsPath"
5561
kill settings.Mappings
5662
while ( $Get(%request.Data(param,i)) '= "" ){
63+
if ($Get(%request.Data(param,i)) = "NoFolders"){
64+
set settings.Mappings($Get(%request.Data("MappingsExt",i)), $Get(%request.Data("MappingsCov",i)), $Get(%request.Data(param,i))) = 1
65+
}
66+
5767
set settings.Mappings($Get(%request.Data("MappingsExt",i)), $Get(%request.Data("MappingsCov",i))) = $Get(%request.Data(param,i))
68+
5869
set i = i+1
5970
}
6071
do settings.%Save()
@@ -128,7 +139,7 @@ hr {
128139
</div>
129140
<script language="cache" runat=server>
130141
set extKey = ""
131-
set first = 1
142+
set idx = 1
132143
for {
133144
set covKey = ""
134145
set extKey = $ORDER(settings.Mappings(extKey))
@@ -137,19 +148,46 @@ hr {
137148
set covKey = $ORDER(settings.Mappings(extKey, covKey))
138149
quit:covKey=""
139150

140-
if (first = 1) {
141-
set first = 0
142-
}
143-
else {
151+
if (idx '= 1) {
144152
&html<<div class="col-sm-3" id="indent-div">
145153
</div>>
154+
}
155+
156+
if ($DATA(settings.Mappings(extKey, covKey)) = 1){
157+
set checked = "checked"
158+
set activated = " active"
159+
set readOnly = ""
160+
set mapPath = settings.Mappings(extKey, covKey)
161+
162+
} else {
163+
set checked = ""
164+
set activated = ""
165+
set readOnly = "readonly"
166+
set mapPath = "NoFolders"
146167
}
147168

148169
&html<<div class="voca col-sm-7">
149170
<div class = "input-group mb-1">
150171
<input type="text" class="form-control" id="MappingsExt" name="MappingsExt" value=#(extKey)# placeholder="Extension">
151172
<input type="text" class="form-control" id="MappingsCov" name="MappingsCov" value=#(covKey)# placeholder="Coverage">
152-
<input type="text" class="form-control" id="MappingsPath" name="MappingsPath" value=#(settings.Mappings(extKey, covKey))# placeholder="Relative path">
173+
<input type="text" class="form-control" id="MappingsPath" name="MappingsPath" value=#(mapPath)# placeholder="Relative path" #(readOnly)#>
174+
<div class="custom-control custom-switch" data-delay='{"show":"1000", "hide":"100"}' data-toggle="tooltip" data-placement="top" title="Switch off to store files in a flat directory structure.">
175+
<input type="checkbox" class="#("custom-control-input"_activated)#" id=#("noFoldersSwitch"_idx)# #(checked)#>
176+
<label class="custom-control-label" for=#("noFoldersSwitch"_idx)#>>
177+
178+
if (checked '= ""){
179+
&html<<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="#007bff" class="bi bi-folder-fill" viewBox="0 0 16 16">
180+
<path d="M9.828 3h3.982a2 2 0 0 1 1.992 2.181l-.637 7A2 2 0 0 1 13.174 14H2.825a2 2 0 0 1-1.991-1.819l-.637-7a1.99 1.99 0 0 1 .342-1.31L.5 3a2 2 0 0 1 2-2h3.672a2 2 0 0 1 1.414.586l.828.828A2 2 0 0 0 9.828 3zm-8.322.12C1.72 3.042 1.95 3 2.19 3h5.396l-.707-.707A1 1 0 0 0 6.172 2H2.5a1 1 0 0 0-1 .981l.006.139z"/>
181+
</svg>>
182+
} else{
183+
&html<<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" class="bi bi-folder-x" viewBox="0 0 16 16">
184+
<path d="M.54 3.87.5 3a2 2 0 0 1 2-2h3.672a2 2 0 0 1 1.414.586l.828.828A2 2 0 0 0 9.828 3h3.982a2 2 0 0 1 1.992 2.181L15.546 8H14.54l.265-2.91A1 1 0 0 0 13.81 4H2.19a1 1 0 0 0-.996 1.09l.637 7a1 1 0 0 0 .995.91H9v1H2.826a2 2 0 0 1-1.991-1.819l-.637-7a1.99 1.99 0 0 1 .342-1.31zm6.339-1.577A1 1 0 0 0 6.172 2H2.5a1 1 0 0 0-1 .981l.006.139C1.72 3.042 1.95 3 2.19 3h5.396l-.707-.707z"/>
185+
<path d="M11.854 10.146a.5.5 0 0 0-.707.708L12.293 12l-1.146 1.146a.5.5 0 0 0 .707.708L13 12.707l1.146 1.147a.5.5 0 0 0 .708-.708L13.707 12l1.147-1.146a.5.5 0 0 0-.707-.708L13 11.293l-1.146-1.147z"/>
186+
</svg>>
187+
}
188+
189+
&html<</label>
190+
</div>
153191
<div class="input-group-append">
154192
<button type="button" class="btn btn-remove" >
155193
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="#dc3545" class="bi bi-dash-circle-fill" viewBox="0 0 16 16">
@@ -159,6 +197,8 @@ hr {
159197
</div>
160198
</div>
161199
</div>>
200+
201+
set idx = idx + 1
162202
}
163203
}
164204
</script>
@@ -205,8 +245,12 @@ hr {
205245
<script src="js/popper.min.js"></script>
206246
<script src="js/bootstrap.min.js"></script>
207247
<script type="text/javascript">
248+
249+
previous_path = new Array($(".voca").length).fill("");
208250
$(function () {
209-
$('[data-toggle="tooltip"]').tooltip()
251+
$('[data-toggle="tooltip"]').tooltip({
252+
trigger: 'hover'
253+
});
210254
})
211255
$(function()
212256
{
@@ -235,6 +279,34 @@ $(function()
235279
return false;
236280
});
237281
});
282+
283+
$('[id^=noFoldersSwitch]').click(function(e) {
284+
285+
$(this).siblings("label").empty()
286+
var idx = parseInt($(this)[0].id.split("noFoldersSwitch")[1]);
287+
288+
if (!$(this).hasClass("active")) {
289+
$(this).addClass("active");
290+
$(this).siblings("label").append('<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="#007bff" class="bi bi-folder-fill" viewBox="0 0 16 16">'+
291+
'<path d="M9.828 3h3.982a2 2 0 0 1 1.992 2.181l-.637 7A2 2 0 0 1 13.174 14H2.825a2 2 0 0 1-1.991-1.819l-.637-7a1.99 1.99 0 0 1 .342-1.31L.5 3a2 2 0 0 1 2-2h3.672a2 2 0 0 1 1.414.586l.828.828A2 2 0 0 0 9.828 3zm-8.322.12C1.72 3.042 1.95 3 2.19 3h5.396l-.707-.707A1 1 0 0 0 6.172 2H2.5a1 1 0 0 0-1 .981l.006.139z"/>'+
292+
'</svg>');
293+
294+
$(this).parent().siblings("#MappingsPath")[0].value = previous_path[idx-1];
295+
$(this).parent().siblings("#MappingsPath")[0].readOnly = false;
296+
297+
} else {
298+
$(this).removeClass("active");
299+
$(this).siblings("label").append('<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" class="bi bi-folder-x" viewBox="0 0 16 16">'+
300+
'<path d="M.54 3.87.5 3a2 2 0 0 1 2-2h3.672a2 2 0 0 1 1.414.586l.828.828A2 2 0 0 0 9.828 3h3.982a2 2 0 0 1 1.992 2.181L15.546 8H14.54l.265-2.91A1 1 0 0 0 13.81 4H2.19a1 1 0 0 0-.996 1.09l.637 7a1 1 0 0 0 .995.91H9v1H2.826a2 2 0 0 1-1.991-1.819l-.637-7a1.99 1.99 0 0 1 .342-1.31zm6.339-1.577A1 1 0 0 0 6.172 2H2.5a1 1 0 0 0-1 .981l.006.139C1.72 3.042 1.95 3 2.19 3h5.396l-.707-.707z"/>'+
301+
'<path d="M11.854 10.146a.5.5 0 0 0-.707.708L12.293 12l-1.146 1.146a.5.5 0 0 0 .707.708L13 12.707l1.146 1.147a.5.5 0 0 0 .708-.708L13.707 12l1.147-1.146a.5.5 0 0 0-.707-.708L13 11.293l-1.146-1.147z"/>'+
302+
'</svg>');
303+
304+
previous_path[idx-1] = $(this).parent().siblings("#MappingsPath").val()
305+
$(this).parent().siblings("#MappingsPath")[0].value = "NoFolders";
306+
$(this).parent().siblings("#MappingsPath")[0].readOnly = true;
307+
}
308+
});
309+
238310
</script>
239311
</body>
240312
</html>

0 commit comments

Comments
 (0)