Prettier format all js files
This commit is contained in:
@@ -1,36 +1,46 @@
|
||||
import { compose, sortBy, reverse, indexBy, partial, prop, pipe, toLower } from 'ramda'
|
||||
import {
|
||||
compose,
|
||||
sortBy,
|
||||
reverse,
|
||||
indexBy,
|
||||
partial,
|
||||
prop,
|
||||
pipe,
|
||||
toLower,
|
||||
} from 'ramda'
|
||||
|
||||
const search = (query, members) => {
|
||||
if (query === '' || query === 'all') {
|
||||
return members
|
||||
} else {
|
||||
const normalizedQuery = query.toLowerCase()
|
||||
return members.filter(
|
||||
(member) => member.name.toLowerCase().includes(normalizedQuery)
|
||||
return members.filter(member =>
|
||||
member.name.toLowerCase().includes(normalizedQuery)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const filterByStatus = (status, statusesByDisplayName, members) => {
|
||||
const getStatusFromDisplayName = (_status) => statusesByDisplayName[_status].name
|
||||
const getStatusFromDisplayName = _status =>
|
||||
statusesByDisplayName[_status].name
|
||||
|
||||
if (status === '' || status === 'all') {
|
||||
return members
|
||||
} else {
|
||||
return members.filter(
|
||||
(member) => getStatusFromDisplayName(member.status) === status
|
||||
member => getStatusFromDisplayName(member.status) === status
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const filterByRole = (role, rolesByDisplayname, members) => {
|
||||
const getRoleNameFromDisplayName = (_role) => rolesByDisplayname[_role].name
|
||||
const getRoleNameFromDisplayName = _role => rolesByDisplayname[_role].name
|
||||
|
||||
if (role === '' || role === 'all') {
|
||||
return members
|
||||
} else {
|
||||
return members.filter(
|
||||
(member) => getRoleNameFromDisplayName(member.role) === role
|
||||
member => getRoleNameFromDisplayName(member.role) === role
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -42,10 +52,8 @@ const sort = (sortInfo, members) => {
|
||||
const sortColumn = sortInfo.columns[sortInfo.columnName]
|
||||
const sortedMembers = sortColumn.sortFunc(sortColumn.attr, members)
|
||||
|
||||
return sortInfo.isAscending ?
|
||||
sortedMembers :
|
||||
reverse(sortedMembers)
|
||||
}
|
||||
return sortInfo.isAscending ? sortedMembers : reverse(sortedMembers)
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
@@ -57,9 +65,12 @@ export default {
|
||||
status_choices: Array,
|
||||
},
|
||||
|
||||
data: function () {
|
||||
data: function() {
|
||||
const alphabeticalSort = (attr, members) => {
|
||||
const lowercaseProp = compose(toLower, prop(attr))
|
||||
const lowercaseProp = compose(
|
||||
toLower,
|
||||
prop(attr)
|
||||
)
|
||||
return sortBy(lowercaseProp, members)
|
||||
}
|
||||
|
||||
@@ -70,18 +81,18 @@ export default {
|
||||
displayName: 'Name',
|
||||
attr: 'name',
|
||||
sortFunc: alphabeticalSort,
|
||||
width: "50%"
|
||||
width: '50%',
|
||||
},
|
||||
{
|
||||
displayName: 'Environments',
|
||||
attr: 'num_env',
|
||||
sortFunc: numericSort,
|
||||
class: "table-cell--align-right"
|
||||
class: 'table-cell--align-right',
|
||||
},
|
||||
{
|
||||
displayName: 'Status',
|
||||
attr: 'status',
|
||||
sortFunc: alphabeticalSort
|
||||
sortFunc: alphabeticalSort,
|
||||
},
|
||||
{
|
||||
displayName: 'Portfolio Role',
|
||||
@@ -101,20 +112,20 @@ export default {
|
||||
sortInfo: {
|
||||
columnName: defaultSortColumn,
|
||||
isAscending: true,
|
||||
columns: indexBy(prop('displayName'), columns)
|
||||
columns: indexBy(prop('displayName'), columns),
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
searchedList: function () {
|
||||
searchedList: function() {
|
||||
return pipe(
|
||||
partial(search, [this.searchValue]),
|
||||
partial(filterByStatus, [this.status, this.statusesByDisplayName]),
|
||||
partial(filterByRole, [this.role, this.rolesByDisplayName]),
|
||||
partial(sort, [this.sortInfo])
|
||||
)(this.members)
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
@@ -128,8 +139,8 @@ export default {
|
||||
},
|
||||
getColumns: function() {
|
||||
return Object.values(this.sortInfo.columns)
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
template: '<div></div>'
|
||||
template: '<div></div>',
|
||||
}
|
||||
|
Reference in New Issue
Block a user