Skip to content

Commit

Permalink
Merge branch 'release/0.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
w1lldone committed May 18, 2021
2 parents 414adbd + b057dd7 commit a3c0c84
Show file tree
Hide file tree
Showing 44 changed files with 842 additions and 393 deletions.
36 changes: 36 additions & 0 deletions app/Http/Controllers/DropboxLogControlle.php
@@ -0,0 +1,36 @@
<?php

namespace App\Http\Controllers;

use App\Models\DropboxLog;
use Illuminate\Http\Request;

class DropboxLogControlle extends Controller
{
public function update(DropboxLog $dropboxLog, Request $request)
{
$this->authorize('update', $dropboxLog->dropbox->station);

$data = $request->validate([
'weight' => 'numeric|nullable',
'final_weight' => 'numeric|nullable',
'starts_at' => 'date|nullable',
'ends_at' => 'date|nullable',
]);

$data['user_id'] = $request->user()->id;

$dropboxLog->update($data);

return $dropboxLog;
}

public function destroy(DropboxLog $dropboxLog)
{
$this->authorize('update', $dropboxLog->dropbox->station);

$dropboxLog->delete();

return response()->noContent();
}
}
8 changes: 0 additions & 8 deletions app/Http/Controllers/OperationController.php
Expand Up @@ -127,14 +127,6 @@ protected function createInspection(Dropbox $dropbox, $weight, $timestamp, User
'user_id' => $user->id
]);

$latestLog = $log->parent->children()->orderBy('ends_at', 'desc')->first();

// Update parent final_weight, ends_at
$log->parent->update([
'final_weight' => $latestLog->final_weight,
'ends_at' => $latestLog->ends_at,
]);

return $log;
}
}
22 changes: 22 additions & 0 deletions app/Models/DropboxLog.php
Expand Up @@ -32,12 +32,34 @@ protected static function booted()
}
});

// Listen to saved event
static::saved(function ($dropboxLog)
{
// Update parent final_weight, ends_at
if ($dropboxLog->parent_id) {
$latestLog = $dropboxLog->parent->children()->orderBy('ends_at', 'desc')->first();
$dropboxLog->parent->update([
'final_weight' => $latestLog->final_weight,
'ends_at' => $latestLog->ends_at,
]);
}
});

// Listen to the deleted event
static::deleted(function ($dropboxLog) {
// If the parent gets deleted, the childern will be deleted too
if ($dropboxLog->parent_id == null) {
$dropboxLog->children()->delete();
}

// Update parent final_weight, ends_at
if ($dropboxLog->parent_id) {
$latestLog = $dropboxLog->parent->children()->orderBy('ends_at', 'desc')->first();
$dropboxLog->parent->update([
'final_weight' => optional($latestLog)->final_weight,
'ends_at' => optional($latestLog)->ends_at,
]);
}
});
}

Expand Down
2 changes: 1 addition & 1 deletion public/css/app.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/css/tailwind.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/app.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions public/mix-manifest.json
@@ -1,8 +1,8 @@
{
"/js/app.js": "/js/app.js?id=c2fdc1b79102d0dfd8a0",
"/js/app.js": "/js/app.js?id=9cbc5b35c4f9ba57c0fb",
"/js/alpine.js": "/js/alpine.js?id=eea86eb67d792d022004",
"/css/app.css": "/css/app.css?id=23bf7dc849d484910f1f",
"/css/tailwind.css": "/css/tailwind.css?id=74ae01682f0fd9617e39",
"/css/app.css": "/css/app.css?id=e7d562d43302aade9de8",
"/css/tailwind.css": "/css/tailwind.css?id=12998ad25a72a5c62dcf",
"/dropboxes/hijau_lubang bulat.jpg": "/dropboxes/hijau_lubang bulat.jpg?id=1269f80703da5b8d1471",
"/dropboxes/hijau_lubang kotak.jpg": "/dropboxes/hijau_lubang kotak.jpg?id=bc1e6364c9576c231556",
"/dropboxes/kuning_lubang bulat.jpg": "/dropboxes/kuning_lubang bulat.jpg?id=33e10edd426427f90080",
Expand Down
4 changes: 4 additions & 0 deletions resources/js/app.js
Expand Up @@ -45,3 +45,7 @@ files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(
const app = new Vue({
el: '#app',
});

$(function() {
$('[data-toggle="tooltip"]').tooltip();
});
2 changes: 1 addition & 1 deletion resources/js/components/Auth/ForgotPassword.vue
Expand Up @@ -3,7 +3,7 @@
<div class="card border-0 shadow my-auto" style="border-radius: 0.5em">
<div class="card-body">
<div class="text-center mb-3">
<img src="/img/logo_navbar.svg" class="w-50" alt="logo_dumask">
<img src="/img/logo_navbar.svg" class="w-md-50" alt="logo_dumask">
</div>
<p class="text-justify text-muted w-100 my-4">
Masukkan alamat email akun Dumask.id Anda.
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/Auth/LoginPage.vue
Expand Up @@ -3,7 +3,7 @@
<div class="card border-0 shadow my-auto" style="border-radius: 0.5em">
<div class="card-body">
<div class="text-center mb-3">
<img src="/img/logo_navbar.svg" class="w-50" alt="logo_dumask">
<img src="/img/logo_navbar.svg" class="w-md-50" alt="logo_dumask">
</div>
<h2 class="text-center font-weight-bold text-primary">
SELAMAT DATANG
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/Auth/RegisterPage.vue
Expand Up @@ -3,7 +3,7 @@
<div class="card border-0 shadow my-auto" style="border-radius: 0.5em">
<div class="card-body">
<div class="text-center mb-3">
<img src="/img/logo_navbar.svg" class="w-50" alt="logo_dumask">
<img src="/img/logo_navbar.svg" class="w-md-50" alt="logo_dumask">
</div>
<div class="flex text-center mb-3">
<h2
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/Auth/ResetPassword.vue
Expand Up @@ -3,7 +3,7 @@
<div class="card border-0 shadow my-auto" style="border-radius: 0.5em">
<div class="card-body">
<div class="text-center mb-3">
<img src="/img/logo_navbar.svg" class="w-50" alt="logo_dumask">
<img src="/img/logo_navbar.svg" class="w-md-50" alt="logo_dumask">
</div>
<div class="flex text-center mb-3">
<h2
Expand Down
31 changes: 19 additions & 12 deletions resources/js/components/DeleteModal.vue
@@ -1,7 +1,7 @@
<template>
<div>
<button
class="btn btn-danger"
:class="btnClass"
data-toggle="modal"
:data-target="'#delete-modal-' + deleteType + '-' + deleteId"
>
Expand Down Expand Up @@ -35,7 +35,7 @@
</div>
<div class="modal-body text-left mx-4">
<div>
Apakah Anda yakin akan menghapus {{ deleteType }} {{ deleteName }}
Apakah Anda yakin akan menghapus {{ deleteType }} {{ deleteName }}. {{ message }}
</div>
<div class="mt-4 text-right">
<button type="button" class="btn btn-primary mx-2 shadow" data-dismiss="modal">TIDAK</button>
Expand All @@ -62,18 +62,17 @@
name: "DeleteModal",
props: {
deleteUrl: {
deleteUrl: String,
deleteType: String,
deleteName: String,
deleteId: String,
redirectTo: String,
shouldReload: Boolean,
btnClass: {
type: String,
default: "btn btn-danger"
},
deleteType: {
type: String,
},
deleteName: {
type: String
},
deleteId: {
type: String
}
message: String
},
data() {
Expand All @@ -92,6 +91,14 @@
this.$emit('deleted')
$('.modal').modal('hide')
alert('deleted')
if (this.shouldReload) {
return window.location.reload()
}
if (this.redirectTo) {
return window.location = this.redirectTo
}
} catch (error) {
alert(error.response.data.message)
}
Expand Down
33 changes: 24 additions & 9 deletions resources/js/components/Dropbox/DropboxCreateModal.vue
@@ -1,11 +1,11 @@
<template>
<div>
<button
class="btn btn-primary"
class="btn btn-primary shadow"
data-toggle="modal"
data-target="#create-dropbox-modal-id"
>
Create new Dropbox
TAMBAH DROPBOX
</button>
<div
class="modal fade"
Expand All @@ -21,8 +21,9 @@
<h5
class="modal-title font-weight-bold text-muted"
id="modal-title"
style="text-transform: capitalize;"
>
Create New Dropbox for {{ station.name }}
TAMBAH DROPBOX
</h5>
<button
type="button"
Expand All @@ -33,8 +34,7 @@
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body mx-4">

<div class="modal-body text-left mx-4">
<div class="form-group" >
<label for="color">Color</label>
<select
Expand Down Expand Up @@ -80,15 +80,22 @@
</div>

<div class="form-group mt-4 text-right">
<button
style="background: #A7A7A7"
class="btn text-white shadow mx-2"
@click="doReset()"
>
RESET
</button>
<button
class="btn btn-success"
class="btn btn-primary shadow"
v-show="!isLoading"
@click="doSubmit()"
>
Create Dropbox
SAVE
</button>
<button class="btn btn-success" disabled v-show="isLoading">
Creating...
<button class="btn btn-primary" disabled v-show="isLoading">
SAVING...
</button>
</div>
</div>
Expand Down Expand Up @@ -155,6 +162,14 @@ export default {
return "";
},
doReset() {
this.form = {
station_id: this.station.id,
color: null,
model: null,
}
}
},
};
</script>
Expand Down
61 changes: 25 additions & 36 deletions resources/js/components/Dropbox/DropboxDeleteModal.vue
Expand Up @@ -5,7 +5,7 @@
data-toggle="modal"
:data-target="'#delete-dropbox-modal-' + dropbox.id"
>
Delete Dropbox
<span class="mdi mdi-delete"></span>
</button>
<div
class="modal fade"
Expand All @@ -18,49 +18,38 @@
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header mx-4">
<h5
<h5
class="modal-title font-weight-bold text-muted"
id="modal-title"
>
Delete Dropbox
</h5>
<button
type="button"
class="close"
data-dismiss="modal"
aria-label="Close"
>
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body mx-4">
<h6>
Are you sure?
</h6>
<div class="form-group mt-4 text-right">
<button
class="btn btn-danger"
v-show="!isLoading"
@click="doDelete()"
style="text-transform: uppercase"
>
Delete
</button>
HAPUS DROPBOX
</h5>
<button
type="button"
class="btn"
class="close"
data-dismiss="modal"
v-show="!isLoading"
aria-label="Close"
>
Cancel
</button>
<button class="btn btn-danger" disabled v-show="isLoading">
Deleting...
</button>
<button class="btn" disabled v-show="isLoading">
Cancel
<span aria-hidden="true">&times;</span>
</button>
</div>
</div>
<div class="modal-body text-left mx-4">
<div>
Apakah Anda yakin akan menghapus dropbox <b>{{ dropbox.color }}-{{ dropbox.model }}</b>?
</div>
<div class="mt-4 text-right">
<button type="button" class="btn btn-primary mx-2 shadow" data-dismiss="modal">TIDAK</button>
<button
class="btn btn-secondary shadow"
v-show="!isLoading"
@click="doDelete()"
>
YA
</button>
<button class="btn btn-secondary" disabled v-show="isLoading">
YA
</button>
</div>
</div>
</div>
</div>
Expand Down

0 comments on commit a3c0c84

Please sign in to comment.