Skip to content

Commit

Permalink
Merge pull request #3662 from fjordllc/main
Browse files Browse the repository at this point in the history
Release 2021-12-09 08:39:55
  • Loading branch information
komagata committed Dec 13, 2021
2 parents 337fe53 + ec9b9d9 commit 4c96b27
Show file tree
Hide file tree
Showing 55 changed files with 662 additions and 3,033 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ GEM
ast (2.4.2)
bcrypt (3.1.16)
bindex (0.8.1)
bootsnap (1.7.2)
bootsnap (1.9.3)
msgpack (~> 1.0)
builder (3.2.4)
bullet (6.1.3)
Expand Down
6 changes: 5 additions & 1 deletion app/assets/stylesheets/atoms/_a-textarea-bottom-note.sass
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
+media-breakpoint-down(md)
.a-textarea-bottom-note__banner
display: none

+media-breakpoint-up(lg)
.a-textarea-bottom-note
position: relative
Expand All @@ -9,5 +13,5 @@
+position(absolute, left 1px, bottom 1px, right 1px)
+border-radius(bottom, 3px)
padding: .5rem
+text-block(.8125rem 1.4, center)
+text-block(.75rem 1.4, center)
border-top: solid 1px $border-more-shade
1 change: 1 addition & 0 deletions app/assets/stylesheets/blocks/form/_form-actions.sass
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
display: flex
align-items: flex-end
justify-content: center
flex-wrap: wrap
&.is-ais-flex-start
align-items: flex-start
+media-breakpoint-down(sm)
Expand Down
3 changes: 2 additions & 1 deletion app/assets/stylesheets/blocks/form/_form-tabs.sass
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
display: flex
margin-bottom: 1rem
border-bottom: solid 1px $border
.a-card > &:first-child
.a-card > &:first-child,
.a-card__inner > &:first-child
margin-top: 1rem

.form-tabs__tab
Expand Down
2 changes: 2 additions & 0 deletions app/assets/stylesheets/blocks/side/_side-tabs-contents.sass
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
border-top-left-radius: 0
max-height: calc(100vh - 100px)
overflow-y: auto
.card-header
display: none

#side-tabs-1:checked ~ .side-tabs-contents #side-tabs-content-1
display: block
Expand Down
5 changes: 2 additions & 3 deletions app/assets/stylesheets/blocks/side/_side-tabs-nav.sass
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.side-tabs-nav__items
display: flex
+position(relative, 2)
margin-bottom: -1px
+margin(horizontal, auto)
max-width: 50rem

Expand All @@ -18,10 +17,10 @@
color: $default-text

.side-tabs-nav__item-link
+text-block(.875rem 1.4, flex)
+text-block(.8125rem 1.4, flex 600)
cursor: pointer
padding: .75em 1.25em
border: solid 1px $border-shade
border: solid 1px $border-more-shade
border-bottom: none
+position(relative, bottom -1px)
+border-radius(top, .25rem)
Expand Down
4 changes: 4 additions & 0 deletions app/assets/stylesheets/blocks/thread/_thread-list-item.sass
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
padding-left: 3.75rem
+media-breakpoint-up(md)
min-height: 2.75rem
.has-no-author-image &
padding-left: 0
+media-breakpoint-down(sm)
padding-left: 3rem

Expand Down Expand Up @@ -113,6 +115,8 @@

.thread-list-item__user
+position(absolute, left 0, top 0)
.has-no-author-image &
display: none

.thread-list-item__user-icon
+size(2.75rem)
Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/mixins/_long-text-style.sass
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

=long-text-style($pc-font-size: 1rem, $mobile-font-size: .8125rem, $background: $base, $font: $default-text)
font-size: $pc-font-size
word-break: break-all
+media-breakpoint-down(sm)
font-size: $mobile-font-size
>*:first-child
Expand Down Expand Up @@ -60,7 +61,6 @@
p
+text-block(1em 1.86)
margin-bottom: 1.5em
word-break: break-all
a
+hover-link-reversal
+default-link
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/api/subscriptions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

class API::SubscriptionsController < API::BaseController
def index
@subscriptions = Subscription.new.all
end
end
8 changes: 8 additions & 0 deletions app/controllers/api/users/recent_reports_controller.rb
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
2 changes: 1 addition & 1 deletion app/controllers/companies/users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class Companies::UsersController < ApplicationController
TARGETS = %w[student_and_trainee all].freeze
TARGETS = %w[all student_and_trainee graduate adviser mentor].freeze
before_action :require_login

def index
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def set_page

def page_params
keys = %i[title body tag_list practice_id slug]
keys << :user_id if admin_login?
keys << :user_id if admin_or_mentor_login?
params.require(:page).permit(*keys)
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/works_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def work_params
end

def set_my_work
@work = if admin_login?
@work = if admin_or_mentor_login?
Work.find(params[:id])
else
current_user.works.find(params[:id])
Expand Down
4 changes: 1 addition & 3 deletions app/javascript/comments.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
.thread-comments-more(v-show='!loadedComment')
.thread-comments-more__inner
.thread-comments-more__action
button#js-shortcut-post-comment.a-button.is-lg.is-text.is-block(
@click='showComments'
)
button.a-button.is-lg.is-text.is-block(@click='showComments')
| コメント({{ commentLimit }})をもっと見る
comment(
v-for='(comment, index) in comments',
Expand Down
2 changes: 2 additions & 0 deletions app/javascript/packs/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,5 @@ require('../practice-select.js')
require('../companies.js')
require('../worried-users.js')
require('../report_template.js')
require('../user-recent-reports.js')
require('../subscription-status.js')
2 changes: 1 addition & 1 deletion app/javascript/question-edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
.thread-header-metas__start
.thread-header-metas__meta
a.a-user-name(:href='`/users/${question.user.id}`')
| {{ question.user.login_name }}
| {{ question.user.long_name }}
.thread-header-metas__meta
.a-meta
time.thread_header_date-value(
Expand Down
6 changes: 6 additions & 0 deletions app/javascript/reports.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<template lang="pug">
.reports.is-md(v-if='reports === null')
loadingListPlaceholder
.reports(v-else-if='reports.length === 0')
.o-empty-message
.o-empty-message__icon
i.far.fa-sad-tear
.o-empty-message__text
| 日報はまだありません。
.reports(v-else-if='reports.length > 0 || !isUncheckedReportsPage')
nav.pagination(v-if='totalPages > 1')
pager(v-bind='pagerProps')
Expand Down
49 changes: 49 additions & 0 deletions app/javascript/subscription-status.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
document.addEventListener('DOMContentLoaded', () => {
const statusMap = {
trialing: 'is-primary',
active: 'is-success',
canceled: 'is-danger',
past_due: 'is-warning'
}
const statusLabel = {
trialing: 'お試し中',
active: '有効',
canceled: 'キャンセル',
past_due: '期日経過'
}
const selector = '.subscription-status'
const statuses = document.querySelectorAll(selector)
if (statuses) {
let subs = []

fetch('/api/subscriptions.json', {
method: 'GET',
headers: { 'X-Requested-With': 'XMLHttpRequest' },
credentials: 'same-origin',
redirect: 'manual'
})
.then((response) => {
return response.json()
})
.then((json) => {
subs = json.subscriptions

statuses.forEach((status) => {
const subId = status.getAttribute('data-subscription-id')
subs.forEach((sub) => {
if (sub.id === subId) {
const level = statusMap[sub.status]
const label = statusLabel[sub.status]
status.classList.add('a-button')
status.classList.add('is-sm')
status.classList.add(level)
status.innerHTML = label
}
})
})
})
.catch((error) => {
console.warn('Failed to parsing', error)
})
}
})
18 changes: 18 additions & 0 deletions app/javascript/user-recent-reports.js
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)
}
})
62 changes: 62 additions & 0 deletions app/javascript/user-recent-reports.vue
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>
17 changes: 6 additions & 11 deletions app/javascript/user_mentor_memo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,15 @@ section.a-card.is-memo.is-only-mentor
)
i.fas.fa-pen
| 編集
div(
:class='{ "a-card": productsMode, "thread-comment-form__form": !productsMode }',
v-show='editing'
)
div(
:class='[{ "form-tabs": productsMode, "a-form-tabs": !productsMode }, "js-tabs"]'
)
div(
:class='[{ "is-active": isActive("memo"), "form-tabs__tab": productsMode, "a-form-tabs__tab": !productsMode }, "js-tabs__tab"]',
.a-card__inner(v-show='editing')
.form-tabs.js-tabs
.form-tabs__tab.js-tabs__tab(
:class='{ "is-active": isActive("memo") }',
@click='changeActiveTab("memo")'
)
| メモ
div(
:class='[{ "is-active": isActive("preview"), "form-tabs__tab": productsMode, "a-form-tabs__tab": !productsMode }, "js-tabs__tab"]',
.form-tabs__tab.js-tabs__tab(
:class='{ "is-active": isActive("preview") }',
@click='changeActiveTab("preview")'
)
| プレビュー
Expand Down
3 changes: 0 additions & 3 deletions app/views/admin/companies/index.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ header.page-header
tr.admin-table__labels
th.admin-table__label = Company.human_attribute_name :name
th.admin-table__label = Company.human_attribute_name :logo
th.admin-table__label = Company.human_attribute_name :description
th.admin-table__label = Company.human_attribute_name :website
th.admin-table__label.actions リンク
th.admin-table__label.actions 操作
Expand All @@ -36,8 +35,6 @@ header.page-header
td.admin-table__item-value.is-text-align-center
- if company.logo.attached?
= image_tag company.logo_url, class: 'admin-table__item-logo-image'
td.admin-table__item-value
= company.description
td.admin-table__item-value
= company.website
td.admin-table__item-value.is-text-align-center
Expand Down
8 changes: 5 additions & 3 deletions app/views/admin/users/_table.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,11 @@
td.admin-table__item-value.is-text-align-center
- if user.subscription_id?
= link_to user.subscription_url,
class: 'a-button is-sm is-info',
target: '_blank', rel: 'noopener' do
i.fas.fa-credit-card
class: 'subscription-status',
target: '_blank',
rel: 'noopener',
data: { 'subscription-id': user.subscription_id } do
i.fas.fa-spinner.fa-pulse
- else
| -
td.admin-table__item-value.is-text-align-center
Expand Down
2 changes: 1 addition & 1 deletion app/views/api/reports/_report.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
json.id report.id
json.title truncate(raw(report.title), length: 46)
json.title truncate(report.title, {length: 46, escape: false})
json.reportedOn l(report.reported_on)
json.url report_url(report)
json.editURL edit_report_path(report)
Expand Down
2 changes: 1 addition & 1 deletion app/views/api/reports/recents/index.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
json.array! @reports do |report|
json.id report.id
json.title truncate(raw(report.title), length: 46)
json.title truncate(report.title, {length: 46, escape: false})
json.reported_on l(report.reported_on)
json.url report_url(report)
json.check report.checks.present?
Expand Down
Loading

0 comments on commit 4c96b27

Please sign in to comment.