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
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Package registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
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
HUB Terra
SMS
Frontend
Commits
94db043f
Verified
Commit
94db043f
authored
3 years ago
by
Marc Hanisch
Browse files
Options
Downloads
Patches
Plain Diff
uses actiontypes from the CV
parent
c0757d2f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!104
Load and save Generic Device Actions
,
!93
Actions UI for devices
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pages/devices/_deviceId/actions/new.vue
+50
-18
50 additions, 18 deletions
pages/devices/_deviceId/actions/new.vue
with
50 additions
and
18 deletions
pages/devices/_deviceId/actions/new.vue
+
50
−
18
View file @
94db043f
...
...
@@ -63,7 +63,7 @@ permissions and limitations under the Licence.
Add
</v-btn>
<v-btn
v-else-if=
"
other
Chosen"
v-else-if=
"
genericAction
Chosen"
color=
"green"
small
:disabled=
"isSaving"
...
...
@@ -75,7 +75,7 @@ permissions and limitations under the Licence.
<v-card-text>
<v-select
v-model=
"chosenKindOfAction"
:items=
"
optionsFor
ActionType"
:items=
"
get
ActionType
Items()
"
:item-text=
"(x) => x.name"
:item-value=
"(x) => x"
clearable
...
...
@@ -173,7 +173,7 @@ permissions and limitations under the Licence.
</v-row>
</v-card-text>
<v-card-text
v-if=
"
other
Chosen"
v-if=
"
genericAction
Chosen"
>
<GenericActionForm
ref=
"genericDeviceActionForm"
...
...
@@ -183,7 +183,7 @@ permissions and limitations under the Licence.
</v-card-text>
<!-- action type independent -->
<v-card-text
v-if=
"chosenKindOfAction && !
other
Chosen"
v-if=
"chosenKindOfAction && !
genericAction
Chosen"
>
<v-row>
<v-col
cols=
"12"
md=
"12"
>
...
...
@@ -260,7 +260,7 @@ permissions and limitations under the Licence.
Add
</v-btn>
<v-btn
v-else-if=
"
other
Chosen"
v-else-if=
"
genericAction
Chosen"
color=
"green"
small
:disabled=
"isSaving"
...
...
@@ -281,13 +281,18 @@ import { Contact } from '@/models/Contact'
import
{
Attachment
}
from
'
@/models/Attachment
'
import
{
DeviceProperty
}
from
'
@/models/DeviceProperty
'
import
{
GenericAction
}
from
'
@/models/GenericAction
'
import
{
IActionType
,
ActionType
}
from
'
@/models/ActionType
'
import
{
dateToString
,
stringToDate
}
from
'
@/utils/dateHelper
'
import
GenericActionForm
from
'
@/components/GenericActionForm.vue
'
import
DatePicker
from
'
@/components/DatePicker.vue
'
type
KindOfActionType
=
'
device_calibration
'
|
'
software_update
'
|
'
generic_device_action
'
const
KIND_OF_ACTION_TYPE_DEVICE_CALIBRATION
=
'
device_calibration
'
const
KIND_OF_ACTION_TYPE_SOFTWARE_UPDATE
=
'
software_update
'
const
KIND_OF_ACTION_TYPE_GENERIC_DEVICE_ACTION
=
'
generic_device_action
'
const
KIND_OF_ACTION_TYPE_UNKNOWN
=
'
unknown
'
type
KindOfActionType
=
typeof
KIND_OF_ACTION_TYPE_DEVICE_CALIBRATION
|
typeof
KIND_OF_ACTION_TYPE_SOFTWARE_UPDATE
|
typeof
KIND_OF_ACTION_TYPE_GENERIC_DEVICE_ACTION
|
typeof
KIND_OF_ACTION_TYPE_UNKNOWN
interface
IOptionsForActionType
{
id
:
string
...
...
@@ -317,12 +322,7 @@ export default class ActionAddPage extends Vue {
private
contactIsValid
=
true
private
softwareTypeIsValid
=
true
private
optionsForActionType
:
IOptionsForActionType
[]
=
[
{
id
:
'
device-calibration
'
,
kind
:
'
device_calibration
'
,
name
:
'
Device calibration
'
},
{
id
:
'
software-update
'
,
kind
:
'
software_update
'
,
name
:
'
Software update
'
},
{
id
:
'
generic-action-1
'
,
kind
:
'
generic_device_action
'
,
/* uri: 'actionTypes/device_visit', */
name
:
'
Device visit
'
},
{
id
:
'
generic-action-2
'
,
kind
:
'
generic_device_action
'
,
/* uri: 'actionTypes/device_maintenance', */
name
:
'
Device maintenance
'
}
]
private
actionTypes
:
ActionType
[]
=
[]
private
contacts
:
Contact
[]
=
[]
private
selectedContact
:
Contact
|
null
=
null
...
...
@@ -348,6 +348,16 @@ export default class ActionAddPage extends Vue {
private
_isSaving
:
boolean
=
false
async
fetch
()
{
await
Promise
.
all
([
this
.
fetchActionTypes
()
])
}
async
fetchActionTypes
():
Promise
<
any
>
{
this
.
actionTypes
=
await
this
.
$api
.
actionTypes
.
findAllPaginated
()
}
mounted
()
{
this
.
$api
.
contacts
.
findAll
().
then
((
foundContacts
)
=>
{
this
.
contacts
=
foundContacts
...
...
@@ -388,9 +398,8 @@ export default class ActionAddPage extends Vue {
if
(
this
.
$data
.
_chosenKindOfAction
?.
kind
!==
newValue
?.
kind
)
{
this
.
resetAllActionSpecificInputs
()
}
if
(
this
.
other
Chosen
)
{
if
(
this
.
genericAction
Chosen
)
{
this
.
genericDeviceAction
=
new
GenericAction
()
// TODO: we still need those values from the controlled vocabulary
this
.
genericDeviceAction
.
actionTypeName
=
newValue
?.
name
||
''
this
.
genericDeviceAction
.
actionTypeUrl
=
newValue
?.
uri
||
''
}
...
...
@@ -407,15 +416,15 @@ export default class ActionAddPage extends Vue {
}
get
deviceCalibrationChosen
()
{
return
this
.
$data
.
_chosenKindOfAction
?.
kind
===
'
device_calibration
'
return
this
.
$data
.
_chosenKindOfAction
?.
kind
===
KIND_OF_ACTION_TYPE_DEVICE_CALIBRATION
}
get
softwareUpdateChosen
()
{
return
this
.
$data
.
_chosenKindOfAction
?.
kind
===
'
software_update
'
return
this
.
$data
.
_chosenKindOfAction
?.
kind
===
KIND_OF_ACTION_TYPE_SOFTWARE_UPDATE
}
get
other
Chosen
()
{
return
this
.
$data
.
_chosenKindOfAction
?.
kind
===
'
generic_device_action
'
get
genericAction
Chosen
()
{
return
this
.
$data
.
_chosenKindOfAction
?.
kind
===
KIND_OF_ACTION_TYPE_GENERIC_DEVICE_ACTION
}
getStartDate
():
string
{
...
...
@@ -554,6 +563,29 @@ export default class ActionAddPage extends Vue {
this
.
isSaving
=
false
})
}
getActionTypeItems
():
IOptionsForActionType
[]
{
const
result
:
IOptionsForActionType
[]
=
this
.
actionTypes
.
filter
(
i
=>
i
.
name
.
match
(
/device/i
)).
map
((
i
)
=>
{
let
kind
:
KindOfActionType
=
KIND_OF_ACTION_TYPE_UNKNOWN
// TODO: is there another way to get the kind of action than parsing the name?
if
(
i
.
name
.
match
(
/maintenance/i
))
{
kind
=
KIND_OF_ACTION_TYPE_GENERIC_DEVICE_ACTION
}
else
if
(
i
.
name
.
match
(
/observation/i
))
{
kind
=
KIND_OF_ACTION_TYPE_GENERIC_DEVICE_ACTION
}
else
if
(
i
.
name
.
match
(
/update/i
))
{
kind
=
KIND_OF_ACTION_TYPE_SOFTWARE_UPDATE
}
else
if
(
i
.
name
.
match
(
/calibration/i
))
{
kind
=
KIND_OF_ACTION_TYPE_DEVICE_CALIBRATION
}
return
{
id
:
i
.
id
,
name
:
i
.
name
,
uri
:
i
.
uri
,
kind
}
as
IOptionsForActionType
})
return
result
}
}
</
script
>
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