Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Solidify-Frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Solidify
Solidify-Frontend
Commits
8b0f9ccb
Commit
8b0f9ccb
authored
1 year ago
by
Homada.Boumedane
Committed by
Florent Poittevin
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
fix: compute current folder after a delete
parent
f1334551
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!114
refactor: compute current folder after a delete
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
projects/solidify-frontend/src/lib/application/components/presentationals/folder-tree/folder-tree.presentational.ts
+41
-1
41 additions, 1 deletion
...presentationals/folder-tree/folder-tree.presentational.ts
with
41 additions
and
1 deletion
projects/solidify-frontend/src/lib/application/components/presentationals/folder-tree/folder-tree.presentational.ts
+
41
−
1
View file @
8b0f9ccb
...
...
@@ -43,6 +43,7 @@ import {
import
{
AbstractInternalPresentational
}
from
"
../../../../core/components/presentationals/abstract-internal/abstract-internal.presentational
"
;
import
{
SOLIDIFY_CONSTANTS
}
from
"
../../../../core/constants
"
;
import
{
isEmptyString
,
isNonEmptyArray
,
isNotNullNorUndefined
,
isNotNullNorUndefinedNorWhiteString
,
...
...
@@ -79,6 +80,7 @@ class FileNode {
export
class
FolderTreePresentational
<
TDataFile
extends
any
>
extends
AbstractInternalPresentational
implements
OnInit
,
AfterViewInit
{
private
readonly
_SEPARATOR
:
string
=
SOLIDIFY_CONSTANTS
.
SEPARATOR
;
readonly
ROOT
:
string
=
SOLIDIFY_CONSTANTS
.
SEPARATOR
;
static
readonly
ROOT
:
string
=
SOLIDIFY_CONSTANTS
.
SEPARATOR
;
readonly
indentation
:
number
=
10
;
readonly
CDK_DROP_LIST_PREFIX
:
string
;
...
...
@@ -269,7 +271,13 @@ export class FolderTreePresentational<TDataFile extends any> extends AbstractInt
private
_expandFirstLevelTree
():
void
{
if
(
this
.
currentFolder
!==
this
.
ROOT
)
{
const
node
=
this
.
treeControl
.
dataNodes
.
find
(
d
=>
d
.
fullFolderName
===
this
.
currentFolder
);
let
node
=
this
.
treeControl
.
dataNodes
.
find
(
d
=>
d
.
fullFolderName
===
this
.
currentFolder
);
if
(
isNullOrUndefined
(
node
))
{
const
urlOfFolder
=
this
.
currentFolder
.
substring
(
0
,
this
.
currentFolder
.
lastIndexOf
(
this
.
_SEPARATOR
));
const
lastParentPath
=
!
isEmptyString
(
urlOfFolder
)
?
urlOfFolder
:
this
.
ROOT
;
node
=
this
.
treeControl
.
dataNodes
.
find
(
d
=>
d
.
fullFolderName
===
lastParentPath
);
this
.
currentFolder
=
lastParentPath
;
}
this
.
_expandRecursivelyParent
(
node
);
this
.
treeControl
.
expand
(
node
);
return
;
...
...
@@ -381,4 +389,36 @@ export class FolderTreePresentational<TDataFile extends any> extends AbstractInt
mouseOut
(
$event
:
MouseEvent
,
node
:
FileFlatNode
):
void
{
this
.
eventMouseOver
=
undefined
;
}
static
computeCurrentFolderAfterDelete
(
intermediateFolders
:
string
[],
foldersWithIntermediateFolders
:
string
[],
searchString
:
string
):
string
{
const
computeRecursively
=
(
currentSearchString
:
string
):
string
=>
{
// Extract the URL without the ROOT
const
url
=
currentSearchString
.
substring
(
0
,
currentSearchString
.
lastIndexOf
(
FolderTreePresentational
.
ROOT
));
if
(
isEmptyString
(
url
))
{
return
FolderTreePresentational
.
ROOT
;
}
else
{
const
folderWithIntFolders
=
foldersWithIntermediateFolders
.
find
(
folder
=>
folder
===
url
);
const
intFolder
=
intermediateFolders
.
find
(
ft
=>
ft
===
folderWithIntFolders
);
if
(
isNotNullNorUndefined
(
intFolder
))
{
// Find a folder with a child.
const
parentWithChild
=
foldersWithIntermediateFolders
.
find
(
folder
=>
folder
.
startsWith
(
intFolder
)
&&
(
folder
.
length
===
searchString
.
length
&&
folder
!==
searchString
)
&&
folder
.
substring
(
intFolder
.
length
).
length
>
1
);
if
(
isNotNullNorUndefined
(
parentWithChild
))
{
return
intFolder
;
}
else
{
// Recursively call the internal function with the updated search string
return
computeRecursively
(
url
);
}
}
else
{
return
folderWithIntFolders
;
}
}
};
// Call the internal function with the original search string
return
computeRecursively
(
searchString
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment