Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
epoc-editor
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
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
Admin message
GitLab upgrade completed. Current version is 17.11.3.
Show more breadcrumbs
learninglab
epoc
epoc-editor
Commits
b5370658
Commit
b5370658
authored
2 years ago
by
VIAUD Nathan
Browse files
Options
Downloads
Patches
Plain Diff
Adding add/remove repeat input to undo
parent
ff60879e
Branches
Branches containing commit
No related tags found
1 merge request
!47
Draft: Resolve "Adding undo/redo"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/features/forms/components/GenericField.vue
+44
-5
44 additions, 5 deletions
src/features/forms/components/GenericField.vue
src/shared/services/graph/form.service.ts
+3
-1
3 additions, 1 deletion
src/shared/services/graph/form.service.ts
with
47 additions
and
6 deletions
src/features/forms/components/GenericField.vue
+
44
−
5
View file @
b5370658
<
script
setup
lang=
"ts"
>
import
{
FormRepeatChangeAction
,
FormRepeatMoveAction
,
FormUpdatedAction
,
Input
}
from
'
@/src/shared/interfaces
'
;
import
{
FormRepeatChangeAction
,
FormRepeatMoveAction
,
FormRepeatMutateAction
,
FormUpdatedAction
,
Input
}
from
'
@/src/shared/interfaces
'
;
import
GenericInput
from
'
./inputs/GenericInput.vue
'
;
import
{
useEditorStore
,
useUndoRedoStore
}
from
'
@/src/shared/stores
'
;
import
{
graphService
}
from
'
@/src/shared/services
'
;
...
...
@@ -77,6 +77,9 @@ function onRepeatInput(value, id: string) {
}
function
handleAddRepeatInput
(
element
,
value
,
id
:
string
):
void
{
addRepeatAddUndoAction
(
id
,
value
.
defaultValues
);
const
formValues
=
element
?
element
.
formValues
:
currentNode
.
data
.
formValues
;
if
(
!
formValues
[
id
])
formValues
[
id
]
=
[];
formValues
[
id
].
push
(
value
.
defaultValues
);
...
...
@@ -84,9 +87,15 @@ function handleAddRepeatInput(element, value, id: string): void {
function
handleRemoveRepeatInput
(
element
,
value
,
id
:
string
):
void
{
const
formValues
=
element
?
element
.
formValues
[
id
]
:
currentNode
.
data
.
formValues
[
id
];
const
savedInput
=
JSON
.
stringify
(
formValues
[
value
.
index
]);
addRepeatRemoveUndoAction
(
id
,
value
.
index
,
savedInput
);
formValues
.
splice
(
value
.
index
,
1
);
const
currentElement
=
currentNode
.
data
.
elements
?.[
value
.
index
];
if
(
!
editorStore
.
openedNodeId
&&
currentElement
)
{
deleteElement
(
currentElement
.
id
,
currentElement
.
parentId
);
}
...
...
@@ -94,7 +103,7 @@ function handleRemoveRepeatInput(element, value, id: string): void {
function
handleMoveRepeatInput
(
element
,
value
,
id
:
string
):
void
{
onAdd
MoveUndoAction
(
id
,
value
.
oldIndex
,
value
.
newIndex
);
addRepeat
MoveUndoAction
(
id
,
value
.
oldIndex
,
value
.
newIndex
);
if
(
currentNode
.
data
.
elements
&&
!
editorStore
.
openedNodeId
)
{
changeContentOrder
(
value
.
oldIndex
,
value
.
newIndex
,
currentNode
.
id
);
...
...
@@ -118,7 +127,7 @@ function handleChangeRepeatInput(element, value, id: string): void {
}
}
function
onAdd
ChangeUndoAction
(
repeatEvent
,
formValueId
:
string
):
void
{
function
addRepeat
ChangeUndoAction
(
repeatEvent
,
formValueId
:
string
):
void
{
const
{
type
,
value
,
index
,
id
}
=
repeatEvent
;
const
action
:
FormRepeatChangeAction
=
{
...
...
@@ -136,7 +145,7 @@ function onAddChangeUndoAction(repeatEvent, formValueId: string): void {
undoRedoStore
.
addAction
(
action
);
}
function
onAdd
MoveUndoAction
(
formValueId
:
string
,
oldIndex
:
number
,
newIndex
:
number
):
void
{
function
addRepeat
MoveUndoAction
(
formValueId
:
string
,
oldIndex
:
number
,
newIndex
:
number
):
void
{
const
action
:
FormRepeatMoveAction
=
{
type
:
'
formRepeatUpdated
'
,
...
...
@@ -150,6 +159,36 @@ function onAddMoveUndoAction(formValueId: string, oldIndex: number, newIndex: nu
undoRedoStore
.
addAction
(
action
);
}
function
addRepeatAddUndoAction
(
id
,
defaultValues
):
void
{
const
action
:
FormRepeatMutateAction
=
{
type
:
'
formRepeatUpdated
'
,
nodeId
:
currentNode
.
id
,
elementId
:
editorStore
.
openedElementId
,
formValueId
:
id
,
updateType
:
'
add
'
,
value
:
defaultValues
,
index
:
-
1
};
undoRedoStore
.
addAction
(
action
);
}
function
addRepeatRemoveUndoAction
(
id
,
index
,
value
):
void
{
const
action
:
FormRepeatMutateAction
=
{
type
:
'
formRepeatUpdated
'
,
nodeId
:
currentNode
.
id
,
elementId
:
editorStore
.
openedElementId
,
formValueId
:
id
,
updateType
:
'
remove
'
,
value
,
index
};
undoRedoStore
.
addAction
(
action
);
}
// Repeat Input end
function
onCheck
(
value
:
boolean
,
id
:
string
)
{
...
...
@@ -190,7 +229,7 @@ function onAddUndoAction(value: { oldValue: string, newValue: string }, id: stri
@
check=
"onCheck($event, input.id)"
@
repeat-input=
"onRepeatInput($event, input.id)"
@
add-undo-action=
"onAddUndoAction($event, input.id)"
@
add-repeat-undo-action=
"
onAdd
ChangeUndoAction($event, input.id)"
@
add-repeat-undo-action=
"
addRepeat
ChangeUndoAction($event, input.id)"
/>
</
template
>
...
...
This diff is collapsed.
Click to expand it.
src/shared/services/graph/form.service.ts
+
3
−
1
View file @
b5370658
...
...
@@ -34,7 +34,9 @@ export function addRepeatElement(elementId: string, nodeId: string, formValueId:
verifyAndOpenFormPanel
(
id
,
formType
,
formValues
,
nodeId
);
formValues
[
formValueId
].
splice
(
index
,
0
,
repeatElement
);
repeatElement
=
JSON
.
parse
(
repeatElement
);
index
===
-
1
?
formValues
[
formValueId
].
push
(
repeatElement
)
:
formValues
[
formValueId
].
splice
(
index
,
0
,
repeatElement
);
}
export
function
moveRepeatElement
(
elementId
:
string
,
nodeId
:
string
,
formValueId
:
string
,
oldIndex
:
number
,
newIndex
:
number
):
void
{
...
...
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