Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
basic
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor 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
xrm
basic
Commits
3fe1e405
Commit
3fe1e405
authored
5 years ago
by
Simon Leipold
Browse files
Options
Downloads
Patches
Plain Diff
[Projekt: Entwicklung - Neon][TicketNr.: 1049945][Rollen - Fehler bei Zuweisung von Kindrollen]
parent
15187ddc
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
entity/Role_entity/Role_entity.aod
+1
-0
1 addition, 0 deletions
entity/Role_entity/Role_entity.aod
entity/Role_entity/entityfields/rolechildrens/onValidation.js
+70
-0
70 additions, 0 deletions
...ty/Role_entity/entityfields/rolechildrens/onValidation.js
with
71 additions
and
0 deletions
entity/Role_entity/Role_entity.aod
+
1
−
0
View file @
3fe1e405
...
...
@@ -126,6 +126,7 @@
</entityField>
<entityConsumer>
<name>
RoleChildrens
</name>
<onValidation>
%aditoprj%/entity/Role_entity/entityfields/rolechildrens/onValidation.js
</onValidation>
<dependency>
<name>
dependency
</name>
<entityName>
RoleChildren_entity
</entityName>
...
...
This diff is collapsed.
Click to expand it.
entity/Role_entity/entityfields/rolechildrens/onValidation.js
0 → 100644
+
70
−
0
View file @
3fe1e405
import
(
"
system.result
"
);
import
(
"
Sql_lib
"
);
import
(
"
system.logging
"
);
import
(
"
system.vars
"
);
var
changedRows
=
vars
.
get
(
"
$field.RoleChildrens.changedRows
"
);
var
insertedRows
=
vars
.
get
(
"
$field.RoleChildrens.insertedRows
"
);
// check for duplicates
for
each
(
let
row
in
insertedRows
)
{
if
(
isRoleAlreadyChildren
(
row
))
{
result
.
string
(
"
No duplicates allowed!
"
);
}
}
for
each
(
let
row
in
changedRows
)
{
if
(
isRoleAlreadyChildren
(
row
))
{
result
.
string
(
"
No duplicates allowed!
"
);
}
}
function
isRoleAlreadyChildren
(
pRole
)
{
var
alias
=
SqlUtils
.
getSystemAlias
();
var
parentRoleName
=
vars
.
get
(
"
$field.ROLENAME
"
)
var
childRoles
=
newSelect
(
"
CHILD_ROLE
"
,
alias
)
.
from
(
"
ASYS_ROLES_CHILDREN
"
)
.
where
(
"
ASYS_ROLES_CHILDREN.PARENT_ROLE
"
,
parentRoleName
)
.
table
();
// check for duplicates in database
for
each
(
let
child
in
childRoles
)
{
if
(
child
==
pRole
.
CHILD_ROLE
)
{
return
true
;
}
}
// check for duplicate in changed or inserted rows
if
(
checkDuplicateInObject
(
"
CHILD_ROLE
"
,
changedRows
)
||
checkDuplicateInObject
(
"
CHILD_ROLE
"
,
insertedRows
))
return
true
;
// crosscheck for duplicates in inserted and changed rows
for
each
(
let
insRow
in
insertedRows
)
{
for
each
(
let
chaRow
in
changedRows
)
{
if
(
insRow
.
CHILD_ROLE
==
chaRow
.
CHILD_ROLE
)
{
return
true
;
}
}
}
return
false
;
}
function
checkDuplicateInObject
(
propertyName
,
inputArray
)
{
var
seenDuplicate
=
false
,
testObject
=
{};
inputArray
.
map
(
function
(
item
)
{
var
itemPropertyName
=
item
[
propertyName
];
if
(
itemPropertyName
in
testObject
)
{
testObject
[
itemPropertyName
].
duplicate
=
true
;
item
.
duplicate
=
true
;
seenDuplicate
=
true
;
}
else
{
testObject
[
itemPropertyName
]
=
item
;
delete
item
.
duplicate
;
}
});
return
seenDuplicate
;
}
\ No newline at end of file
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