mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Add sorting to resource claims and reports lists
This commit is contained in:
parent
70d8830e4c
commit
6890ef25be
@ -77,6 +77,7 @@ export default {
|
|||||||
createdRelationshipWithNestedAttributes = {
|
createdRelationshipWithNestedAttributes = {
|
||||||
...review.properties,
|
...review.properties,
|
||||||
claimId: claim.properties.id,
|
claimId: claim.properties.id,
|
||||||
|
claimCreatedAt: claim.properties.createdAt,
|
||||||
claimUpdatedAt: claim.properties.updatedAt,
|
claimUpdatedAt: claim.properties.updatedAt,
|
||||||
claimDisable: claim.properties.disable,
|
claimDisable: claim.properties.disable,
|
||||||
claimClosed: claim.properties.closed,
|
claimClosed: claim.properties.closed,
|
||||||
|
|||||||
@ -44,6 +44,7 @@ export default {
|
|||||||
createdRelationshipWithNestedAttributes = {
|
createdRelationshipWithNestedAttributes = {
|
||||||
...report.properties,
|
...report.properties,
|
||||||
claimId: claim.properties.id,
|
claimId: claim.properties.id,
|
||||||
|
claimCreatedAt: claim.properties.createdAt,
|
||||||
claimUpdatedAt: claim.properties.updatedAt,
|
claimUpdatedAt: claim.properties.updatedAt,
|
||||||
claimDisable: claim.properties.disable,
|
claimDisable: claim.properties.disable,
|
||||||
claimClosed: claim.properties.closed,
|
claimClosed: claim.properties.closed,
|
||||||
@ -112,6 +113,7 @@ export default {
|
|||||||
const responseEle = {
|
const responseEle = {
|
||||||
...report.properties,
|
...report.properties,
|
||||||
claimId: claim.properties.id,
|
claimId: claim.properties.id,
|
||||||
|
claimCreatedAt: claim.properties.createdAt,
|
||||||
claimUpdatedAt: claim.properties.updatedAt,
|
claimUpdatedAt: claim.properties.updatedAt,
|
||||||
claimDisable: claim.properties.disable,
|
claimDisable: claim.properties.disable,
|
||||||
claimClosed: claim.properties.closed,
|
claimClosed: claim.properties.closed,
|
||||||
|
|||||||
@ -4,8 +4,9 @@ type REPORTED {
|
|||||||
reasonDescription: String!
|
reasonDescription: String!
|
||||||
|
|
||||||
claimId: ID!
|
claimId: ID!
|
||||||
claimDisable: Boolean!
|
claimCreatedAt: String!
|
||||||
claimUpdatedAt: String!
|
claimUpdatedAt: String!
|
||||||
|
claimDisable: Boolean!
|
||||||
claimClosed: Boolean!
|
claimClosed: Boolean!
|
||||||
|
|
||||||
submitter: User
|
submitter: User
|
||||||
|
|||||||
@ -7,8 +7,9 @@ type REVIEWED {
|
|||||||
closed: Boolean!
|
closed: Boolean!
|
||||||
|
|
||||||
claimId: ID!
|
claimId: ID!
|
||||||
claimDisable: Boolean!
|
claimCreatedAt: String!
|
||||||
claimUpdatedAt: String!
|
claimUpdatedAt: String!
|
||||||
|
claimDisable: Boolean!
|
||||||
claimClosed: Boolean!
|
claimClosed: Boolean!
|
||||||
|
|
||||||
moderator: User
|
moderator: User
|
||||||
|
|||||||
@ -9,6 +9,7 @@ export const reportListQuery = () => {
|
|||||||
reasonCategory
|
reasonCategory
|
||||||
reasonDescription
|
reasonDescription
|
||||||
claimId
|
claimId
|
||||||
|
claimCreatedAt
|
||||||
claimUpdatedAt
|
claimUpdatedAt
|
||||||
claimDisable
|
claimDisable
|
||||||
claimClosed
|
claimClosed
|
||||||
@ -35,6 +36,9 @@ export const reportListQuery = () => {
|
|||||||
name
|
name
|
||||||
disabled
|
disabled
|
||||||
deleted
|
deleted
|
||||||
|
followedByCount
|
||||||
|
contributionsCount
|
||||||
|
commentedCount
|
||||||
}
|
}
|
||||||
followedByCount
|
followedByCount
|
||||||
contributionsCount
|
contributionsCount
|
||||||
@ -66,6 +70,9 @@ export const reportListQuery = () => {
|
|||||||
name
|
name
|
||||||
disabled
|
disabled
|
||||||
deleted
|
deleted
|
||||||
|
followedByCount
|
||||||
|
contributionsCount
|
||||||
|
commentedCount
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
post {
|
post {
|
||||||
@ -90,6 +97,9 @@ export const reportListQuery = () => {
|
|||||||
name
|
name
|
||||||
disabled
|
disabled
|
||||||
deleted
|
deleted
|
||||||
|
followedByCount
|
||||||
|
contributionsCount
|
||||||
|
commentedCount
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -223,18 +223,6 @@ export default {
|
|||||||
reasonDescription: this.$t('moderation.reports.reasonDescription'),
|
reasonDescription: this.$t('moderation.reports.reasonDescription'),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Wolle delete + remove unneeded translations
|
|
||||||
// fields() {
|
|
||||||
// return {
|
|
||||||
// type: ' ',
|
|
||||||
// reportedUserContent: ' ',
|
|
||||||
// reasonCategory: this.$t('moderation.reports.reasonCategory'),
|
|
||||||
// reasonDescription: this.$t('moderation.reports.reasonDescription'),
|
|
||||||
// submitter: this.$t('moderation.reports.submitter'),
|
|
||||||
// createdAt: this.$t('moderation.reports.createdAt'),
|
|
||||||
// disabledBy: this.$t('moderation.reports.disabledBy'),
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
confirm(content) {
|
confirm(content) {
|
||||||
@ -306,8 +294,8 @@ export default {
|
|||||||
return {}
|
return {}
|
||||||
},
|
},
|
||||||
update({ reports }) {
|
update({ reports }) {
|
||||||
// Wolle console.log('reports: ', reports)
|
|
||||||
const newResourcesClaims = []
|
const newResourcesClaims = []
|
||||||
|
|
||||||
reports.forEach(report => {
|
reports.forEach(report => {
|
||||||
const resource =
|
const resource =
|
||||||
report.type === 'User'
|
report.type === 'User'
|
||||||
@ -320,16 +308,10 @@ export default {
|
|||||||
let idxResource = newResourcesClaims.findIndex(
|
let idxResource = newResourcesClaims.findIndex(
|
||||||
content => content.resource.id === resource.id,
|
content => content.resource.id === resource.id,
|
||||||
)
|
)
|
||||||
// if resource not in resource list, then add it
|
// if resource is not in resource list, then add it
|
||||||
if (idxResource === -1) {
|
if (idxResource === -1) {
|
||||||
idxResource = newResourcesClaims.length
|
idxResource = newResourcesClaims.length
|
||||||
newResourcesClaims.push({
|
newResourcesClaims.push({
|
||||||
latestClaim: {
|
|
||||||
id: report.claimId,
|
|
||||||
updatedAt: report.claimUpdatedAt,
|
|
||||||
disable: report.claimDisable,
|
|
||||||
closed: report.claimClosed,
|
|
||||||
},
|
|
||||||
type: report.type,
|
type: report.type,
|
||||||
resource,
|
resource,
|
||||||
user: report.user,
|
user: report.user,
|
||||||
@ -342,11 +324,13 @@ export default {
|
|||||||
let idxClaim = newResourcesClaims[idxResource].claims.findIndex(
|
let idxClaim = newResourcesClaims[idxResource].claims.findIndex(
|
||||||
claim => claim.id === report.claimId,
|
claim => claim.id === report.claimId,
|
||||||
)
|
)
|
||||||
// if claim not in claim list, then add it
|
// if claim is not in claim list, then add it
|
||||||
if (idxClaim === -1) {
|
if (idxClaim === -1) {
|
||||||
idxClaim = newResourcesClaims[idxResource].claims.length
|
idxClaim = newResourcesClaims[idxResource].claims.length
|
||||||
newResourcesClaims[idxResource].claims.push({
|
newResourcesClaims[idxResource].claims.push({
|
||||||
|
// it is the same for all reports of a claim
|
||||||
id: report.claimId,
|
id: report.claimId,
|
||||||
|
createdAt: report.claimCreatedAt,
|
||||||
updatedAt: report.claimUpdatedAt,
|
updatedAt: report.claimUpdatedAt,
|
||||||
disable: report.claimDisable,
|
disable: report.claimDisable,
|
||||||
closed: report.claimClosed,
|
closed: report.claimClosed,
|
||||||
@ -355,7 +339,37 @@ export default {
|
|||||||
}
|
}
|
||||||
newResourcesClaims[idxResource].claims[idxClaim].reports.push(report)
|
newResourcesClaims[idxResource].claims[idxClaim].reports.push(report)
|
||||||
})
|
})
|
||||||
// Wolle console.log('newResourcesClaims: ', newResourcesClaims)
|
|
||||||
|
// sorting of resource claims and their reports
|
||||||
|
newResourcesClaims.forEach(resourceClaims => {
|
||||||
|
// latestClaim by updatedAt rules
|
||||||
|
resourceClaims.claims.sort(
|
||||||
|
(a, b) => new Date(b.updatedAt) - new Date(a.updatedAt),
|
||||||
|
)
|
||||||
|
resourceClaims.latestClaim = {
|
||||||
|
id: resourceClaims.claims[0].id,
|
||||||
|
createdAt: resourceClaims.claims[0].createdAt,
|
||||||
|
updatedAt: resourceClaims.claims[0].updatedAt,
|
||||||
|
disable: resourceClaims.claims[0].disable,
|
||||||
|
closed: resourceClaims.claims[0].closed,
|
||||||
|
}
|
||||||
|
// display claims always by starting with latest createdAt
|
||||||
|
resourceClaims.claims.sort(
|
||||||
|
(a, b) => new Date(b.createdAt) - new Date(a.createdAt),
|
||||||
|
)
|
||||||
|
|
||||||
|
resourceClaims.claims.forEach(claim => {
|
||||||
|
// display reports always by starting with latest createdAt
|
||||||
|
claim.reports.sort(
|
||||||
|
(a, b) => new Date(b.createdAt) - new Date(a.createdAt),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
// display resources by starting with claims by their latest createdAt
|
||||||
|
newResourcesClaims.sort(
|
||||||
|
(a, b) => new Date(b.claims[0].createdAt) - new Date(a.claims[0].createdAt),
|
||||||
|
)
|
||||||
|
|
||||||
this.resourcesClaims = newResourcesClaims
|
this.resourcesClaims = newResourcesClaims
|
||||||
return reports
|
return reports
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user