Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Helmholtz Centre for Environmental Research – UFZ
IT
RDM
BioMe
tmd
frontend
Commits
b7da8d4d
Commit
b7da8d4d
authored
3 years ago
by
Lars Kollmann
Browse files
Options
Downloads
Patches
Plain Diff
#156
finalize validation and error handling, add alert if selected transect has no sections
parent
cb480254
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!174
Merge develop into master
,
!150
Resolve "Begehung: Refactor Error handling (create/update)"
Pipeline
#420072
passed
3 years ago
Stage: build
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/src/i18n/deutsch.json
+2
-1
2 additions, 1 deletion
app/src/i18n/deutsch.json
app/src/i18n/english.json
+2
-1
2 additions, 1 deletion
app/src/i18n/english.json
app/src/views/TransectInspection.ts
+73
-59
73 additions, 59 deletions
app/src/views/TransectInspection.ts
with
77 additions
and
61 deletions
app/src/i18n/deutsch.json
+
2
−
1
View file @
b7da8d4d
...
...
@@ -121,7 +121,8 @@
"invalidTime"
:
"Es muss eine gültige Uhrzeit ausgewählt werden"
,
"requiredTime"
:
"Es muss eine Uhrzeit ausgewählt werden"
,
"requiredDate"
:
"Es muss ein Datum ausgewählt werden"
,
"notAccessible"
:
"Nicht begehbar"
"notAccessible"
:
"Nicht begehbar"
,
"noSectionsForTransect"
:
"Das Transekt enthält keine Abschnitte"
}
},
"inspections"
:
{
...
...
This diff is collapsed.
Click to expand it.
app/src/i18n/english.json
+
2
−
1
View file @
b7da8d4d
...
...
@@ -121,7 +121,8 @@
"invalidTime"
:
"A valid time must be entered"
,
"requiredTime"
:
"Time must be entered"
,
"requiredDate"
:
"Date must be entered"
,
"notAccessible"
:
"Not accessible"
"notAccessible"
:
"Not accessible"
,
"noSectionsForTransect"
:
"The transect does not contain any sections"
}
},
"inspections"
:
{
...
...
This diff is collapsed.
Click to expand it.
app/src/views/TransectInspection.ts
+
73
−
59
View file @
b7da8d4d
...
...
@@ -65,46 +65,55 @@ export default class TransectInspection extends Vue {
@
Watch
(
"
inspectionData.headerData.transect
"
)
private
transectWatcher
()
{
this
.
hideAlerts
();
this
.
inspectionData
.
mainData
.
sections
=
[];
// Did this to avoid errors when toggling transect selection
this
.
getSections
(
this
.
inspectionData
.
headerData
.
transect
,
this
.
inspectionData
.
mainData
.
sections
)
.
then
();
.
then
((
data
:
any
)
=>
{
if
(
data
&&
data
.
errors
)
{
let
message
=
""
;
for
(
const
error
of
data
.
errors
)
{
message
=
message
.
concat
(
error
.
message
);
}
this
.
showErrorAlert
(
message
);
}
else
if
(
this
.
inspectionData
.
mainData
.
sections
.
length
===
0
)
{
this
.
showErrorAlert
(
this
.
$i18n
.
t
(
"
transektbegehung.errors.noSectionsForTransect
"
)
as
string
);
}
});
}
private
getSections
=
async
(
transect
:
string
,
sectionsArray
:
Section
[])
=>
{
const
data
=
await
this
.
getSectionsForTransect
(
transect
);
if
(
data
.
errors
||
!
this
.
validSectionData
(
data
))
{
// todo: add error handling
return
sectionsArray
;
}
const
sections
=
data
.
data
.
transect
.
sections
.
edges
;
for
(
let
i
=
0
;
i
<
sections
.
length
;
i
++
)
{
const
sectionNode
=
sections
[
i
].
node
;
const
newSection
:
Section
=
{
accessible
:
sectionNode
.
accessible
,
id
:
sectionNode
.
id
,
label
:
sectionNode
.
label
,
location
:
sectionNode
.
location
,
name
:
sectionNode
.
name
,
sequenceNumber
:
sectionNode
.
sequenceNumber
,
sectionEvent
:
{
id
:
""
,
comment
:
""
,
inspectionId
:
this
.
inspectionData
.
id
,
sectionId
:
sectionNode
.
id
,
observationTableRows
:
[],
imageRefs
:
[],
},
};
sectionsArray
.
push
(
newSection
);
}
sectionsArray
.
sort
((
a
,
b
)
=>
(
a
.
sequenceNumber
>
b
.
sequenceNumber
)
?
1
:
-
1
);
return
sectionsArray
;
if
(
data
.
errors
||
!
this
.
isValidSectionData
(
data
))
{
return
data
;
}
const
sections
=
data
.
data
.
transect
.
sections
.
edges
;
for
(
let
i
=
0
;
i
<
sections
.
length
;
i
++
)
{
const
sectionNode
=
sections
[
i
].
node
;
const
newSection
:
Section
=
{
accessible
:
sectionNode
.
accessible
,
id
:
sectionNode
.
id
,
label
:
sectionNode
.
label
,
location
:
sectionNode
.
location
,
name
:
sectionNode
.
name
,
sequenceNumber
:
sectionNode
.
sequenceNumber
,
sectionEvent
:
{
id
:
""
,
comment
:
""
,
inspectionId
:
this
.
inspectionData
.
id
,
sectionId
:
sectionNode
.
id
,
observationTableRows
:
[],
imageRefs
:
[],
},
};
sectionsArray
.
push
(
newSection
);
}
sectionsArray
.
sort
((
a
,
b
)
=>
(
a
.
sequenceNumber
>
b
.
sequenceNumber
)
?
1
:
-
1
);
return
sectionsArray
;
}
private
v
alidSectionData
(
data
:
any
)
{
private
isV
alidSectionData
(
data
:
any
)
{
return
(
data
&&
data
.
data
&&
data
.
data
.
transect
&&
data
.
data
.
transect
.
sections
&&
data
.
data
.
transect
.
sections
.
edges
);
}
...
...
@@ -185,37 +194,11 @@ export default class TransectInspection extends Vue {
});
}
private
getResponseErrors
(
response
:
any
)
{
// todo: collect all the errors and try to display in alert
for
(
const
item
of
response
)
{
if
(
item
.
errors
)
{
return
item
.
errors
[
0
].
message
;
}
for
(
const
itemChild
of
item
)
{
if
(
itemChild
.
errors
)
{
return
itemChild
.
errors
[
0
].
message
;
}
for
(
const
itemChildChild
of
itemChild
)
{
if
(
itemChildChild
.
errors
)
{
return
itemChildChild
.
errors
[
0
].
message
;
}
for
(
const
itemChildChildChild
of
itemChildChild
)
{
if
(
itemChildChildChild
.
errors
)
{
return
itemChildChildChild
.
errors
[
0
].
message
;
}
}
}
}
}
return
""
;
}
private
persistMainDataAndGoToStepper
=
async
(
step
:
number
)
=>
{
this
.
hideAlerts
();
this
.
showLoadingCircle
(
true
,
step
);
if
(
this
.
previousUsedTransect
!==
this
.
inspectionData
.
headerData
.
transect
)
{
// init create or Transect has changed
this
.
previousUsedTransect
=
this
.
inspectionData
.
headerData
.
transect
;
const
sectionEventsResponse
=
await
this
.
createSectionEvents
(
this
.
inspectionData
.
id
,
this
.
inspectionData
.
mainData
.
sections
);
const
sectionEventErrorMessage
=
this
.
getResponseErrors
(
sectionEventsResponse
);
if
(
sectionEventErrorMessage
!==
""
)
{
...
...
@@ -223,13 +206,12 @@ export default class TransectInspection extends Vue {
return
;
}
const
observationTableRowsResponse
=
await
this
.
createObservationTableRows
(
this
.
inspectionData
.
mainData
.
sections
);
console
.
log
(
observationTableRowsResponse
)
const
observationTableRowsErrorMessage
=
this
.
getResponseErrors
(
observationTableRowsResponse
);
console
.
log
(
observationTableRowsErrorMessage
)
if
(
observationTableRowsErrorMessage
!==
""
)
{
this
.
showErrorAlert
(
observationTableRowsErrorMessage
);
return
;
}
this
.
previousUsedTransect
=
this
.
inspectionData
.
headerData
.
transect
;
this
.
previousMainDataMd5Hash
=
Md5
.
hashStr
(
JSON
.
stringify
(
this
.
inspectionData
.
mainData
));
}
else
{
const
actualMainDataMd5Hash
=
Md5
.
hashStr
(
JSON
.
stringify
(
this
.
inspectionData
.
mainData
));
...
...
@@ -242,7 +224,6 @@ export default class TransectInspection extends Vue {
}
const
observationTableRowsResponse
=
await
this
.
updateObservationTableRows
(
this
.
inspectionData
.
mainData
.
sections
);
console
.
log
(
observationTableRowsResponse
)
const
observationTableRowsErrorMessage
=
this
.
getResponseErrors
(
observationTableRowsResponse
);
if
(
observationTableRowsErrorMessage
!==
""
)
{
this
.
showErrorAlert
(
observationTableRowsErrorMessage
);
...
...
@@ -254,6 +235,39 @@ export default class TransectInspection extends Vue {
this
.
finishStepperChange
(
step
);
}
private
getResponseErrors
(
response
:
any
)
{
// todo: collect all the errors and try to display in alert
// todo: refactor loop style
try
{
for
(
const
item
of
response
)
{
if
(
item
.
errors
)
{
return
item
.
errors
[
0
].
message
;
}
else
if
(
item
.
length
>
0
)
{
for
(
const
itemChild
of
item
)
{
if
(
itemChild
.
errors
)
{
return
itemChild
.
errors
[
0
].
message
;
}
else
if
(
itemChild
.
length
>
0
)
{
for
(
const
itemChildChild
of
itemChild
)
{
if
(
itemChildChild
.
errors
)
{
return
itemChildChild
.
errors
[
0
].
message
;
}
else
if
(
itemChildChild
.
length
>
0
)
{
for
(
const
itemChildChildChild
of
itemChildChild
)
{
if
(
itemChildChildChild
.
errors
)
{
return
itemChildChildChild
.
errors
[
0
].
message
;
}
}
}
}
}
}
}
}
}
catch
(
error
)
{
return
error
;
}
return
""
;
}
private
createObservationTableRows
=
async
(
sections
:
Section
[])
=>
{
try
{
return
await
Promise
.
all
(
...
...
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