This commit is contained in:
@@ -127,7 +127,7 @@ class PostsController < ApplicationController
|
||||
|
||||
post = Post.new(title:, url:, thumbnail_base: nil, uploaded_user: current_user,
|
||||
original_created_from:, original_created_before:)
|
||||
post.thumbnail.attach(thumbnail)
|
||||
post.thumbnail.attach(thumbnail) if thumbnail.present?
|
||||
|
||||
ApplicationRecord.transaction do
|
||||
post.save!
|
||||
@@ -149,8 +149,8 @@ class PostsController < ApplicationController
|
||||
render json: PostRepr.base(post), status: :created
|
||||
rescue ArgumentError => e
|
||||
render json: { errors: [e.message] }, status: :unprocessable_entity
|
||||
rescue ActiveRecord::RecordInvalid
|
||||
render json: { errors: post.errors.full_messages }, status: :unprocessable_entity
|
||||
rescue ActiveRecord::RecordInvalid => e
|
||||
render json: { errors: e.record.errors.full_messages }, status: :unprocessable_entity
|
||||
rescue Tag::NicoTagNormalisationError
|
||||
head :bad_request
|
||||
end
|
||||
@@ -204,8 +204,8 @@ class PostsController < ApplicationController
|
||||
render json:, status: :ok
|
||||
rescue ArgumentError => e
|
||||
render json: { errors: [e.message] }, status: :unprocessable_entity
|
||||
rescue ActiveRecord::RecordInvalid
|
||||
render json: post.errors, status: :unprocessable_entity
|
||||
rescue ActiveRecord::RecordInvalid => e
|
||||
render json: { errors: e.record.errors.full_messages }, status: :unprocessable_entity
|
||||
rescue Tag::NicoTagNormalisationError
|
||||
head :bad_request
|
||||
end
|
||||
|
||||
@@ -56,7 +56,7 @@ class Post < ApplicationRecord
|
||||
|
||||
def snapshot_tag_names = tags.joins(:tag_name).order('tag_names.name').pluck('tag_names.name')
|
||||
|
||||
def snapshot_parent_post_ids = parents.order(:parent_post_id).pluck(:parent_post_id)
|
||||
def snapshot_parent_post_ids = parents.order(:id).pluck(:id)
|
||||
|
||||
def related limit: nil
|
||||
ids = post_similarities.order(cos: :desc)
|
||||
|
||||
@@ -52,6 +52,9 @@ export default (({ post, onSave }: Props) => {
|
||||
onSave ({ ...post,
|
||||
title: data.title,
|
||||
tags: data.tags,
|
||||
parentPosts: data.parentPosts,
|
||||
childPosts: data.childPosts,
|
||||
siblingPosts: data.siblingPosts,
|
||||
originalCreatedFrom: data.originalCreatedFrom,
|
||||
originalCreatedBefore: data.originalCreatedBefore } as Post)
|
||||
toast ({ description: '更新しました.' })
|
||||
|
||||
@@ -42,8 +42,8 @@ export default (({ posts, onClick }: Props) => {
|
||||
layoutId={layoutId}
|
||||
className={cn ('w-full h-full overflow-hidden rounded-xl shadow',
|
||||
'transform-gpu will-change-transform',
|
||||
(post.childPosts ?? []).length > 0 && 'border-4 border-green-500',
|
||||
(post.parentPosts ?? []).length > 0 && 'border-4 border-yellow-500')}
|
||||
(post.childPosts ?? []).length > 0 && 'outline-4 border-green-500',
|
||||
(post.parentPosts ?? []).length > 0 && 'outline-4 border-yellow-500')}
|
||||
whileHover={{ scale: 1.02 }}
|
||||
onLayoutAnimationStart={() => {
|
||||
if (!(cardRef.current))
|
||||
|
||||
@@ -95,8 +95,8 @@ export default (() => {
|
||||
<col className="w-96"/>
|
||||
{/* タグ */}
|
||||
<col className="w-[48rem]"/>
|
||||
{/* 親投稿 */}
|
||||
<col className="w-[48rem]"/>
|
||||
{/* TODO: 親投稿 */}
|
||||
{/* <col className="w-[48rem]"/> */}
|
||||
{/* オリジナルの投稿日時 */}
|
||||
<col className="w-96"/>
|
||||
{/* 更新日時 */}
|
||||
@@ -112,7 +112,8 @@ export default (() => {
|
||||
<th className="p-2 text-left">タイトル</th>
|
||||
<th className="p-2 text-left">URL</th>
|
||||
<th className="p-2 text-left">タグ</th>
|
||||
<th className="p-2 text-left">親投稿</th>
|
||||
{/* TODO: 親投稿の履歴 */}
|
||||
{/* <th className="p-2 text-left">親投稿</th> */}
|
||||
<th className="p-2 text-left">オリジナルの投稿日時</th>
|
||||
<th className="p-2 text-left">更新日時</th>
|
||||
<th className="p-2"/>
|
||||
@@ -183,7 +184,8 @@ export default (() => {
|
||||
{tag.name}
|
||||
</span>))))}
|
||||
</td>
|
||||
<td className="p-2">
|
||||
{/* TODO: 親投稿の履歴 */}
|
||||
{/* <td className="p-2">
|
||||
{change.parentPosts.map ((pp, i) => (
|
||||
pp.type === 'added'
|
||||
? (
|
||||
@@ -204,7 +206,7 @@ export default (() => {
|
||||
<span key={i} className="mr-2">
|
||||
{pp.title}
|
||||
</span>))))}
|
||||
</td>
|
||||
</td> */}
|
||||
<td className="p-2">
|
||||
{change.versionNo === 1
|
||||
? originalCreatedAtString (change.originalCreatedFrom.current,
|
||||
@@ -251,7 +253,10 @@ export default (() => {
|
||||
.filter (t => t.slice (0, 5) !== 'nico:')
|
||||
.join (' '),
|
||||
parent_post_ids:
|
||||
change.parentPosts.map (p => p.id).join (' '),
|
||||
change.parentPosts
|
||||
.filter (p => p.type !== 'removed')
|
||||
.map (p => p.id)
|
||||
.join (' '),
|
||||
original_created_from:
|
||||
change.originalCreatedFrom.current,
|
||||
original_created_before:
|
||||
|
||||
Reference in New Issue
Block a user