Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
form-generator
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
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
Coscine
frontend
libraries
form-generator
Commits
fb4c4862
Commit
fb4c4862
authored
2 years ago
by
Benedikt Heinrichs
Browse files
Options
Downloads
Patches
Plain Diff
Fix: Deal with odd list handling
parent
1500b10a
Branches
Issue/2345-dealWithWeirdLists
No related tags found
1 merge request
!117
Fix: List Handling
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/components/WrapperInput.vue
+47
-11
47 additions, 11 deletions
src/components/WrapperInput.vue
with
47 additions
and
11 deletions
src/components/WrapperInput.vue
+
47
−
11
View file @
fb4c4862
...
...
@@ -485,8 +485,8 @@ export default defineComponent({
this
.
initFixedValues
();
},
metadata
()
{
this
.
initMetadata
();
this
.
setValuesFromMetadataValues
();
this
.
fillMetadata
();
},
},
beforeMount
()
{
...
...
@@ -509,6 +509,15 @@ export default defineComponent({
}
this
.
setFixedValues
(
this
.
values
);
},
fillMetadata
()
{
// Set values if they don't exist
if
(
!
this
.
values
.
length
)
{
const
numberOfNewFields
=
this
.
isNode
?
0
:
1
;
// Setting more than one will not work since a dataset does not support multiple triples
// which are the same ?s ?p ?o
this
.
insertNewFields
(
numberOfNewFields
);
}
},
initDefaultValues
()
{
if
(
(
!
this
.
values
.
length
||
...
...
@@ -563,13 +572,7 @@ export default defineComponent({
},
initMetadata
()
{
this
.
values
=
[...
this
.
metadataValues
];
// Set values if they don't exist
if
(
!
this
.
values
.
length
)
{
const
numberOfNewFields
=
this
.
isNode
?
0
:
1
;
// Setting more than one will not work since a dataset does not support multiple triples
// which are the same ?s ?p ?o
this
.
insertNewFields
(
numberOfNewFields
);
}
this
.
fillMetadata
();
},
input
(
values
:
Quad_Object
[],
fixedValueTransfer
=
true
)
{
this
.
$emit
(
'
input
'
,
this
.
nodeName
,
values
);
...
...
@@ -640,16 +643,49 @@ export default defineComponent({
this
.
inputFixedValues
(
currentFixedValueObject
);
},
setValuesFromMetadataValues
()
{
this
.
values
=
this
.
values
.
filter
((
entry
)
=>
// What values will be kept from this.values
const
keptValues
=
this
.
values
.
map
((
entry
)
=>
this
.
metadataValues
.
some
(
(
metadataEntry
)
=>
entry
.
value
===
metadataEntry
.
value
)
?
entry
:
false
);
// What values are new in this.metadataValues
const
newValues
=
this
.
metadataValues
.
filter
(
(
metadataEntry
)
=>
!
this
.
values
.
some
((
entry
)
=>
entry
.
value
===
metadataEntry
.
value
)
!
keptValues
.
some
(
(
entry
)
=>
entry
!==
false
&&
entry
.
value
===
metadataEntry
.
value
)
);
this
.
values
=
[...
this
.
values
,
...
newValues
];
let
currentAddKey
=
0
;
const
removeKeys
:
number
[]
=
[];
// Update every value which is not kept with a new value
for
(
let
i
=
0
;
i
<
this
.
values
.
length
;
i
++
)
{
if
(
keptValues
[
i
]
===
false
)
{
if
(
currentAddKey
<
newValues
.
length
)
{
this
.
values
[
i
]
=
newValues
[
currentAddKey
];
currentAddKey
++
;
}
else
{
removeKeys
.
push
(
i
);
}
}
}
// Add values which have not been added
for
(
let
i
=
currentAddKey
;
i
<
newValues
.
length
;
i
++
)
{
this
.
values
.
push
(
newValues
[
i
]);
}
// Create a list with every to keep and new value
const
setNewValues
:
Quad_Object
[]
=
[];
for
(
let
i
=
0
;
i
<
this
.
values
.
length
;
i
++
)
{
if
(
!
removeKeys
.
includes
(
i
))
{
setNewValues
.
push
(
this
.
values
[
i
]);
}
}
this
.
values
=
setNewValues
;
},
triggerValidation
()
{
this
.
$emit
(
'
triggerValidation
'
);
...
...
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