mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
update the createRemarkLogic, so all modules are able to use it
create a RemarkFormComponent update order page to use this API clean up old remark API
This commit is contained in:
@@ -1,62 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Http\Resources\CompanyModuleResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateCompanyRemarkLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Company Module Remark',
|
||||
'message' => 'You have successfully created a new Company Module Remark'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/** @var CreateRemarkProcessor */
|
||||
private $createRemarkProcessor;
|
||||
|
||||
/**
|
||||
* CreateCompanyRemarkLogic constructor.
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param CreateRemarkProcessor $createRemarkProcessor
|
||||
*/
|
||||
public function __construct(FetchesCompanyModule $fetchesCompanyModule, CreateRemarkProcessor $createRemarkProcessor)
|
||||
{
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->createRemarkProcessor = $createRemarkProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$companyModule = $this->fetchesCompanyModule->execute(['id' => $request->route('id')]);
|
||||
|
||||
$object = new RemarkObject($request->input('content'), auth()->user()->id);
|
||||
|
||||
$this->createRemarkProcessor->execute($companyModule, $object);
|
||||
|
||||
return $this->resourceResponse(new CompanyModuleResource($companyModule));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
||||
use App\Http\Resources\OrderResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateOrderRemarkLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Order',
|
||||
'message' => 'You have successfully created a new Order'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesOrder */
|
||||
private $fetchesOrder;
|
||||
|
||||
/** @var CreateRemarkProcessor */
|
||||
private $createRemarkProcessor;
|
||||
|
||||
/**
|
||||
* CreateOrderRemarkLogic constructor.
|
||||
* @param FetchesOrder $fetchesOrder
|
||||
* @param CreateRemarkProcessor $createRemarkProcessor
|
||||
*/
|
||||
public function __construct(FetchesOrder $fetchesOrder, CreateRemarkProcessor $createRemarkProcessor)
|
||||
{
|
||||
$this->fetchesOrder = $fetchesOrder;
|
||||
$this->createRemarkProcessor = $createRemarkProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$order = $this->fetchesOrder->execute(['id' => $request->route('id')]);
|
||||
|
||||
$object = new RemarkObject($request->input('content'), auth()->user()->id);
|
||||
|
||||
$this->createRemarkProcessor->execute($order, $object);
|
||||
|
||||
return $this->resourceResponse(new OrderResource($order));
|
||||
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -20,8 +20,8 @@ class CreateContainerRemarkLogic extends AbstractControllerLogic
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Container',
|
||||
'message' => 'You have successfully created a new Container'
|
||||
'title' => 'Created Container Remark',
|
||||
'message' => 'You have successfully created a new Container Remark'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -4,18 +4,16 @@ namespace App\Classes\Modules\Remarks\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Remarks\Services\CreatesRemark;
|
||||
use App\Classes\Modules\Remarks\Standards\Rules\CanCreateRemark;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Accounts\Services\FetchesUser;
|
||||
use App\Http\Resources\RemarkResource;
|
||||
use ErrorException;
|
||||
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Http\Resources\RemarkResource;
|
||||
|
||||
class CreateRemarkLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@@ -26,25 +24,16 @@ class CreateRemarkLogic extends AbstractControllerLogic
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanCreateRemark */
|
||||
private $canCreateRemark;
|
||||
|
||||
/** @var CreatesRemark */
|
||||
private $createsRemark;
|
||||
|
||||
/** @var FetchesUser */
|
||||
private $fetchesUser;
|
||||
/** @var CreateRemarkProcessor */
|
||||
private $createRemarkProcessor;
|
||||
|
||||
/**
|
||||
* CreateRemarkLogic constructor.
|
||||
* @param CanCreateRemark $canCreateRemark
|
||||
* @param CreatesRemark $createsRemark
|
||||
* @param CreateRemarkProcessor $createRemarkProcessor
|
||||
*/
|
||||
public function __construct(CanCreateRemark $canCreateRemark, CreatesRemark $createsRemark, FetchesUser $fetchesUser)
|
||||
public function __construct(CreateRemarkProcessor $createRemarkProcessor)
|
||||
{
|
||||
$this->canCreateRemark = $canCreateRemark;
|
||||
$this->createsRemark = $createsRemark;
|
||||
$this->fetchesUser = $fetchesUser;
|
||||
$this->createRemarkProcessor = $createRemarkProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,15 +45,18 @@ class CreateRemarkLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$classs = '\\App\\Models\\' . Str::studly($request->input('model_type'));
|
||||
|
||||
$object = new RemarkObject($request->input('content'), $request->input('commenter_id'));
|
||||
if (!class_exists($classs)) {
|
||||
throw new MalformedRequestException('Unable to process this entity');
|
||||
}
|
||||
|
||||
$remarkOwner = $classs::find($request->route('id'));
|
||||
|
||||
$this->canCreateRemark->passes($object);
|
||||
$remarkObject = new RemarkObject($request->input('content'), auth()->user()->id);
|
||||
|
||||
$query = $this->createsRemark->execute($this->fetchesUser->execute(['id' => $request->input('commenter_id')]), $object);
|
||||
|
||||
return $this->resourceResponse(new RemarkResource($query));
|
||||
$remmark = $this->createRemarkProcessor->execute($remarkOwner, $remarkObject);
|
||||
|
||||
return $this->resourceResponse(new RemarkResource($remmark));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Companies;
|
||||
|
||||
use App\Classes\Modules\Companies\ControllersLogic\CreateCompanyRemarkLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateCompanyModulesRemarkController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param CreateCompanyModulesRemarkLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function create(Request $request, CreateCompanyRemarkLogic $logic): JsonResponse
|
||||
{
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Orders;
|
||||
|
||||
use App\Classes\Modules\Orders\ControllersLogic\CreateOrderRemarkLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateOrderRemarkController
|
||||
{
|
||||
public function create(Request $request, CreateOrderRemarkLogic $logic): JsonResponse{
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -5,9 +5,9 @@
|
||||
<div class="row justify-content-center" v-show="!isLoading">
|
||||
<div class="col">
|
||||
<div class="row m-b-20">
|
||||
<div class="col">
|
||||
<div class="col text-center">
|
||||
<h3 class="all-caps">Are you Sure?</h3>
|
||||
<div class="fs-11">Are you sure you want to delete this comment?</div>
|
||||
<div class="fs-11">Are you sure you want to delete this remark?</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
+6
-2
@@ -37,18 +37,22 @@
|
||||
</template>
|
||||
<script>
|
||||
import ModalFormHandler from '../../../general/mixins/modalFormHandler';
|
||||
import { required, requiredIf } from "vuelidate/lib/validators";
|
||||
export default {
|
||||
props: {
|
||||
data:{
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
module_type: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
parameters: {
|
||||
content: this.data.remarks.length > 0 ? this.data.remarks[0].content : '',
|
||||
model_type: this.module_type
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -61,7 +65,7 @@
|
||||
},
|
||||
methods: {
|
||||
submitForm() {
|
||||
this.submit(this.data.remarks.length > 0 ? this.route('api.remark.update', this.data.remarks[0].id) : this.route('api.company.module.remark.create', this.data.id), this.data.remarks.length > 0 ? 'put' : 'post', this.section, true, true);
|
||||
this.submit(this.data.remarks.length > 0 ? this.route('api.remark.update', this.data.remarks[0].id) : this.route('api.remark.create', this.data.id), this.data.remarks.length > 0 ? 'put' : 'post', this.section, true, true);
|
||||
}
|
||||
},
|
||||
mixins: [ModalFormHandler]
|
||||
@@ -1,49 +0,0 @@
|
||||
<template>
|
||||
<div class="row">
|
||||
<div class="col-6 p-r-0">
|
||||
<validation-wrapper-component :validator="$v.parameters.content">
|
||||
<input type="text" class="form-control fs-12" placeholder="Make a remark on this order." v-model.trim="parameters.content">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
<div class="col-auto bg-success d-flex justify-content-center align-items-center pointer text-white">
|
||||
<i class="fa fa-check" @click="submitForm"></i>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import modalFormHandler from '../../../general/mixins/modalFormHandler';
|
||||
import { required } from "vuelidate/lib/validators";
|
||||
|
||||
export default {
|
||||
props: {
|
||||
id: {
|
||||
type: Number,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
parameters: {
|
||||
content: this.content,
|
||||
},
|
||||
};
|
||||
},
|
||||
validations: {
|
||||
parameters: {
|
||||
content: { required },
|
||||
}
|
||||
},
|
||||
created() {
|
||||
if (this.data) {
|
||||
this.parameters.content = this.data.content
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
submitForm() {
|
||||
this.submit(this.data ? this.route('api.remark.update', this.data.id) : this.route('api.order.remark.create', this.id), this.data ? 'put' : 'post', this.section, true, true);
|
||||
this.$emit('submit')
|
||||
}
|
||||
},
|
||||
mixins: [modalFormHandler]
|
||||
}
|
||||
</script>
|
||||
@@ -35,39 +35,25 @@
|
||||
<div class="row">
|
||||
<div class="col-auto d-flex align-items-center">
|
||||
<h6 class="no-margin"><b>Remark:</b></h6>
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" type="orderRemark">
|
||||
<remark-form-component module_type="Order" :data="order" :section="section"></remark-form-component>
|
||||
</modal-component>
|
||||
</div>
|
||||
<div class="col-auto p-l-0" v-if="!addComment && order.remarks.length == 0">
|
||||
<div class="btn btn-xs btn-outline-info b-rad-none pointer" @click="addComment = !addComment">Add a Remark</div>
|
||||
<div class="col-auto p-l-0" v-if="order.remarks.length == 0">
|
||||
<div class="btn btn-xs btn-outline-info b-rad-none pointer requestModal" data-type="orderRemark">Add a Remark</div>
|
||||
</div>
|
||||
<div class="col d-flex align-items-center pl-3 pl-md-0" v-if="order.remarks.length >= 1 && !isEditRemark">
|
||||
<h6 class="no-margin">{{order.remarks[0].content}}</h6>
|
||||
<span class="btn btn-md btn-default m-l-10" @click="isEditRemark = !isEditRemark">
|
||||
<div class="col d-flex align-items-center pl-3 pl-md-0" v-if="order.remarks.length >= 1">
|
||||
<h6 class="no-margin">{{ order.remarks[0].content }}</h6>
|
||||
<span class="btn btn-md btn-default m-l-10 requestModal" data-type="orderRemark">
|
||||
<i class="fa fa-edit"></i>
|
||||
</span>
|
||||
<span class="btn btn-md btn-default m-l-5 requestModal" data-type="deleteOrderRemark">
|
||||
<i class="fa fa-trash"></i>
|
||||
</span>
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="deleteOrderRemark">
|
||||
<delete-order-remark-form-component :section="section" :data="order.remarks[0]" v-on:submit="addComment=false"></delete-order-remark-form-component>
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" type="deleteOrderRemark">
|
||||
<delete-remark-form-component :section="section" :data="order.remarks[0]"></delete-remark-form-component>
|
||||
</modal-component>
|
||||
</div>
|
||||
<div class="col pl-2 pl-md-0" v-if="isEditRemark">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<order-remark-form-component :section="section" :data="order.remarks[0]" :id="order.id" v-on:submit="isEditRemark=false"></order-remark-form-component>
|
||||
</div>
|
||||
<div class="col-auto d-flex align-items-center">
|
||||
<div class="row m-l-5">
|
||||
<div class="col b-a btn btn-sm btn-default" @click="isEditRemark = !isEditRemark">
|
||||
Cancel
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col p-l-0" v-if="order.remarks.length === 0 && addComment">
|
||||
<order-remark-form-component :section="section" :id="order.id"></order-remark-form-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -465,7 +451,6 @@
|
||||
section: 'orderProfileSection',
|
||||
isLoading: true,
|
||||
order: null,
|
||||
isEditRemark: false,
|
||||
addComment: false,
|
||||
}
|
||||
},
|
||||
|
||||
@@ -42,13 +42,20 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col" v-if="data.remarks.length > 0">
|
||||
<div class="font-heading all-caps">{{ data.remarks[0].content }} <i class="fa fa-edit pointer fa-fw m-l-5 requestModal text-primary" data-type="warehouseRemark"></i></div>
|
||||
<div class="font-heading">
|
||||
{{ data.remarks[0].content }}
|
||||
<i class="fa fa-edit pointer fa-fw m-l-5 text-primary requestModal " data-type="warehouseRemark"></i>
|
||||
<i class="fa fa-trash pointer fa-fw m-l-5 text-primary requestModal" data-type="deleteWarehouseRemark"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="data.remarks.length == 0" class="col muted hover-primary pointer fs-10 requestModal" data-type="warehouseRemark">
|
||||
<i class="fa fa-plus"></i> Add
|
||||
</div>
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" type="warehouseRemark">
|
||||
<warehouse-remark-form-component :data="data" section="warhouseListSection"></warehouse-remark-form-component>
|
||||
<remark-form-component module_type="CompanyModule" :data="data" section="warhouseListSection"></remark-form-component>
|
||||
</modal-component>
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" type="deleteWarehouseRemark">
|
||||
<delete-remark-form-component :section="section" :data="data.remarks[0]"></delete-remark-form-component>
|
||||
</modal-component>
|
||||
</div>
|
||||
</div>
|
||||
@@ -75,7 +82,7 @@
|
||||
required: false
|
||||
},
|
||||
section: {
|
||||
default: ''
|
||||
default: 'warhouseListSection'
|
||||
},
|
||||
},
|
||||
mixins: [modalFormHandler]
|
||||
|
||||
@@ -33,6 +33,4 @@ Route::group(['prefix' => 'company', 'as' => 'company.', 'namespace' => 'Compani
|
||||
});
|
||||
|
||||
Route::get('/module/list', 'ListCompanyModulesController@list')->name('module.list');
|
||||
|
||||
Route::post('module/{id}/remark/create', 'CreateCompanyModulesRemarkController@create')->name('module.remark.create');
|
||||
});
|
||||
|
||||
@@ -18,6 +18,4 @@ Route::group(['prefix' => 'order', 'as' => 'order.', 'namespace' => 'Orders'], f
|
||||
|
||||
Route::put('/assign-remark/{id}', 'AssignOrderRemarkController@create')->name('assign.remark');
|
||||
Route::get('/{id}/shipping-cost', 'ShippingCostController@calculate')->name('shipping.cost');
|
||||
|
||||
Route::post('/{id}/remark/create', 'CreateOrderRemarkController@create')->name('remark.create');
|
||||
});
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ use Illuminate\Support\Facades\Route;
|
||||
Route::group(['namespace' => 'Remarks', 'as' => 'remark.', 'prefix' => 'remark'], function () {
|
||||
Route::get('/{id}/show', 'FetchRemarkController@fetch')->name('show');
|
||||
Route::get('/list', 'ListRemarksController@list')->name('list');
|
||||
Route::post('/create', 'CreateRemarkController@create')->name('create');
|
||||
Route::post('/{id}/create', 'CreateRemarkController@create')->name('create');
|
||||
Route::put('/update/{id}', 'UpdateRemarkController@update')->name('update');
|
||||
Route::delete('/delete/{id}', 'DeleteRemarkController@delete')->name('delete');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user