Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Dspace7 Angular
Manage
Activity
Members
Labels
Plan
Issues
42
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
code.vt.edu will be down for maintenance from 0530-0630 EDT Wednesday, March 26th
Show more breadcrumbs
vtechworks
Dspace7 Angular
Commits
509fd0d8
Commit
509fd0d8
authored
5 years ago
by
Giuseppe Digilio
Browse files
Options
Downloads
Patches
Plain Diff
Fixed an issue while editing repeatable fields
parent
861f8ddb
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/app/submission/sections/form/section-form.component.ts
+36
-2
36 additions, 2 deletions
src/app/submission/sections/form/section-form.component.ts
with
36 additions
and
2 deletions
src/app/submission/sections/form/section-form.component.ts
+
36
−
2
View file @
509fd0d8
...
...
@@ -64,6 +64,12 @@ export class SubmissionSectionformComponent extends SectionModelComponent {
*/
public
isLoading
=
true
;
/**
* A map representing all field on their way to be removed
* @type {Map}
*/
protected
fieldsOnTheirWayToBeRemoved
:
Map
<
string
,
number
[]
>
=
new
Map
();
/**
* The form config
* @type {SubmissionFormsModel}
...
...
@@ -295,6 +301,7 @@ export class SubmissionSectionformComponent extends SectionModelComponent {
}),
distinctUntilChanged
())
.
subscribe
((
sectionState
:
SubmissionSectionObject
)
=>
{
this
.
fieldsOnTheirWayToBeRemoved
=
new
Map
();
this
.
updateForm
(
sectionState
.
data
as
WorkspaceitemSectionFormObject
,
sectionState
.
errors
);
})
)
...
...
@@ -348,11 +355,24 @@ export class SubmissionSectionformComponent extends SectionModelComponent {
* the [[DynamicFormControlEvent]] emitted
*/
onRemove
(
event
:
DynamicFormControlEvent
):
void
{
const
fieldId
=
this
.
formBuilderService
.
getId
(
event
.
model
);
const
fieldIndex
=
this
.
formOperationsService
.
getArrayIndexFromEvent
(
event
);
// Keep track that this field will be removed
if
(
this
.
fieldsOnTheirWayToBeRemoved
.
has
(
fieldId
))
{
const
indexes
=
this
.
fieldsOnTheirWayToBeRemoved
.
get
(
fieldId
);
indexes
.
push
(
fieldIndex
);
this
.
fieldsOnTheirWayToBeRemoved
.
set
(
fieldId
,
indexes
);
}
else
{
this
.
fieldsOnTheirWayToBeRemoved
.
set
(
fieldId
,
[
fieldIndex
]);
}
this
.
formOperationsService
.
dispatchOperationsFromEvent
(
this
.
pathCombiner
,
event
,
this
.
previousValue
,
this
.
hasStoredValue
(
this
.
formBuilderService
.
getId
(
event
.
model
),
this
.
formOperationsService
.
getArrayIndexFromEvent
(
event
)));
this
.
hasStoredValue
(
fieldId
,
fieldIndex
));
}
/**
...
...
@@ -365,9 +385,23 @@ export class SubmissionSectionformComponent extends SectionModelComponent {
*/
hasStoredValue
(
fieldId
,
index
):
boolean
{
if
(
isNotEmpty
(
this
.
sectionData
.
data
))
{
return
this
.
sectionData
.
data
.
hasOwnProperty
(
fieldId
)
&&
isNotEmpty
(
this
.
sectionData
.
data
[
fieldId
][
index
]);
return
this
.
sectionData
.
data
.
hasOwnProperty
(
fieldId
)
&&
isNotEmpty
(
this
.
sectionData
.
data
[
fieldId
][
index
])
&&
!
this
.
isFieldToRemove
(
fieldId
,
index
);
}
else
{
return
false
;
}
}
/**
* Check if the specified field is on the way to be removed
*
* @param fieldId
* the section data retrieved from the serverù
* @param index
* the section data retrieved from the server
*/
isFieldToRemove
(
fieldId
,
index
)
{
return
this
.
fieldsOnTheirWayToBeRemoved
.
has
(
fieldId
)
&&
this
.
fieldsOnTheirWayToBeRemoved
.
get
(
fieldId
).
includes
(
index
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
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