Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
laboite
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Daniel Dehennin
laboite
Commits
ae8fa588
Commit
ae8fa588
authored
2 years ago
by
otho
Browse files
Options
Downloads
Patches
Plain Diff
fix(structure update): exclude concerned structure from search query
parent
30bb8657
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/imports/api/structures/methods.js
+1
-0
1 addition, 0 deletions
app/imports/api/structures/methods.js
app/imports/api/structures/utils.js
+16
-2
16 additions, 2 deletions
app/imports/api/structures/utils.js
with
17 additions
and
2 deletions
app/imports/api/structures/methods.js
+
1
−
0
View file @
ae8fa588
...
@@ -96,6 +96,7 @@ export const updateStructure = new ValidatedMethod({
...
@@ -96,6 +96,7 @@ export const updateStructure = new ValidatedMethod({
const
structuresWithSameNameOnSameLevel
=
isAStructureWithSameNameExistWithSameParent
({
const
structuresWithSameNameOnSameLevel
=
isAStructureWithSameNameExistWithSameParent
({
name
,
name
,
parentId
:
structure
.
parentId
,
parentId
:
structure
.
parentId
,
structureId
:
structure
.
_id
,
});
});
if
(
structuresWithSameNameOnSameLevel
)
{
if
(
structuresWithSameNameOnSameLevel
)
{
...
...
This diff is collapsed.
Click to expand it.
app/imports/api/structures/utils.js
+
16
−
2
View file @
ae8fa588
...
@@ -11,8 +11,22 @@ export const hasAdminRightOnStructure = ({ userId, structureId }) => {
...
@@ -11,8 +11,22 @@ export const hasAdminRightOnStructure = ({ userId, structureId }) => {
return
isAdmin
;
return
isAdmin
;
};
};
export
const
isAStructureWithSameNameExistWithSameParent
=
({
name
,
parentId
})
=>
{
export
const
isAStructureWithSameNameExistWithSameParent
=
({
name
,
parentId
,
structureId
=
undefined
})
=>
{
const
regExp
=
new
RegExp
(
`^
${
name
}
$`
,
'
i
'
);
const
regExp
=
new
RegExp
(
`^
${
name
}
$`
,
'
i
'
);
const
structuresWithSameNameOnSameLevel
=
Structures
.
find
({
name
:
{
$regex
:
regExp
},
parentId
});
const
query
=
{
name
:
{
$regex
:
regExp
},
parentId
,
};
// structureId will be undefined if we are in a create-structure scenario
// so, don't need to use it
// otherwise, we need to exclude the concerned structure from the query
// that's why we use `$ne` clause/operator
if
(
typeof
structureId
===
'
string
'
)
{
query
.
_id
=
{
$ne
:
structureId
};
}
const
structuresWithSameNameOnSameLevel
=
Structures
.
find
({
...
query
,
});
return
structuresWithSameNameOnSameLevel
.
count
()
>
0
;
return
structuresWithSameNameOnSameLevel
.
count
()
>
0
;
};
};
This diff is collapsed.
Click to expand it.
Ghost User
@ghost
mentioned in commit
26552c79
·
2 years ago
mentioned in commit
26552c79
mentioned in commit 26552c7912199c635be7edd0191d17f7937c01d0
Toggle commit list
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