feat: remove lodash dependency (#743)
Co-authored-by: Dominik Pschenitschni <mail@celement.de> Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/743 Reviewed-by: konrad <k@knt.li> Co-authored-by: dpschen <dpschen@noreply.kolaente.de> Co-committed-by: dpschen <dpschen@noreply.kolaente.de>
This commit is contained in:
@ -1,7 +1,5 @@
|
||||
import defaults from 'lodash/defaults'
|
||||
import isNil from 'lodash/isNil'
|
||||
import omitBy from 'lodash/omitBy'
|
||||
import {objectToCamelCase} from '@/helpers/case'
|
||||
import {omitBy, isNil} from '@/helpers/utils'
|
||||
|
||||
export default class AbstractModel {
|
||||
|
||||
@ -16,11 +14,14 @@ export default class AbstractModel {
|
||||
* @param data
|
||||
*/
|
||||
constructor(data) {
|
||||
|
||||
data = objectToCamelCase(data)
|
||||
|
||||
// Put all data in our model while overriding those with a value of null or undefined with their defaults
|
||||
defaults(this, omitBy(data, isNil), this.defaults())
|
||||
Object.assign(
|
||||
this,
|
||||
this.defaults(),
|
||||
omitBy(data, isNil),
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,13 +1,10 @@
|
||||
import TeamShareBaseModel from './teamShareBase'
|
||||
import merge from 'lodash/merge'
|
||||
|
||||
export default class TeamListModel extends TeamShareBaseModel {
|
||||
defaults() {
|
||||
return merge(
|
||||
super.defaults(),
|
||||
{
|
||||
listId: 0,
|
||||
},
|
||||
)
|
||||
return {
|
||||
...super.defaults(),
|
||||
listId: 0,
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +1,11 @@
|
||||
import UserModel from './user'
|
||||
import merge from 'lodash/merge'
|
||||
|
||||
export default class TeamMemberModel extends UserModel {
|
||||
defaults() {
|
||||
return merge(
|
||||
super.defaults(),
|
||||
{
|
||||
admin: false,
|
||||
teamId: 0,
|
||||
},
|
||||
)
|
||||
return {
|
||||
...super.defaults(),
|
||||
admin: false,
|
||||
teamId: 0,
|
||||
}
|
||||
}
|
||||
}
|
@ -1,13 +1,10 @@
|
||||
import TeamShareBaseModel from './teamShareBase'
|
||||
import merge from 'lodash/merge'
|
||||
|
||||
export default class TeamNamespaceModel extends TeamShareBaseModel {
|
||||
defaults() {
|
||||
return merge(
|
||||
super.defaults(),
|
||||
{
|
||||
namespaceId: 0,
|
||||
},
|
||||
)
|
||||
return {
|
||||
...super.defaults(),
|
||||
namespaceId: 0,
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +1,11 @@
|
||||
import UserShareBaseModel from './userShareBase'
|
||||
import merge from 'lodash/merge'
|
||||
|
||||
// This class extends the user share model with a 'rights' parameter which is used in sharing
|
||||
export default class UserListModel extends UserShareBaseModel {
|
||||
defaults() {
|
||||
return merge(
|
||||
super.defaults(),
|
||||
{
|
||||
listId: 0,
|
||||
},
|
||||
)
|
||||
return {
|
||||
...super.defaults(),
|
||||
listId: 0,
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +1,11 @@
|
||||
import UserShareBaseModel from './userShareBase'
|
||||
import merge from 'lodash/merge'
|
||||
|
||||
// This class extends the user share model with a 'rights' parameter which is used in sharing
|
||||
export default class UserNamespaceModel extends UserShareBaseModel {
|
||||
defaults() {
|
||||
return merge(
|
||||
super.defaults(),
|
||||
{
|
||||
namespaceId: 0,
|
||||
},
|
||||
)
|
||||
return {
|
||||
...super.defaults(),
|
||||
namespaceId: 0,
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user