-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
204 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
class API::Users::RecentReportsController < API::BaseController | ||
def index | ||
@user = User.find(params[:user_id]) | ||
@reports = @user.reports.limit(10).order(reported_on: :DESC) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import Vue from 'vue' | ||
import UserReports from './user-recent-reports.vue' | ||
|
||
document.addEventListener('DOMContentLoaded', () => { | ||
const selector = '#js-user-recent-reports' | ||
const reports = document.querySelector(selector) | ||
if (reports) { | ||
const userID = reports.getAttribute('user-id') | ||
new Vue({ | ||
render: (h) => | ||
h(UserReports, { | ||
props: { | ||
userID: userID | ||
} | ||
}) | ||
}).$mount(selector) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<template lang="pug"> | ||
.thread-list.a-card | ||
.card-header.is-sm | ||
h2.card-header__title | ||
| 直近の日報 | ||
.thread-list__items.has-no-author-image | ||
report( | ||
v-for='report in reports', | ||
:key='report.id', | ||
:report='report', | ||
:current-user-id='currentUserId' | ||
) | ||
</template> | ||
|
||
<script> | ||
import Report from './report.vue' | ||
export default { | ||
components: { | ||
report: Report | ||
}, | ||
props: { | ||
userID: { type: String, required: true } | ||
}, | ||
data: function () { | ||
return { | ||
reports: null, | ||
currentUserId: null | ||
} | ||
}, | ||
computed: { | ||
reportsAPI() { | ||
return `/api/users/${this.userID}/recent_reports.json` | ||
} | ||
}, | ||
created() { | ||
window.onpopstate = () => { | ||
this.getReports() | ||
} | ||
this.getReports() | ||
}, | ||
methods: { | ||
getReports() { | ||
fetch(this.reportsAPI, { | ||
method: 'GET', | ||
headers: { 'X-Requested-With': 'XMLHttpRequest' }, | ||
credentials: 'same-origin', | ||
redirect: 'manual' | ||
}) | ||
.then((response) => { | ||
return response.json() | ||
}) | ||
.then((json) => { | ||
this.reports = json.reports | ||
this.currentUserId = json.currentUserId | ||
}) | ||
.catch((error) => { | ||
console.warn('Failed to parsing', error) | ||
}) | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
json.reports @reports do |report| | ||
json.partial! "api/reports/report", report: report | ||
json.partial! "api/comments/user_icons", comments: report.comments | ||
json.user do | ||
json.partial! "api/users/user", user: report.user | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.