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