From 9252134cc478174a901dc054f4c7a25a8df59164 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 29 Oct 2021 16:20:05 +0800 Subject: [PATCH 1/3] wip update container comments(remarks) section and implement api --- .../Containers/CreateContainerRemarkLogic.php | 4 +- app/Http/Resources/ContainerResource.php | 2 + app/Http/Resources/RemarkResource.php | 4 +- app/Models/Remark.php | 9 +++ .../ContainerProfileSectionComponent.vue | 68 ++++++++++++------- routes/packing_list.php | 1 + 6 files changed, 59 insertions(+), 29 deletions(-) diff --git a/app/Classes/Modules/PackingLists/ControllersLogic/Containers/CreateContainerRemarkLogic.php b/app/Classes/Modules/PackingLists/ControllersLogic/Containers/CreateContainerRemarkLogic.php index 175575cf..bb4b2a06 100644 --- a/app/Classes/Modules/PackingLists/ControllersLogic/Containers/CreateContainerRemarkLogic.php +++ b/app/Classes/Modules/PackingLists/ControllersLogic/Containers/CreateContainerRemarkLogic.php @@ -53,9 +53,9 @@ class CreateContainerRemarkLogic extends AbstractControllerLogic public function logic(Request $request) : JsonResponse { - $container = $this->fetchesContainer->execute(['id' => $request->input('container_id')]); + $container = $this->fetchesContainer->execute(['id' => $request->route('id')]); - $object = new RemarkObject($request->input('content'), 1); + $object = new RemarkObject($request->input('content'), auth()->user()->id); $this->createRemarkProcessor->execute($container, $object); diff --git a/app/Http/Resources/ContainerResource.php b/app/Http/Resources/ContainerResource.php index b9daa54f..23cb7817 100644 --- a/app/Http/Resources/ContainerResource.php +++ b/app/Http/Resources/ContainerResource.php @@ -3,6 +3,7 @@ namespace App\Http\Resources; use App\Classes\ValueObjects\Constants\ContainerTypes; +use App\Models\Remark; use Illuminate\Http\Resources\Json\JsonResource; class ContainerResource extends JsonResource @@ -26,6 +27,7 @@ class ContainerResource extends JsonResource 'packing_lists' => PackingListResource::collection($this->whenLoaded('packingLists', function(){ return $this->packingLists()->whereHas('packages')->get(); })), + 'remarks' => RemarkResource::collection($this->remarks), 'status' => $this->status ]; } diff --git a/app/Http/Resources/RemarkResource.php b/app/Http/Resources/RemarkResource.php index d5f93d79..16d206d8 100644 --- a/app/Http/Resources/RemarkResource.php +++ b/app/Http/Resources/RemarkResource.php @@ -16,8 +16,10 @@ class RemarkResource extends JsonResource { return [ 'id' => $this->id, - 'commenter_id' => $this->commenter_id, + 'commenter' => new UserResource($this->commenter), 'content' => $this->content, + 'created_at' => $this->created_at->format('d-m-Y H:i'), + 'long_ago' => $this->created_at->diffForHumans() ]; } } diff --git a/app/Models/Remark.php b/app/Models/Remark.php index 863c3001..f2de3a5c 100644 --- a/app/Models/Remark.php +++ b/app/Models/Remark.php @@ -4,6 +4,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Relations\MorphTo; use Illuminate\Database\Eloquent\SoftDeletes; +use Illuminate\Database\Eloquent\Relations\BelongsTo; class Remark extends AbstractModel { @@ -15,4 +16,12 @@ class Remark extends AbstractModel { return $this->morphTo(); } + + /** + * @return BelongsTo + */ + public function commenter(): BelongsTo + { + return $this->BelongsTo(User::class, 'commenter_id', 'id'); + } } diff --git a/resources/assets/vue/components/containers/elements/ContainerProfileSectionComponent.vue b/resources/assets/vue/components/containers/elements/ContainerProfileSectionComponent.vue index f2e0e2a7..916c4eae 100644 --- a/resources/assets/vue/components/containers/elements/ContainerProfileSectionComponent.vue +++ b/resources/assets/vue/components/containers/elements/ContainerProfileSectionComponent.vue @@ -616,41 +616,57 @@
-
+ +
-
-
- -
+
-

Jacob Arlington

-
-
-
-
-

Adipisicing occaecat pariatur id sunt ullamco quis laborum irure ea excepteur enim dolore est. Deserunt do consectetur ex in dolor labore ad reprehenderit velit laboris officia ut.

+
+
+ {{remarks.commenter.name.substr(0, 1)}} +
+
+
+
+

{{remarks.commenter.name}}

+
+
+ {{remarks.long_ago}} +
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+
+
+
+
+

{{remarks.content}}

+
+
-
+
-
-
- -
-
-

Jacob Arlington

-
-
-
-
-

Adipisicing occaecat pariatur id sunt ullamco quis laborum irure ea excepteur enim dolore est. Deserunt do consectetur ex in dolor labore ad reprehenderit velit laboris officia ut.

-
-
+ +
+
+
-
diff --git a/routes/packing_list.php b/routes/packing_list.php index 7ee3a3ca..f32533c7 100644 --- a/routes/packing_list.php +++ b/routes/packing_list.php @@ -30,6 +30,7 @@ Route::group(['namespace' => 'PackingLists', 'as' => 'packing_list.', 'prefix' = Route::put('/update-dispatch-date/{id}', 'UpdateDispatchDateContainerController@update')->name('update_dispatch_date'); Route::put('/update-drop-date/{id}', 'UpdateDropDateContainerController@update')->name('update_drop_date'); Route::put('/complete/{id}', 'CompleteContainerController@complete')->name('complete'); + Route::post('/{id}/remark/create', 'CreateContainerRemarkController@create')->name('remark.create'); }); Route::group(['namespace' => 'Packages', 'as' => 'package.', 'prefix' => 'package'], function () { From feec49318b42a85fc42aba4d038e0389b83727b7 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sat, 30 Oct 2021 17:11:28 +0800 Subject: [PATCH 2/3] update container profile comment section with api --- .../elements/ContainerCommentComponent.vue | 64 +++++++++++++++++++ .../ContainerProfileSectionComponent.vue | 51 ++------------- .../DeleteContainerCommentFormComponent.vue | 32 ++++++++++ .../EditContainerCommentFormComponent.vue | 53 +++++++++++++++ .../CreateContainerCommentFormComponent.vue | 32 ++++++++++ 5 files changed, 185 insertions(+), 47 deletions(-) create mode 100644 resources/assets/vue/components/containers/elements/ContainerCommentComponent.vue create mode 100644 resources/assets/vue/components/containers/elements/DeleteContainerCommentFormComponent.vue create mode 100644 resources/assets/vue/components/containers/elements/EditContainerCommentFormComponent.vue create mode 100644 resources/assets/vue/components/containers/forms/CreateContainerCommentFormComponent.vue diff --git a/resources/assets/vue/components/containers/elements/ContainerCommentComponent.vue b/resources/assets/vue/components/containers/elements/ContainerCommentComponent.vue new file mode 100644 index 00000000..8d961664 --- /dev/null +++ b/resources/assets/vue/components/containers/elements/ContainerCommentComponent.vue @@ -0,0 +1,64 @@ + + diff --git a/resources/assets/vue/components/containers/elements/ContainerProfileSectionComponent.vue b/resources/assets/vue/components/containers/elements/ContainerProfileSectionComponent.vue index 916c4eae..feddd039 100644 --- a/resources/assets/vue/components/containers/elements/ContainerProfileSectionComponent.vue +++ b/resources/assets/vue/components/containers/elements/ContainerProfileSectionComponent.vue @@ -619,54 +619,10 @@
-
-
-
-
- {{remarks.commenter.name.substr(0, 1)}} -
-
-
-
-

{{remarks.commenter.name}}

-
-
- {{remarks.long_ago}} -
-
-
-
-
-
- -
-
- -
-
-
-
-
-
-
-
-
-
-

{{remarks.content}}

-
-
-
-
-
-
-
-
- -
-
- +
+
@@ -695,7 +651,8 @@ CBMcapacity: 30, tabShowing: 'Timeline', selectAllPackingList: false, - selectedPackageList: [] + selectedPackageList: [], + deleteCommentId: '', } }, computed: { diff --git a/resources/assets/vue/components/containers/elements/DeleteContainerCommentFormComponent.vue b/resources/assets/vue/components/containers/elements/DeleteContainerCommentFormComponent.vue new file mode 100644 index 00000000..3bd97a45 --- /dev/null +++ b/resources/assets/vue/components/containers/elements/DeleteContainerCommentFormComponent.vue @@ -0,0 +1,32 @@ + + \ No newline at end of file diff --git a/resources/assets/vue/components/containers/elements/EditContainerCommentFormComponent.vue b/resources/assets/vue/components/containers/elements/EditContainerCommentFormComponent.vue new file mode 100644 index 00000000..315e8651 --- /dev/null +++ b/resources/assets/vue/components/containers/elements/EditContainerCommentFormComponent.vue @@ -0,0 +1,53 @@ + + \ No newline at end of file diff --git a/resources/assets/vue/components/containers/forms/CreateContainerCommentFormComponent.vue b/resources/assets/vue/components/containers/forms/CreateContainerCommentFormComponent.vue new file mode 100644 index 00000000..48267409 --- /dev/null +++ b/resources/assets/vue/components/containers/forms/CreateContainerCommentFormComponent.vue @@ -0,0 +1,32 @@ + + From b0a2ab08c94f0649b2b32b5c0146beccaefa9f82 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sun, 31 Oct 2021 19:10:16 +0800 Subject: [PATCH 3/3] tody up container forms component --- .../ControllersLogic/UpdateRemarkLogic.php | 2 +- app/Http/Resources/RemarkResource.php | 1 + .../elements/ContainerCommentComponent.vue | 22 ++++--- .../elements/EditContainerFormComponent.vue | 59 ------------------- .../ContainerArrivalFormComponent.vue | 0 ....vue => ContainerCommentFormComponent.vue} | 23 +++++++- .../ContainerDepatureFormComponent.vue | 0 .../ContainerUnpackingFormContainer.vue} | 0 ...CreateDeliveryPackinglistFormComponent.vue | 0 .../DeleteContainerCommentFormComponent.vue | 0 .../EditContainerCommentFormComponent.vue | 1 - .../ListPackagelistFormComponent.vue | 0 .../RescheduleDateFormComponent.vue | 0 .../ContainerProfileSectionComponent.vue | 4 +- 14 files changed, 37 insertions(+), 75 deletions(-) delete mode 100644 resources/assets/vue/components/containers/elements/EditContainerFormComponent.vue rename resources/assets/vue/components/containers/{elements => forms}/ContainerArrivalFormComponent.vue (100%) rename resources/assets/vue/components/containers/forms/{CreateContainerCommentFormComponent.vue => ContainerCommentFormComponent.vue} (57%) rename resources/assets/vue/components/containers/{elements => forms}/ContainerDepatureFormComponent.vue (100%) rename resources/assets/vue/components/containers/{elements/containerUnpackingFormContainer.vue => forms/ContainerUnpackingFormContainer.vue} (100%) rename resources/assets/vue/components/containers/{elements => forms}/CreateDeliveryPackinglistFormComponent.vue (100%) rename resources/assets/vue/components/containers/{elements => forms}/DeleteContainerCommentFormComponent.vue (100%) rename resources/assets/vue/components/containers/{elements => forms}/EditContainerCommentFormComponent.vue (97%) rename resources/assets/vue/components/containers/{elements => forms}/ListPackagelistFormComponent.vue (100%) rename resources/assets/vue/components/containers/{elements => forms}/RescheduleDateFormComponent.vue (100%) rename resources/assets/vue/components/containers/{elements => sections}/ContainerProfileSectionComponent.vue (99%) diff --git a/app/Classes/Modules/Remarks/ControllersLogic/UpdateRemarkLogic.php b/app/Classes/Modules/Remarks/ControllersLogic/UpdateRemarkLogic.php index e9c0738f..5b3af8f8 100644 --- a/app/Classes/Modules/Remarks/ControllersLogic/UpdateRemarkLogic.php +++ b/app/Classes/Modules/Remarks/ControllersLogic/UpdateRemarkLogic.php @@ -55,7 +55,7 @@ class UpdateRemarkLogic extends AbstractControllerLogic */ public function logic(Request $request) : JsonResponse { - $object = new RemarkObject($request->input('content'), $request->input('commenter_id')); + $object = new RemarkObject($request->input('content'), auth()->user()->id); $this->canUpdateRemark->passes($object); diff --git a/app/Http/Resources/RemarkResource.php b/app/Http/Resources/RemarkResource.php index 16d206d8..24081934 100644 --- a/app/Http/Resources/RemarkResource.php +++ b/app/Http/Resources/RemarkResource.php @@ -17,6 +17,7 @@ class RemarkResource extends JsonResource return [ 'id' => $this->id, 'commenter' => new UserResource($this->commenter), + 'owner_id' => $this->owner_id, 'content' => $this->content, 'created_at' => $this->created_at->format('d-m-Y H:i'), 'long_ago' => $this->created_at->diffForHumans() diff --git a/resources/assets/vue/components/containers/elements/ContainerCommentComponent.vue b/resources/assets/vue/components/containers/elements/ContainerCommentComponent.vue index 8d961664..9cc32c2f 100644 --- a/resources/assets/vue/components/containers/elements/ContainerCommentComponent.vue +++ b/resources/assets/vue/components/containers/elements/ContainerCommentComponent.vue @@ -16,11 +16,9 @@
-
+
-
- -
+
@@ -28,6 +26,11 @@
+
+
+ +
+
@@ -36,13 +39,11 @@
-

{{item.content}}

+

{{item.content}}

+
- - - @@ -59,6 +60,11 @@ required: true, } }, + data(){ + return { + isEdit: false, + } + }, mixins: [componentHandler] } diff --git a/resources/assets/vue/components/containers/elements/EditContainerFormComponent.vue b/resources/assets/vue/components/containers/elements/EditContainerFormComponent.vue deleted file mode 100644 index 25df6f59..00000000 --- a/resources/assets/vue/components/containers/elements/EditContainerFormComponent.vue +++ /dev/null @@ -1,59 +0,0 @@ - - \ No newline at end of file diff --git a/resources/assets/vue/components/containers/elements/ContainerArrivalFormComponent.vue b/resources/assets/vue/components/containers/forms/ContainerArrivalFormComponent.vue similarity index 100% rename from resources/assets/vue/components/containers/elements/ContainerArrivalFormComponent.vue rename to resources/assets/vue/components/containers/forms/ContainerArrivalFormComponent.vue diff --git a/resources/assets/vue/components/containers/forms/CreateContainerCommentFormComponent.vue b/resources/assets/vue/components/containers/forms/ContainerCommentFormComponent.vue similarity index 57% rename from resources/assets/vue/components/containers/forms/CreateContainerCommentFormComponent.vue rename to resources/assets/vue/components/containers/forms/ContainerCommentFormComponent.vue index 48267409..a77807fa 100644 --- a/resources/assets/vue/components/containers/forms/CreateContainerCommentFormComponent.vue +++ b/resources/assets/vue/components/containers/forms/ContainerCommentFormComponent.vue @@ -1,12 +1,12 @@ @@ -15,6 +15,12 @@ import { required } from "vuelidate/lib/validators"; export default { + props: { + id: { + type: Number, + required: true + } + }, data() { return { parameters: { @@ -26,7 +32,18 @@ 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.packing_list.container.remark.create', this.id), this.data ? 'put' : 'post', this.section, true, true); + this.$emit('submit') + } + }, mixins: [modalFormHandler] } diff --git a/resources/assets/vue/components/containers/elements/ContainerDepatureFormComponent.vue b/resources/assets/vue/components/containers/forms/ContainerDepatureFormComponent.vue similarity index 100% rename from resources/assets/vue/components/containers/elements/ContainerDepatureFormComponent.vue rename to resources/assets/vue/components/containers/forms/ContainerDepatureFormComponent.vue diff --git a/resources/assets/vue/components/containers/elements/containerUnpackingFormContainer.vue b/resources/assets/vue/components/containers/forms/ContainerUnpackingFormContainer.vue similarity index 100% rename from resources/assets/vue/components/containers/elements/containerUnpackingFormContainer.vue rename to resources/assets/vue/components/containers/forms/ContainerUnpackingFormContainer.vue diff --git a/resources/assets/vue/components/containers/elements/CreateDeliveryPackinglistFormComponent.vue b/resources/assets/vue/components/containers/forms/CreateDeliveryPackinglistFormComponent.vue similarity index 100% rename from resources/assets/vue/components/containers/elements/CreateDeliveryPackinglistFormComponent.vue rename to resources/assets/vue/components/containers/forms/CreateDeliveryPackinglistFormComponent.vue diff --git a/resources/assets/vue/components/containers/elements/DeleteContainerCommentFormComponent.vue b/resources/assets/vue/components/containers/forms/DeleteContainerCommentFormComponent.vue similarity index 100% rename from resources/assets/vue/components/containers/elements/DeleteContainerCommentFormComponent.vue rename to resources/assets/vue/components/containers/forms/DeleteContainerCommentFormComponent.vue diff --git a/resources/assets/vue/components/containers/elements/EditContainerCommentFormComponent.vue b/resources/assets/vue/components/containers/forms/EditContainerCommentFormComponent.vue similarity index 97% rename from resources/assets/vue/components/containers/elements/EditContainerCommentFormComponent.vue rename to resources/assets/vue/components/containers/forms/EditContainerCommentFormComponent.vue index 315e8651..6101f736 100644 --- a/resources/assets/vue/components/containers/elements/EditContainerCommentFormComponent.vue +++ b/resources/assets/vue/components/containers/forms/EditContainerCommentFormComponent.vue @@ -9,7 +9,6 @@ - diff --git a/resources/assets/vue/components/containers/elements/ListPackagelistFormComponent.vue b/resources/assets/vue/components/containers/forms/ListPackagelistFormComponent.vue similarity index 100% rename from resources/assets/vue/components/containers/elements/ListPackagelistFormComponent.vue rename to resources/assets/vue/components/containers/forms/ListPackagelistFormComponent.vue diff --git a/resources/assets/vue/components/containers/elements/RescheduleDateFormComponent.vue b/resources/assets/vue/components/containers/forms/RescheduleDateFormComponent.vue similarity index 100% rename from resources/assets/vue/components/containers/elements/RescheduleDateFormComponent.vue rename to resources/assets/vue/components/containers/forms/RescheduleDateFormComponent.vue diff --git a/resources/assets/vue/components/containers/elements/ContainerProfileSectionComponent.vue b/resources/assets/vue/components/containers/sections/ContainerProfileSectionComponent.vue similarity index 99% rename from resources/assets/vue/components/containers/elements/ContainerProfileSectionComponent.vue rename to resources/assets/vue/components/containers/sections/ContainerProfileSectionComponent.vue index feddd039..a9d22e9c 100644 --- a/resources/assets/vue/components/containers/elements/ContainerProfileSectionComponent.vue +++ b/resources/assets/vue/components/containers/sections/ContainerProfileSectionComponent.vue @@ -622,7 +622,7 @@ - + @@ -633,9 +633,7 @@