From 5f8ef6c1994dbd21be9414cda783912e74ca429d Mon Sep 17 00:00:00 2001 From: arieeefajar Date: Mon, 28 Apr 2025 15:31:45 +0700 Subject: [PATCH 1/2] fix(master-rule): fix table rule --- app/Http/Controllers/MasterData/RuleController.php | 2 -- resources/views/master-data/aturan/index.blade.php | 12 +++++------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/app/Http/Controllers/MasterData/RuleController.php b/app/Http/Controllers/MasterData/RuleController.php index 458315b..4dd7f40 100644 --- a/app/Http/Controllers/MasterData/RuleController.php +++ b/app/Http/Controllers/MasterData/RuleController.php @@ -13,8 +13,6 @@ class RuleController extends Controller public function index() { $indicators = Indicator::with('rules')->get(); - // $indicators = Indicator::select('id', 'name')->get(); - // dd($indicators); return view('master-data.aturan.index', compact('indicators')); } diff --git a/resources/views/master-data/aturan/index.blade.php b/resources/views/master-data/aturan/index.blade.php index 028838e..b488650 100644 --- a/resources/views/master-data/aturan/index.blade.php +++ b/resources/views/master-data/aturan/index.blade.php @@ -140,17 +140,15 @@ class="fw-medium link-primary">#VZ2101 Action + @php + $no = 1; // Mulai dari 1, counter global + @endphp @foreach ($indicators as $indicator) @foreach ($indicator->rules as $index => $rule) - @if ($index === 0) - - {{ $loop->iteration }} - - {{ $indicator->name }} - @endif + {{ $no++ }} + {{ $indicator->name }} #VZ2101 From 63af6bb1d7ff0682685ce1dc71f88a0d825f979e Mon Sep 17 00:00:00 2001 From: arieeefajar Date: Mon, 28 Apr 2025 19:00:06 +0700 Subject: [PATCH 2/2] fix(master-rule): crud function --- .../Controllers/MasterData/RuleController.php | 2 +- .../customJs/master-data/aturan/index.js | 38 ++- .../views/master-data/aturan/index.blade.php | 233 ++++++++---------- 3 files changed, 122 insertions(+), 151 deletions(-) diff --git a/app/Http/Controllers/MasterData/RuleController.php b/app/Http/Controllers/MasterData/RuleController.php index 4dd7f40..694e11c 100644 --- a/app/Http/Controllers/MasterData/RuleController.php +++ b/app/Http/Controllers/MasterData/RuleController.php @@ -12,7 +12,7 @@ class RuleController extends Controller { public function index() { - $indicators = Indicator::with('rules')->get(); + $indicators = Indicator::with('rules')->orderBy('created_at', 'desc')->get(); return view('master-data.aturan.index', compact('indicators')); } diff --git a/public/assets/js/pages/customJs/master-data/aturan/index.js b/public/assets/js/pages/customJs/master-data/aturan/index.js index d6047f7..5497be1 100644 --- a/public/assets/js/pages/customJs/master-data/aturan/index.js +++ b/public/assets/js/pages/customJs/master-data/aturan/index.js @@ -1,11 +1,21 @@ +document.addEventListener("DOMContentLoaded", function () { + const indicatorField = document.getElementById("indicator-field"); + const indicatorVal = new Choices(indicatorField); + const indicatorEditField = document.getElementById("indicator-edit-field"); + window.indicatorEditVal = new Choices(indicatorEditField); +}); + function updateData(rule) { var form = document.getElementById("edit-form"); - var indicatorType = form.querySelector("#indicator-type-edit-field"); + var categoryEditField = form.querySelector("#category-edit-field"); var description = form.querySelector("#description-edit-field"); var cf = form.querySelector("#cf-edit-field"); form.action = "/data-aturan/" + rule.id; - indicatorType.value = rule.parameter_type; + window.indicatorEditVal.setChoiceByValue(rule.indicator_id.toString()); + window.indicatorEditVal.passedElement.element.value = + rule.indicator_id.toString(); + categoryEditField.value = rule.parameter_type; description.value = rule.description; cf.value = rule.cf; } @@ -61,7 +71,7 @@ function validateCfInput(input) { var perPage = 10, options = { - valueNames: ["id", "category", "description", "status"], + valueNames: ["id", "indicator", "category", "description", "status"], page: perPage, pagination: !0, plugins: [ListPagination({ left: 2, right: 2 })], @@ -165,11 +175,11 @@ refreshCallbacks(), (document .getElementById("showModal") .querySelector(".modal-footer").style.display = "block"), - // (document.getElementById("add-btn").style.display = "none"), + (document.getElementById("add-btn").style.display = "none"), (document.getElementById("edit-btn").style.display = "block")) : e.relatedTarget.classList.contains("add-btn") ? ((document.getElementById("exampleModalLabel").innerHTML = - "Add Customer"), + "Tambah Aturan"), (document .getElementById("showModal") .querySelector(".modal-footer").style.display = "block"), @@ -184,7 +194,9 @@ refreshCallbacks(), ischeckboxcheck(), document .getElementById("showModal") - .addEventListener("hidden.bs.modal", function () {}), + .addEventListener("hidden.bs.modal", function () { + clearFields(); + }), document .querySelector("#customerList") .addEventListener("click", function () { @@ -236,7 +248,7 @@ editBtn.addEventListener("click", function (e) { document.getElementById("close-modal").click(), clearFields(); }); -// var statusVal = new Choices(statusField); +var statusVal = new Choices(statusField); function isStatus(e) { switch (e) { case "Active": @@ -317,12 +329,12 @@ function refreshCallbacks() { }); }); } -// function clearFields() { -// (customerNameField.value = ""), -// (emailField.value = ""), -// (dateField.value = ""), -// (phoneField.value = ""); -// } +function clearFields() { + (customerNameField.value = ""), + (emailField.value = ""), + (dateField.value = ""), + (phoneField.value = ""); +} document .querySelector(".pagination-next") .addEventListener("click", function () { diff --git a/resources/views/master-data/aturan/index.blade.php b/resources/views/master-data/aturan/index.blade.php index b488650..3d5d27f 100644 --- a/resources/views/master-data/aturan/index.blade.php +++ b/resources/views/master-data/aturan/index.blade.php @@ -13,115 +13,29 @@ -
-
-
- -
-
-
- - {{-- @foreach ($rules as $rule) -
-
-
-
-

Indikator {{ $rule->name }}

-
- -
-
-
-
-
- -
-
-
- -
- - - - - - - - - - - - @foreach ($rule->rules as $item) - - - - - - - - - @endforeach - -
NoJenis ParameterDeskirpsi - CF(e) - Action
{{ $loop->iteration }}{{ $item->parameter_type }}{{ $item->description }}{{ $item->cf }} -
-
- -
-
- -
-
-
- - -
-
-
-
-
-
- @endforeach --}} -
-
+
-

Data Rule

+

Data Aturan

+
+
+ +
+
+
@@ -129,46 +43,57 @@ class="fw-medium link-primary">#VZ2101
- +
- - + + - + @php - $no = 1; // Mulai dari 1, counter global + $no = 1; @endphp @foreach ($indicators as $indicator) @foreach ($indicator->rules as $index => $rule) - - + - + + - + @@ -177,19 +102,45 @@ class="fw-medium link-primary">#VZ2101 @endforeach
NoIndikatorNo + Indikator + Kategori DeskripsiCF(e) + CF(e) + Action
{{ $no++ }}{{ $indicator->name }} + {{ $no++ }} + - {{ $rule->parameter_type }} - {{ $indicator->name }}{{ $rule->parameter_type }} {{ $rule->description }}{{ $rule->cf }} + {{ $rule->cf }} +
+ data-bs-toggle="modal" data-bs-target="#editModal" + onclick="updateData({{ $rule }})"> + Edit +
+ data-bs-target="#deleteRecordModal" + onclick="deleteData({{ $rule->id }})"> + Hapus +
+ +
+ +
+
+
+
+ {{-- add modal --}} -