Skip to content

Commit

Permalink
#14 #12 신고에 대한 항목 기능을 제공하도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
xharpenParksuhyeon committed Jun 17, 2022
1 parent b60b8be commit e960255
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 44 deletions.
24 changes: 19 additions & 5 deletions src/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use XePresenter;
use Auth;
use App\Http\Controllers\Controller;
use Xpressengine\Category\CategoryHandler;
use Xpressengine\Http\Request;
use Xpressengine\Plugins\Claim\Exceptions\AlreadyClaimedHttpException;
use Xpressengine\Plugins\Claim\Handler;
Expand Down Expand Up @@ -75,12 +76,23 @@ public function index(Request $request)
*
* @return \Xpressengine\Presenter\Presentable
*/
public function modal(Request $request)
public function modal(Request $request, CategoryHandler $categoryHandler)
{
$config = $this->handler->getConfig();
$categoryItems = collect([]);

\XeFrontend::translation(['claim::msgClaimReceived']);

if ($config->get('category', false) === true) {
$categoryItems = $categoryHandler->items()
->where('category_id', $config->get('categoryId'))
->orderBy('ordering')
->get();
}

return api_render('claim::views.modal', [
'config' => $config
'config' => $config,
'categoryItems' => $categoryItems
]);
}

Expand All @@ -99,15 +111,17 @@ public function store(Request $request)
$targetId = $request->get('targetId');
$shortCut = $request->get('shortCut');
$categoryItem = $request->get('categoryItem');
$message = $request->get('message');

$this->handler->set($from);

try {
$this->handler->add($targetId, Auth::user(), $shortCut, $categoryItem);
$this->handler->add($targetId, Auth::user(), $shortCut, $categoryItem, $message);
} catch (\Exception $e) {
throw new AlreadyClaimedHttpException;
}
return $this->index();

return $this->index($request);
}

/**
Expand All @@ -124,6 +138,6 @@ public function destroy(Request $request)

$this->handler->removeByTargetId($targetId, Auth::user());

return $this->index();
return $this->index($request);
}
}
21 changes: 13 additions & 8 deletions src/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,14 @@ public function removeByTargetId($targetId, UserInterface $author)
/**
* 신고 추가
*
* @param string $targetId targetId
* @param UserInterface $author user instance
* @param string $shortCut 바로가기
*
* @param string $targetId targetId
* @param UserInterface $author user instance
* @param string $shortCut 바로가기
* @param mixed|null $categoryItem
* @param null $message
* @return void
*/
public function add($targetId, UserInterface $author, $shortCut, int $categoryItemId = null)
public function add($targetId, UserInterface $author, $shortCut, $categoryItem = null, $message = null)
{
if ($this->has($targetId, $author) === true) {
throw new Exceptions\AlreadyClaimedException;
Expand All @@ -144,11 +145,15 @@ public function add($targetId, UserInterface $author, $shortCut, int $categoryIt
'short_cut' => $shortCut,
'target_id' => $targetId,
'user_id' => $author->getId(),
'ipaddress' => request()->ip()
'ipaddress' => request()->ip(),
];

if ($categoryItemId !== null && $config->get('category') === true) {
$data['category_item_id'] = $categoryItemId;
if ($categoryItem !== null && $config->get('category') === true) {
$data['category_item_id'] = $categoryItem;
}

if ($message !== null) {
$data['message'] = $message;
}

ClaimLog::create($data);
Expand Down
49 changes: 18 additions & 31 deletions views/modal.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,24 @@
<div class="skin-modal-desc">신고는 반대 의견을 표시하는 기능이 아닙니다.</div>
</div>
<div class="xe-modal-body skin-modal-body">
{{ csrf_field() }}

<input type="hidden" name="_token" value="{{ csrf_token() }}">
<input type="hidden" name="from" value="{{ request('from') }}" />
<input type="hidden" name="targetId" value="{{ request('targetId') }}" />
<input type="hidden" name="shortCut" value="{{ request('shortCut') }}" />

<div class="skin-modal-sub">신고사유<span class="skin-modal-desc">여러 사유에 해당하는 경우 대표적인 사유 1개 선택</span></div>

<div class="skin-modal-content-toggle-wrap">
<label>
<input name="claim_type" type="radio" value="1" />
회원 분란 유도
</label>
<label>
<input name="claim_type" type="radio" value="1" />
허위사실 유포
</label>
<label>
<input name="claim_type" type="radio" value="1" />
욕설/반말북적절한 언어
</label>
<label>
<input name="claim_type" type="radio" value="1" />
음란성/선정성
</label>
<label>
<input name="claim_type" type="radio" value="1" />
영리목적/홍보상
</label>
@foreach($categoryItems as $categoryItem)
<label>
<input name="categoryItem" type="radio" value="{{ $categoryItem->id }}" required/>
{{ xe_trans($categoryItem->word) }}
</label>
@endforeach
</div>
<textarea name="calim_description" maxLength="300" placeholder="신고사유 설명이 추가로 필요하실 경우에만 작성해주세요.\n(최대 300자 이내로 작성해주세요.)" value="">
</textarea>

<textarea name="message" maxLength="300" placeholder="신고사유 설명이 추가로 필요하실 경우에만 작성해주세요.\n(최대 300자 이내로 작성해주세요.)" value="" style="resize: none"></textarea>

<div class="skin-modal-content-alert">
<ul>
<li>허위 신고의 경우, 신고자의 서비스 활동이 제한될 수 있으니 신중하게 신고해주세요.</li>
Expand All @@ -54,11 +42,9 @@
$("#claim-modal").submit(function(e) {
e.preventDefault();
var $this = $(this);
var formData = new FormData(this);
console.log(this);
console.log(formData);
$.ajax({
cache : false,
url : "{{ route('fixed.claim.store') }}",
Expand All @@ -67,7 +53,8 @@
type : 'POST',
data : formData,
success : function(data) {
$(this).find('button.xe-btn-secondary').click();
$this.find('.skin-modal-btn--cancle').click();
XE.toast('success', XE.Lang.trans('claim::msgClaimReceived'));
}
});
});
Expand All @@ -83,7 +70,7 @@
font-family: 'Pretendard';
color: white;
}
.skin-poly-modal .skin-modal-header {
background: #333;
border-bottom: none;
Expand Down Expand Up @@ -175,4 +162,4 @@
height: 150px;
padding: 10px;
}
</style>
</style>

0 comments on commit e960255

Please sign in to comment.