Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
RLG Maker
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Romain DELEAU
RLG Maker
Commits
4478a65f
Commit
4478a65f
authored
Oct 11, 2023
by
Romain DELEAU
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rework move up/down tasks with possibility to put a task at the same index if there is space
parent
10f32d81
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
2 deletions
+78
-2
role.ts
src/app/class/role/role.ts
+78
-2
No files found.
src/app/class/role/role.ts
View file @
4478a65f
...
@@ -53,7 +53,7 @@ export class Role {
...
@@ -53,7 +53,7 @@ export class Role {
}
}
public
moveTask
(
i
:
number
,
j
:
number
,
direction
:
string
):
void
{
public
moveTask
(
i
:
number
,
j
:
number
,
direction
:
string
):
void
{
let
tmp
:
Task
|
null
=
this
.
tasks
[
i
][
j
];
let
tmp
:
Task
|
null
=
this
.
tasks
[
i
][
j
]
as
Task
;
if
(
direction
==
'left'
)
{
if
(
direction
==
'left'
)
{
this
.
tasks
[
i
][
j
]
=
this
.
tasks
[
i
][
j
-
1
];
this
.
tasks
[
i
][
j
]
=
this
.
tasks
[
i
][
j
-
1
];
...
@@ -69,16 +69,29 @@ export class Role {
...
@@ -69,16 +69,29 @@ export class Role {
if
(
this
.
tasks
[
i
][
j
]?.
type
==
'final'
||
this
.
tasks
[
i
][
j
]?.
type
==
'repeat'
)
{
if
(
this
.
tasks
[
i
][
j
]?.
type
==
'final'
||
this
.
tasks
[
i
][
j
]?.
type
==
'repeat'
)
{
this
.
tasks
[
i
][
j
]
=
this
.
tasks
[
i
-
1
][
this
.
getLastTaskIndex
(
i
-
1
)];
this
.
tasks
[
i
][
j
]
=
this
.
tasks
[
i
-
1
][
this
.
getLastTaskIndex
(
i
-
1
)];
this
.
tasks
[
i
-
1
][
this
.
getLastTaskIndex
(
i
-
1
)]
=
tmp
;
this
.
tasks
[
i
-
1
][
this
.
getLastTaskIndex
(
i
-
1
)]
=
tmp
;
}
else
if
(
this
.
thereIsSpace
(
i
-
1
,
this
.
getRealIndex
(
i
-
1
,
j
),
this
.
tasks
[
i
][
j
]
as
Task
))
{
this
.
tasks
[
i
-
1
][
this
.
getRealIndex
(
i
-
1
,
j
)]
=
tmp
;
this
.
tasks
[
i
][
j
]
=
null
;
this
.
tasks
[
i
-
1
].
splice
(
this
.
getRealIndex
(
i
-
1
,
j
)
+
1
,
tmp
?.
duration
-
1
);
for
(
let
index
=
1
;
index
<
tmp
.
duration
;
index
++
)
{
this
.
tasks
[
i
].
splice
(
j
+
index
,
0
,
null
);
}
}
else
{
}
else
{
let
deplace
=
this
.
tasks
[
i
-
1
][
this
.
getLastTaskIndex
(
i
-
1
)];
let
deplace
=
this
.
tasks
[
i
-
1
][
this
.
getLastTaskIndex
(
i
-
1
)];
this
.
tasks
[
i
-
1
][
this
.
getLastTaskIndex
(
i
-
1
)]
=
tmp
;
this
.
tasks
[
i
-
1
][
this
.
getLastTaskIndex
(
i
-
1
)]
=
tmp
;
this
.
tasks
[
i
-
1
][
this
.
getLastTaskIndex
(
i
-
1
)
+
1
]
=
deplace
;
this
.
tasks
[
i
-
1
][
this
.
getLastTaskIndex
(
i
-
1
)
+
1
]
=
deplace
;
this
.
tasks
[
i
][
j
]
=
null
;
this
.
tasks
[
i
][
j
]
=
null
;
}
}
}
else
if
(
this
.
thereIsSpace
(
i
-
1
,
this
.
getRealIndex
(
i
-
1
,
j
),
this
.
tasks
[
i
][
j
]
as
Task
))
{
this
.
tasks
[
i
-
1
][
this
.
getRealIndex
(
i
-
1
,
j
)]
=
tmp
;
this
.
tasks
[
i
][
j
]
=
null
;
this
.
tasks
[
i
-
1
].
splice
(
this
.
getRealIndex
(
i
-
1
,
j
)
+
1
,
tmp
.
duration
-
1
);
for
(
let
index
=
1
;
index
<
tmp
.
duration
;
index
++
)
{
this
.
tasks
[
i
].
splice
(
j
+
index
,
0
,
null
);
}
}
else
{
}
else
{
this
.
tasks
[
i
-
1
][
this
.
getLastTaskIndex
(
i
-
1
)
+
1
]
=
tmp
;
this
.
tasks
[
i
-
1
][
this
.
getLastTaskIndex
(
i
-
1
)
+
1
]
=
tmp
;
this
.
tasks
[
i
][
j
]
=
null
;
this
.
tasks
[
i
][
j
]
=
null
;
}
}
if
(
!
this
.
tasks
[
i
].
some
(
element
=>
element
instanceof
Task
))
{
if
(
!
this
.
tasks
[
i
].
some
(
element
=>
element
instanceof
Task
))
{
this
.
tasks
.
splice
(
i
,
1
);
this
.
tasks
.
splice
(
i
,
1
);
...
@@ -94,12 +107,26 @@ export class Role {
...
@@ -94,12 +107,26 @@ export class Role {
if
(
this
.
tasks
[
i
][
j
]?.
type
==
'final'
||
this
.
tasks
[
i
][
j
]?.
type
==
'repeat'
)
{
if
(
this
.
tasks
[
i
][
j
]?.
type
==
'final'
||
this
.
tasks
[
i
][
j
]?.
type
==
'repeat'
)
{
this
.
tasks
[
i
][
j
]
=
this
.
tasks
[
i
+
1
][
this
.
getLastTaskIndex
(
i
+
1
)];
this
.
tasks
[
i
][
j
]
=
this
.
tasks
[
i
+
1
][
this
.
getLastTaskIndex
(
i
+
1
)];
this
.
tasks
[
i
+
1
][
this
.
getLastTaskIndex
(
i
+
1
)]
=
tmp
;
this
.
tasks
[
i
+
1
][
this
.
getLastTaskIndex
(
i
+
1
)]
=
tmp
;
}
else
if
(
this
.
thereIsSpace
(
i
+
1
,
this
.
getRealIndex
(
i
+
1
,
j
),
this
.
tasks
[
i
][
j
]
as
Task
))
{
this
.
tasks
[
i
+
1
][
this
.
getRealIndex
(
i
+
1
,
j
)]
=
tmp
;
this
.
tasks
[
i
][
j
]
=
null
;
this
.
tasks
[
i
+
1
].
splice
(
this
.
getRealIndex
(
i
+
1
,
j
)
+
1
,
tmp
?.
duration
-
1
);
for
(
let
index
=
1
;
index
<
tmp
.
duration
;
index
++
)
{
this
.
tasks
[
i
].
splice
(
j
+
index
,
0
,
null
);
}
}
else
{
}
else
{
let
deplace
=
this
.
tasks
[
i
+
1
][
this
.
getLastTaskIndex
(
i
+
1
)];
let
deplace
=
this
.
tasks
[
i
+
1
][
this
.
getLastTaskIndex
(
i
+
1
)];
this
.
tasks
[
i
+
1
][
this
.
getLastTaskIndex
(
i
+
1
)]
=
tmp
;
this
.
tasks
[
i
+
1
][
this
.
getLastTaskIndex
(
i
+
1
)]
=
tmp
;
this
.
tasks
[
i
+
1
][
this
.
getLastTaskIndex
(
i
+
1
)
+
1
]
=
deplace
;
this
.
tasks
[
i
+
1
][
this
.
getLastTaskIndex
(
i
+
1
)
+
1
]
=
deplace
;
this
.
tasks
[
i
][
j
]
=
null
;
this
.
tasks
[
i
][
j
]
=
null
;
}
}
}
else
if
(
this
.
thereIsSpace
(
i
+
1
,
this
.
getRealIndex
(
i
+
1
,
j
),
this
.
tasks
[
i
][
j
]
as
Task
))
{
this
.
tasks
[
i
+
1
][
this
.
getRealIndex
(
i
+
1
,
j
)]
=
tmp
;
this
.
tasks
[
i
][
j
]
=
null
;
this
.
tasks
[
i
+
1
].
splice
(
this
.
getRealIndex
(
i
+
1
,
j
)
+
1
,
tmp
.
duration
-
1
);
for
(
let
index
=
1
;
index
<
tmp
.
duration
;
index
++
)
{
this
.
tasks
[
i
].
splice
(
j
+
index
,
0
,
null
);
}
}
else
{
}
else
{
this
.
tasks
[
i
+
1
][
this
.
getLastTaskIndex
(
i
+
1
)
+
1
]
=
tmp
;
this
.
tasks
[
i
+
1
][
this
.
getLastTaskIndex
(
i
+
1
)
+
1
]
=
tmp
;
this
.
tasks
[
i
][
j
]
=
null
;
this
.
tasks
[
i
][
j
]
=
null
;
...
@@ -107,6 +134,55 @@ export class Role {
...
@@ -107,6 +134,55 @@ export class Role {
}
}
}
}
thereIsSpace
(
iDest
:
number
,
j
:
number
,
task
:
Task
):
boolean
{
let
res
:
boolean
=
true
;
let
spaceNecessary
:
number
=
0
;
if
(
task
.
durationUnit
==
'UT'
)
{
if
(
task
.
duration
<
10
)
{
spaceNecessary
=
task
.
duration
;
}
else
{
spaceNecessary
=
10
;
}
}
else
{
spaceNecessary
=
1
;
}
for
(
let
i
=
0
;
i
<
spaceNecessary
;
i
++
)
{
if
(
this
.
tasks
[
iDest
][
j
+
i
]
!=
null
)
{
res
=
false
;
}
}
return
res
;
}
getRealIndex
(
i
:
number
,
j
:
number
):
number
{
let
realj
:
number
=
0
;
let
index
:
number
=
0
;
while
(
index
<
j
)
{
let
task
:
Task
|
null
=
this
.
tasks
[
i
][
index
];
if
(
task
instanceof
Task
)
{
if
(
task
.
durationUnit
==
'UT'
)
{
if
(
task
.
duration
<=
10
)
{
index
=
index
+
task
.
duration
;
realj
++
;
}
else
{
index
=
index
+
10
;
realj
++
;
}
}
else
{
realj
++
;
index
++
;
}
}
else
{
realj
++
;
index
++
;
}
}
console
.
log
(
realj
);
return
realj
;
}
public
moveStep
(
i
:
number
,
direction
:
string
):
void
{
public
moveStep
(
i
:
number
,
direction
:
string
):
void
{
let
tmp
:
Step
|
null
=
this
.
chronologie
[
i
];
let
tmp
:
Step
|
null
=
this
.
chronologie
[
i
];
if
(
direction
==
'left'
)
{
if
(
direction
==
'left'
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment