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
70ef0f0f
Verified
Commit
70ef0f0f
authored
3 years ago
by
Kotyba Alhaj Taha
Browse files
Options
Downloads
Patches
Plain Diff
Platform make include related object optional
parent
141d7ab2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!92
Feature restructure frontend platforms
,
!82
Restructure frontend
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pages/platforms/_platformId.vue
+4
-1
4 additions, 1 deletion
pages/platforms/_platformId.vue
serializers/jsonapi/PlatformSerializer.ts
+4
-0
4 additions, 0 deletions
serializers/jsonapi/PlatformSerializer.ts
services/sms/PlatformApi.ts
+19
-5
19 additions, 5 deletions
services/sms/PlatformApi.ts
with
27 additions
and
6 deletions
pages/platforms/_platformId.vue
+
4
−
1
View file @
70ef0f0f
...
...
@@ -64,7 +64,10 @@ export default class PlatformPage extends Vue {
mounted
()
{
this
.
initializeAppBar
()
this
.
$api
.
platforms
.
findById
(
this
.
platformId
).
then
((
platform
)
=>
{
this
.
$api
.
platforms
.
findById
(
this
.
platformId
,{
includeContacts
:
false
,
includePlatformAttachments
:
false
}).
then
((
platform
)
=>
{
this
.
platform
=
platform
this
.
isLoading
=
false
}).
catch
((
_error
)
=>
{
...
...
This diff is collapsed.
Click to expand it.
serializers/jsonapi/PlatformSerializer.ts
+
4
−
0
View file @
70ef0f0f
...
...
@@ -207,3 +207,7 @@ export const platformWithMetaToPlatformByAddingDummyObjects = (platformWithMeta:
return
platform
}
export
const
platformWithMetaToDeviceThrowingNoErrorOnMissing
=
(
platformWithMeta
:
{
missing
:
{
contacts
:
{
ids
:
any
[]
}
};
platform
:
Platform
}):
Platform
=>
{
const
platform
=
platformWithMeta
.
platform
return
platform
}
This diff is collapsed.
Click to expand it.
services/sms/PlatformApi.ts
+
19
−
5
View file @
70ef0f0f
...
...
@@ -42,7 +42,7 @@ import { ContactSerializer } from '@/serializers/jsonapi/ContactSerializer'
import
{
PlatformSerializer
,
platformWithMetaTo
PlatformBy
ThrowingErrorOnMissing
,
platformWithMetaTo
Device
Throwing
No
ErrorOnMissing
,
platformWithMetaToPlatformByAddingDummyObjects
}
from
'
@/serializers/jsonapi/PlatformSerializer
'
import
{
PlatformAttachmentSerializer
}
from
'
@/serializers/jsonapi/PlatformAttachmentSerializer
'
...
...
@@ -53,6 +53,11 @@ import {
IPaginationLoader
,
FilteredPaginationedLoader
}
from
'
@/utils/PaginatedLoader
'
interface
IncludedRelationships
{
includeContacts
?:
boolean
includePlatformAttachments
?:
boolean
}
export
class
PlatformApi
{
private
axiosApi
:
AxiosInstance
private
serializer
:
PlatformSerializer
...
...
@@ -62,16 +67,25 @@ export class PlatformApi {
this
.
serializer
=
new
PlatformSerializer
()
}
findById
(
id
:
string
):
Promise
<
Platform
>
{
findById
(
id
:
string
,
includes
:
IncludedRelationships
):
Promise
<
Platform
>
{
const
listIncludedRelationships
:
string
[]
=
[]
if
(
includes
.
includeContacts
)
{
listIncludedRelationships
.
push
(
'
contacts
'
)
}
if
(
includes
.
includePlatformAttachments
)
{
listIncludedRelationships
.
push
(
'
platform_attachments
'
)
}
const
include
=
listIncludedRelationships
.
join
(
'
,
'
)
return
this
.
axiosApi
.
get
(
id
,
{
params
:
{
include
:
'
contacts,platform_attachments
'
include
}
}).
then
((
rawResponse
)
=>
{
const
rawData
=
rawResponse
.
data
// As we ask the api to include all the contacts, we want to have them here
// if they are missing => throw an error
return
platformWithMetaTo
PlatformBy
ThrowingErrorOnMissing
(
this
.
serializer
.
convertJsonApiObjectToModel
(
rawData
))
return
platformWithMetaTo
Device
Throwing
No
ErrorOnMissing
(
this
.
serializer
.
convertJsonApiObjectToModel
(
rawData
))
})
}
...
...
@@ -100,7 +114,7 @@ export class PlatformApi {
data
}
}).
then
((
serverAnswer
)
=>
{
return
this
.
findById
(
serverAnswer
.
data
.
data
.
id
)
return
this
.
findById
(
serverAnswer
.
data
.
data
.
id
,
{}
)
})
}
...
...
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