Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fc-pregmod
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
macaronideath
fc-pregmod
Commits
cb86fb41
Commit
cb86fb41
authored
4 years ago
by
lowercasedonkey
Browse files
Options
Downloads
Patches
Plain Diff
move repeal out of the main loop
parent
b40f8e72
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/interaction/policies/policies.js
+60
-34
60 additions, 34 deletions
src/interaction/policies/policies.js
with
60 additions
and
34 deletions
src/interaction/policies/policies.js
+
60
−
34
View file @
cb86fb41
...
@@ -122,22 +122,63 @@ globalThis.policy = function(category) {
...
@@ -122,22 +122,63 @@ globalThis.policy = function(category) {
let
div
;
let
div
;
let
span
;
let
span
;
let
link
;
let
link
;
let
policyValue
=
_
.
get
(
V
.
policies
,
selectedPolicy
[
0
].
policy
);
if
(
policyValue
===
0
)
{
// apply
for
(
let
i
=
0
;
i
<
selectedPolicy
.
length
;
i
++
)
{
const
p
=
selectedPolicy
[
i
];
policyValue
=
_
.
get
(
V
.
policies
,
p
.
policy
);
for
(
let
i
=
0
;
i
<
selectedPolicy
.
length
;
i
++
)
{
testArray
(
p
);
const
p
=
selectedPolicy
[
i
];
div
=
document
.
createElement
(
"
div
"
);
const
policyValue
=
_
.
get
(
V
.
policies
,
p
.
policy
);
span
=
document
.
createElement
(
"
span
"
);
// title
span
.
style
.
fontWeight
=
"
bold
"
;
span
.
textContent
=
p
.
title
;
div
.
append
(
span
);
div
.
append
(
`: `
);
// If we can repeal any policy, hide the others.
// Description text
if
(
policyValue
!==
0
)
{
div
.
append
(
p
.
text
);
if
(
selectedPolicy
.
length
===
2
)
{
// If it's length of two, we just need to hide the wrong one. Also, it uses -1.
div
.
append
(
` `
);
if
((
i
===
0
&&
policyValue
===
-
1
)
||
(
i
===
1
&&
policyValue
===
1
))
{
//console.log(`selectedPolicy is `, p.policy, `and policyValue is: `, policyValue, `i: `, i);
continue
;
// link
if
(
policyValue
===
0
)
{
let
enable
;
if
(
i
===
1
&&
selectedPolicy
.
length
===
2
)
{
enable
=
-
1
;
}
else
{
enable
=
i
+
1
;
}
if
(
p
.
hasOwnProperty
(
"
requirements
"
))
{
if
(
p
.
requirements
())
{
implement
(
p
,
enable
);
}
else
{
link
=
App
.
UI
.
DOM
.
disabledLink
(
"
Implement
"
,
[
`You do not meet the requirments, or passed a conflicting policy already`
]);
link
.
style
.
color
=
"
white
"
;
div
.
append
(
link
);
el
.
append
(
div
);
}
}
else
{
implement
(
p
,
enable
);
}
}
}
else
if
(
i
!==
policyValue
-
1
)
{
// Otherwise, the policyValue should be the place in the array, starting from 1 since 0 represents off, so we offset.
continue
;
}
}
}
}
}
else
{
// repeal
let
i
;
if
(
selectedPolicy
.
length
===
2
)
{
// Tall vs short, -1 vs 1.
if
(
policyValue
===
1
)
{
i
=
0
;
// first element of array
}
else
if
(
policyValue
===
-
1
)
{
i
=
1
;
}
}
else
{
i
=
policyValue
-
1
;
}
const
p
=
selectedPolicy
[
i
];
policyValue
=
_
.
get
(
V
.
policies
,
p
.
policy
);
testArray
(
p
);
testArray
(
p
);
div
=
document
.
createElement
(
"
div
"
);
div
=
document
.
createElement
(
"
div
"
);
span
=
document
.
createElement
(
"
span
"
);
span
=
document
.
createElement
(
"
span
"
);
...
@@ -149,34 +190,19 @@ globalThis.policy = function(category) {
...
@@ -149,34 +190,19 @@ globalThis.policy = function(category) {
div
.
append
(
`: `
);
div
.
append
(
`: `
);
// Description text
// Description text
div
.
append
(
p
.
text
);
// TODO: "activatedText" if available
if
(
p
.
hasOwnProperty
(
"
activatedText
"
))
{
div
.
append
(
p
.
activatedText
);
}
else
{
div
.
append
(
p
.
text
);
}
div
.
append
(
` `
);
div
.
append
(
` `
);
//console.log(`selectedPolicy is `, p.policy, `and policyValue is: `, policyValue, `i: `, i);
//console.log(`selectedPolicy is `, p.policy, `and policyValue is: `, policyValue, `i: `, i);
// link
// link
if
(
policyValue
===
0
)
{
repeal
(
p
);
let
enable
;
if
(
i
===
1
&&
selectedPolicy
.
length
===
2
)
{
enable
=
-
1
;
}
else
{
enable
=
i
+
1
;
}
if
(
p
.
hasOwnProperty
(
"
requirements
"
))
{
if
(
p
.
requirements
())
{
implement
(
p
,
enable
);
}
else
{
link
=
App
.
UI
.
DOM
.
disabledLink
(
"
Implement
"
,
[
`You do not meet the requirments, or passed a conflicting policy already`
]);
link
.
style
.
color
=
"
white
"
;
div
.
append
(
link
);
el
.
append
(
div
);
}
}
else
{
implement
(
p
,
enable
);
}
}
else
{
repeal
(
p
);
}
}
}
return
el
;
return
el
;
function
testArray
(
p
)
{
function
testArray
(
p
)
{
...
...
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