diff --git a/backend/src/schema/resolvers/moderation.js b/backend/src/schema/resolvers/moderation.js index 1de06fa5f..58df850a4 100644 --- a/backend/src/schema/resolvers/moderation.js +++ b/backend/src/schema/resolvers/moderation.js @@ -77,6 +77,7 @@ export default { createdRelationshipWithNestedAttributes = { ...review.properties, claimId: claim.properties.id, + claimCreatedAt: claim.properties.createdAt, claimUpdatedAt: claim.properties.updatedAt, claimDisable: claim.properties.disable, claimClosed: claim.properties.closed, diff --git a/backend/src/schema/resolvers/reports.js b/backend/src/schema/resolvers/reports.js index b5632f241..ca5a1ced3 100644 --- a/backend/src/schema/resolvers/reports.js +++ b/backend/src/schema/resolvers/reports.js @@ -44,6 +44,7 @@ export default { createdRelationshipWithNestedAttributes = { ...report.properties, claimId: claim.properties.id, + claimCreatedAt: claim.properties.createdAt, claimUpdatedAt: claim.properties.updatedAt, claimDisable: claim.properties.disable, claimClosed: claim.properties.closed, @@ -112,6 +113,7 @@ export default { const responseEle = { ...report.properties, claimId: claim.properties.id, + claimCreatedAt: claim.properties.createdAt, claimUpdatedAt: claim.properties.updatedAt, claimDisable: claim.properties.disable, claimClosed: claim.properties.closed, diff --git a/backend/src/schema/types/type/REPORTED.gql b/backend/src/schema/types/type/REPORTED.gql index c05df094d..d59b720c2 100644 --- a/backend/src/schema/types/type/REPORTED.gql +++ b/backend/src/schema/types/type/REPORTED.gql @@ -4,8 +4,9 @@ type REPORTED { reasonDescription: String! claimId: ID! - claimDisable: Boolean! + claimCreatedAt: String! claimUpdatedAt: String! + claimDisable: Boolean! claimClosed: Boolean! submitter: User diff --git a/backend/src/schema/types/type/REVIEWED.gql b/backend/src/schema/types/type/REVIEWED.gql index 9546bfaf2..3babae152 100644 --- a/backend/src/schema/types/type/REVIEWED.gql +++ b/backend/src/schema/types/type/REVIEWED.gql @@ -7,8 +7,9 @@ type REVIEWED { closed: Boolean! claimId: ID! - claimDisable: Boolean! + claimCreatedAt: String! claimUpdatedAt: String! + claimDisable: Boolean! claimClosed: Boolean! moderator: User diff --git a/webapp/graphql/Moderation.js b/webapp/graphql/Moderation.js index 3300f2915..9ade5c414 100644 --- a/webapp/graphql/Moderation.js +++ b/webapp/graphql/Moderation.js @@ -9,6 +9,7 @@ export const reportListQuery = () => { reasonCategory reasonDescription claimId + claimCreatedAt claimUpdatedAt claimDisable claimClosed @@ -35,6 +36,9 @@ export const reportListQuery = () => { name disabled deleted + followedByCount + contributionsCount + commentedCount } followedByCount contributionsCount @@ -66,6 +70,9 @@ export const reportListQuery = () => { name disabled deleted + followedByCount + contributionsCount + commentedCount } } post { @@ -90,6 +97,9 @@ export const reportListQuery = () => { name disabled deleted + followedByCount + contributionsCount + commentedCount } } } diff --git a/webapp/pages/moderation/index.vue b/webapp/pages/moderation/index.vue index a1442e9ce..42177164b 100644 --- a/webapp/pages/moderation/index.vue +++ b/webapp/pages/moderation/index.vue @@ -223,18 +223,6 @@ export default { 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: { confirm(content) { @@ -306,8 +294,8 @@ export default { return {} }, update({ reports }) { - // Wolle console.log('reports: ', reports) const newResourcesClaims = [] + reports.forEach(report => { const resource = report.type === 'User' @@ -320,16 +308,10 @@ export default { let idxResource = newResourcesClaims.findIndex( 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) { idxResource = newResourcesClaims.length newResourcesClaims.push({ - latestClaim: { - id: report.claimId, - updatedAt: report.claimUpdatedAt, - disable: report.claimDisable, - closed: report.claimClosed, - }, type: report.type, resource, user: report.user, @@ -342,11 +324,13 @@ export default { let idxClaim = newResourcesClaims[idxResource].claims.findIndex( 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) { idxClaim = newResourcesClaims[idxResource].claims.length newResourcesClaims[idxResource].claims.push({ + // it is the same for all reports of a claim id: report.claimId, + createdAt: report.claimCreatedAt, updatedAt: report.claimUpdatedAt, disable: report.claimDisable, closed: report.claimClosed, @@ -355,7 +339,37 @@ export default { } 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 return reports },