Commit 00cf7ee2 authored by Thidaporn Laisan's avatar Thidaporn Laisan
Browse files

update edit parameter

parent e0a5c0be
......@@ -9,9 +9,8 @@ use App\Models\TabSpnpage;
class ParameterCreate extends Component
{
public $name, $message, $value, $description, $active = 'Y', $pageCode;
public $name, $message, $value, $description, $active = 'Y', $detail, $pageCode = [];
public $searchByPage = [];
public function mount()
{
......@@ -25,7 +24,8 @@ class ParameterCreate extends Component
'value' => 'required|string|max:50',
'description' => 'required|string|max:100',
'active' => 'required',
'pageCode' => 'required',
'detail' => 'required|string',
'pageCode' => 'required|array|min:1',
]);
ConfParameter::create([
......@@ -35,13 +35,16 @@ class ParameterCreate extends Component
'active' => $this->active,
]);
$pageCodesString = implode(',', $this->pageCode);
TabParameterInfo::create([
'parameterName' => $this->name,
'pageCode' => $this->pageCode,
'pageCode' => $pageCodesString,
'detail' => $this->detail,
]);
$this->reset(['name', 'value', 'description', 'active', 'pageCode']);
$this->emit('showparameterListForm');
$this->reset(['name', 'value', 'description', 'active', 'pageCode', 'detail']);
$this->emit('showparameterListForm');
session()->flash('message', 'Parameter added successfully!');
}
......@@ -49,4 +52,11 @@ class ParameterCreate extends Component
{
return view('livewire.pages.parameter.parameter-create');
}
public function loadPage($page)
{
$this->action = $page;
$this->parameters = ConfParameter::all();
}
}
<?php
namespace App\Http\Livewire\Pages\Patch;
namespace App\Http\Livewire\Pages\Parameter;
use Livewire\Component;
use App\Models\ConfParameter;
use App\Models\TabPatchFile;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
use App\Models\TabParameterInfo;
use App\Models\TabSpnpage;
class PatchEdit extends Component
class ParameterEdit extends Component
{
public $patchId;
public $searchProject = '';
public $selectedBranch , $selectedPatch;
public $selectedProject;
public $projects = [];
public $branches = [];
public $fileChanges = [];
public $startCommit;
public $endCommit;
public $PATCHNAME;
public $PDATE;
public $PHP_VERSION;
public $PLEVEL;
public $PCODE;
public $MAJOR_VERSION;
public $PDESC;
public $Remark;
public $POWNER;
public $PAPPROVEDATE;
public $PTYPE;
public $PATCHCODE;
public $UNINSTALL;
public $PATCHCODE_SERVER;
public $filePathChanges = [];
protected $listeners = [ 'gotoModal'];
public $parameterId;
public $name, $value, $description, $active, $detail, $pageCode = [];
public $searchByPage = [];
protected $rules = [
'name' => 'required|string|max:30',
'value' => 'required|string|max:50',
'description' => 'required|string|max:100',
'active' => 'required',
'detail' => 'required',
'pageCode' => 'required|array|min:1',
];
public function mount($editPid)
{
$this->patchId = $editPid;
$this->loadPatchData();
$parameter = ConfParameter::where('PID', $editPid)->firstOrFail();
$this->parameterId = $parameter->PID;
$this->name = $parameter->name;
$this->value = $parameter->value;
$this->description = $parameter->description;
$this->active = $parameter->active;
$parameterInfo = TabParameterInfo::where('parameterName', $parameter->name)->first();
if ($parameterInfo) {
$this->detail = $parameterInfo->detail;
$this->pageCode = explode(',', $parameterInfo->pageCode);
} else {
$this->detail = '';
$this->pageCode = [];
}
$this->searchByPage = TabSpnpage::select('pagecode', 'pagename')->get()->toArray();
}
public function loadPatchData()
public function updateParameter()
{
$patch = ConfSmartUpdate::findOrFail($this->patchId);
$this->PATCHNAME = $patch->PATCHNAME;
$this->PDATE = $patch->PDATE;
$this->PHP_VERSION = $patch->PHP_VERSION;
$this->PLEVEL = $patch->PLEVEL;
$this->PCODE = $patch->PCODE;
$this->MAJOR_VERSION = $patch->MAJOR_VERSION;
$this->PDESC = $patch->PDESC;
$this->Remark = $patch->Remark;
$this->POWNER = $patch->POWNER;
$this->PAPPROVEDATE = $patch->PAPPROVEDATE;
$this->PTYPE = $patch->PTYPE;
$this->PATCHCODE = $patch->PATCHCODE;
$this->UNINSTALL = $patch->UNINSTALL;
$this->PATCHCODE_SERVER = $patch->PATCHCODE_SERVER;
$filePath = TabPatchFile::where("ptid", $this->patchId)->get()->toArray();
$filePath = $this->buildTree($filePath);
$this->fileChanges = $filePath ;
}
$this->validate();
public function save()
{
$this->validate([
'PATCHNAME' => 'required|string|max:255',
'PDATE' => 'required|date',
'PHP_VERSION' => 'required|integer',
'PLEVEL' => 'required|string|max:255',
'PCODE' => 'required|string|max:255',
'MAJOR_VERSION' => 'required|string|max:255',
'PDESC' => 'required|string|max:255',
'Remark' => 'required|string|max:255',
'POWNER' => 'required|string|max:255',
'PAPPROVEDATE' => 'required|date',
'PTYPE' => 'required|string|max:255',
'PATCHCODE' => 'required|string',
'UNINSTALL' => 'required|string|max:255',
'PATCHCODE_SERVER' => 'required|string',
ConfParameter::where('PID', $this->parameterId)->update([
'name' => $this->name,
'value' => $this->value,
'description' => $this->description,
'active' => $this->active,
]);
$confSmartUpdate = ConfSmartUpdate::findOrFail($this->patchId);
$confSmartUpdate->PATCHNAME = $this->PATCHNAME;
$confSmartUpdate->PDATE = $this->PDATE;
$confSmartUpdate->PHP_VERSION = $this->PHP_VERSION;
$confSmartUpdate->PLEVEL = $this->PLEVEL;
$confSmartUpdate->PCODE = $this->PCODE;
$confSmartUpdate->MAJOR_VERSION = $this->MAJOR_VERSION;
$confSmartUpdate->PDESC = $this->PDESC;
$confSmartUpdate->Remark = $this->Remark;
$confSmartUpdate->POWNER = $this->POWNER;
$confSmartUpdate->PAPPROVEDATE = $this->PAPPROVEDATE;
$confSmartUpdate->PTYPE = $this->PTYPE;
$confSmartUpdate->PATCHCODE = $this->PATCHCODE;
$confSmartUpdate->UNINSTALL = $this->UNINSTALL;
$confSmartUpdate->PATCHCODE_SERVER = $this->PATCHCODE_SERVER;
$confSmartUpdate->save();
if (count($this->filePathChanges) > 0) {
foreach ($this->filePathChanges as $file) {
$filePath = str_replace("IE5DEV.shippingnet", ".", $file);
$filedata = $this->getFileContentFromGit($filePath, $this->endCommit);
$filepath = new TabPatchFile;
$filepath->ptid = $confSmartUpdate->PID;
$filepath->file_name = $filePath;
$filepath->file_data = base64_encode($filedata);
$filepath->save();
}
}
session()->flash('message', 'Patch details and file changes updated successfully.');
}
private function getFileContentFromGit($filePath, $commit)
{
$token = env('GITLAB_API_TOKEN');
$client = new Client([
'base_uri' => 'https://idemo.netbay.co.th/gitlab/api/v4/',
'headers' => [
'Authorization' => "Bearer $token",
'Accept' => 'application/json',
],
'verify' => false,
]);
$pageCodesString = implode(',', $this->pageCode);
try {
$response = $client->get("projects/$this->selectedProject/repository/files/" . urlencode($filePath) . "/raw", [
'query' => ['ref' => $commit]
$parameterInfo = TabParameterInfo::where('parameterName', ConfParameter::where('PID', $this->parameterId)->value('name'))->first();
if ($parameterInfo) {
$parameterInfo->update([
'parameterName' => $this->name, // อัปเดตชื่อด้วย
'pageCode' => $pageCodesString,
'detail' => $this->detail,
]);
} else {
TabParameterInfo::create([
'parameterName' => $this->name,
'pageCode' => $pageCodesString,
'detail' => $this->detail,
]);
$statusCode = $response->getStatusCode();
$content = $response->getBody()->getContents();
if ($statusCode == 200) {
return $content;
} else {
throw new \Exception("Failed to fetch file. Status code: $statusCode");
}
} catch (RequestException $e) {
throw $e;
} catch (\Exception $e) {
throw $e;
}
}
private function buildTree($files)
{
$tree = [];
foreach ($files as $file) {
$filePath = "IE5DEV.shippingnet" . substr($file['file_name'], 1);
$pathParts = explode('/', $filePath);
$current = &$tree;
foreach ($pathParts as $part) {
if (!isset($current[$part])) {
$current[$part] = [];
}
$current = &$current[$part];
}
$current['id'] = $file['fid'];
}
return $tree;
}
public function gotoModal(){
dd("dddd");
session()->flash('message', 'Parameter updated successfully!');
$this->emit('loadPage', 'list');
}
public function render()
{
return view('livewire.pages.patch.patch-edit');
return view('livewire.pages.parameter.parameter-edit');
}
}
}
......@@ -14,8 +14,14 @@ class ParameterIndex extends Component
public $action = 'list';
public $searchBy, $searchByPage, $editPid, $message, $keyword, $perPage = 20, $searchSelected = 'name', $searchSelectedPage = '';
public $selectedParameters = [];
public $deletePid;
protected $listeners = ['deleteItem', 'deleteSelected', 'showparameterListForm'];
protected $listeners = [
'deleteItem',
'deleteSelected',
'showparameterListForm',
'loadPage'
];
public function mount()
{
......@@ -31,7 +37,7 @@ class ParameterIndex extends Component
public function render()
{
$query = ConfParameter::select('conf_parameter.PID', 'conf_parameter.name', 'conf_parameter.value', 'conf_parameter.description', 'conf_parameter.active', 'tab_parameter_info.pageCode')
$query = ConfParameter::select('conf_parameter.PID', 'conf_parameter.name', 'conf_parameter.value', 'conf_parameter.description', 'conf_parameter.active', 'tab_parameter_info.pageCode', 'tab_parameter_info.detail')
->leftJoin('tab_parameter_info', 'conf_parameter.name', '=', 'tab_parameter_info.parameterName');
if ($this->searchSelected && $this->keyword) {
......@@ -68,6 +74,7 @@ class ParameterIndex extends Component
$this->editPid = $pid;
$this->action = 'edit';
}
public function showparameterDeleteForm($pid)
{
......@@ -100,4 +107,20 @@ class ParameterIndex extends Component
$this->selectedParameters = [];
$this->showparameterListForm();
}
public function deleteItem($pid)
{
$this->deleteParameter($pid);
}
public function deleteSelected()
{
$this->deleteSelectedParameters();
}
public function loadPage($page)
{
$this->action = $page;
$this->parameters = ConfParameter::all();
}
}
......@@ -5,6 +5,7 @@
'main-container' => 'App\\Http\\Livewire\\MainContainer',
'navbar' => 'App\\Http\\Livewire\\Navbar',
'pages.parameter.parameter-create' => 'App\\Http\\Livewire\\Pages\\Parameter\\ParameterCreate',
'pages.parameter.parameter-edit' => 'App\\Http\\Livewire\\Pages\\Parameter\\ParameterEdit',
'pages.parameter.parameter-index' => 'App\\Http\\Livewire\\Pages\\Parameter\\ParameterIndex',
'pages.patch.modal-edit-code' => 'App\\Http\\Livewire\\Pages\\Patch\\ModalEditCode',
'pages.patch.patch-create' => 'App\\Http\\Livewire\\Pages\\Patch\\PatchCreate',
......
<div>
<button type="button" wire:click="loadPage('Parameter')"
<button type="button" wire:click="$emit('loadPage', 'list')"
class="btn mx-auto m-3 text-white bg-primary px-3 py-2">Back</button>
<div class="max-w-full mx-auto p-6 bg-gray-100">
......@@ -7,7 +7,7 @@
<div class="p-12 bg-white shadow-md rounded-lg w-1/2">
<h2 class="text-2xl font-bold mb-4">Create Parameter</h2>
<div class="mx-auto p-4">
<div class="mx-auto p-4">
@if (session()->has('message'))
<div class="alert alert-success">
{{ session('message') }}
......@@ -30,13 +30,12 @@
</div>
<div class="mb-4">
<label for="description" class="block text-sm font-medium text-gray-700">Description</label>
<textarea wire:model.defer="description" id="description"
class="w-full mt-1 p-2 border border-gray-300 rounded-md"></textarea>
@error('description') <span class="text-red-500">{{ $message }}</span> @enderror
<label for="description" class="block text-sm font-medium text-gray-700">Description</label>
<textarea wire:model.defer="description" id="description"
class="w-full mt-1 p-2 border border-gray-300 rounded-md"></textarea>
@error('description') <span class="text-red-500">{{ $message }}</span> @enderror
</div>
<div class="mb-4">
<label for="active" class="block text-sm font-medium text-gray-700">Active</label>
<select wire:model.defer="active" id="active"
......@@ -46,22 +45,35 @@
</select>
@error('active') <span class="text-red-500">{{ $message }}</span> @enderror
</div>
<br>
<div class="mb-4">
<label for="detail" class="block text-sm font-medium text-gray-700">More Info</label>
</div>
<div class="mb-4">
<label for="detail" class="block text-sm font-medium text-gray-700">Detail</label>
<textarea wire:model.defer="detail" id="detail"
class="w-full mt-1 p-2 border border-gray-300 rounded-md"></textarea>
@error('detail') <span class="text-red-500">{{ $message }}</span> @enderror
</div>
<div class="mb-4">
<label for="pageCode" class="block text-sm font-medium text-gray-700">Page Code</label>
<select wire:model.defer="pageCode" id="pageCode"
class="w-full mt-1 p-2 border border-gray-300 rounded-md">
<div class="w-full mt-1 p-2 border border-gray-300 rounded-md flex flex-wrap">
@foreach ($searchByPage as $page)
<option value="">Please Select</option>
<option value="{{ $page['pagecode'] }}">{{ $page['pagename'] }}</option>
<div class="w-1/2 mb-2 flex items-center">
<input type="checkbox" wire:model.defer="pageCode" value="{{ $page['pagecode'] }}" id="page_{{ $page['pagecode'] }}"
class="mr-2">
<label for="page_{{ $page['pagecode'] }}" class="text-gray-700">{{ $page['pagename'] }}</label>
</div>
@endforeach
</select>
</div>
@error('pageCode') <span class="text-red-500">{{ $message }}</span> @enderror
</div>
<div class="flex items-center justify-end">
<div class="flex items-center justify-center">
<button type="submit"
class="ml-3 inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
class="bg-primary inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
Save
</button>
</div>
......
<div>
<button type="button" wire:click="$emit('loadPage', 'list')"
class="btn mx-auto m-3 text-white bg-primary px-3 py-2">Back</button>
<div class="max-w-full mx-auto p-6 bg-gray-100">
<div class="flex flex-wrap -mx-3">
<div class="w-full md:w-1/2 px-3 mb-6">
<div x-data="{
searchQuery: 'SPN64Bits',
selectedBranch: @entangle('selectedBranch'),
selectedProject: @entangle('selectedProject'),
projects: @entangle('projects').defer,
branches: @entangle('branches').defer,
fileChanges: @entangle('fileChanges').defer,
isLoading: false,
fetchProjects() {
this.isLoading = true;
this.selectedProject = '60';
this.$wire.set('searchProject', this.searchQuery);
},
fetchBranches() {
if (this.selectedProject) {
this.$wire.set('selectedProject', this.selectedProject);
}
}
}" @projects-fetched.window="isLoading = false"
@files-fetched.window="isLoading = false" x-init="fetchProjects"
class="p-6 bg-white shadow-md rounded-lg">
<div class="w-full px-6 mb-12 flex justify-center">
<div class="p-12 bg-white shadow-md rounded-lg w-1/2">
<h2 class="text-2xl font-bold mb-4">Edit Parameter</h2>
<div class="mx-auto p-4">
@if (session()->has('message'))
<div class="alert alert-success">
{{ session('message') }}
</div>
@endif
<div class="">
<div class="flex mb-3">
<label for="searchProject" class="form-label text-lg mr-2">Search Project:</label>
<input type="text" @input.debounce.500ms="fetchProjects"
class="form-input h-8 ml-2 rounded-lg border border-slate-300 bg-transparent px-3 py-2 placeholder:text-slate-400/70 hover:border-slate-400 focus:border-primary dark:border-navy-450 dark:hover:border-navy-400 dark:focus:border-accent"
id="searchProject" placeholder="Enter project name" x-model="searchQuery">
</div>
</div>
<form wire:submit.prevent="updateParameter">
<div class="mb-4">
<label for="name" class="block text-sm font-medium text-gray-700">Name</label>
<input type="text" wire:model.defer="name" id="name"
class="w-full mt-1 p-2 border border-gray-300 rounded-md">
@error('name') <span class="text-red-500">{{ $message }}</span> @enderror
</div>
<div x-show="true" class="">
<div class="flex mb-3">
<label for="project" class="form-label text-lg mr-2">Select Project:</label>
<div x-show="isLoading" class="mx-auto mt-2">
<span>Loading...</span>
</div>
<select x-model="selectedProject" x-show="!isLoading" @change="fetchBranches" id="project"
class="ml-2 w-64 h-8 mt-1 border border-gray-300 rounded-md">
<option value="">Choose Project</option>
<template x-for="project in projects" :key="project.id">
<option :value="project.id" x-text="project.name"></option>
</template>
</select>
</div>
</div>
<div class="mb-4">
<label for="value" class="block text-sm font-medium text-gray-700">Value</label>
<input type="text" wire:model.defer="value" id="value"
class="w-full mt-1 p-2 border border-gray-300 rounded-md">
@error('value') <span class="text-red-500">{{ $message }}</span> @enderror
</div>
<div class="mb-3">
<input type="text" wire:model.defer="startCommit" placeholder="Start Commit"
class="placeholder:text-sm text-lg mb-2 form-input rounded-lg border border-slate-300 px-2">
<input type="text" wire:model.defer="endCommit" placeholder="End Commit"
class="placeholder:text-sm text-lg mb-2 form-input rounded-lg border border-slate-300 px-2">
<div class="text-center">
<button type="button" wire:click="getChangedFiles"
class="btn mx-auto mt-3 text-white bg-stone-700 px-3 py-2">Get Changed Files</button>
</div>
</div>
<div wire:loading.class="flex" wire:loading.class.remove="hidden"
class="flex inset-0 items-center justify-center z-50 bg-slate-50 dark:bg-navy-900 hidden">
<div class="app-preloader grid h-full w-full place-content-center">
<div class="app-preloader-inner relative inline-block h-48 w-48"></div>
</div>
</div>
<div class="mb-4">
<label for="description" class="block text-sm font-medium text-gray-700">Description</label>
<textarea wire:model.defer="description" id="description"
class="w-full mt-1 p-2 border border-gray-300 rounded-md"></textarea>
@error('description') <span class="text-red-500">{{ $message }}</span> @enderror
</div>
<div class="mt-5 bg-gray-100 p-4 rounded-lg shadow">
<h3 class="text-lg mb-3">Changed Files</h3>
<div class="file-tree">
<ul class='pl-4 mt-1'>
@foreach ($fileChanges as $name => $item)
@include('livewire.pages.patch.tree-item', [
'name' => $name,
'item' => $item,
])
@endforeach
</ul>
</div>
</div>
<div class="mb-4">
<label for="active" class="block text-sm font-medium text-gray-700">Active</label>
<select wire:model.defer="active" id="active"
class="w-full mt-1 p-2 border border-gray-300 rounded-md">
<option value="Y">Yes</option>
<option value="N">No</option>
</select>
@error('active') <span class="text-red-500">{{ $message }}</span> @enderror
</div>
<div class="mb-4">
<label for="detail" class="block text-sm font-medium text-gray-700">Detail</label>
<textarea wire:model.defer="detail" id="detail"
class="w-full mt-1 p-2 border border-gray-300 rounded-md"></textarea>
@error('detail') <span class="text-red-500">{{ $message }}</span> @enderror
</div>
</div>
<div class="w-full md:w-1/2 px-3 mb-6">
<div class="p-6 bg-white shadow-md rounded-lg">
<h2 class="text-2xl font-bold mb-4">Edit Patch</h2>
<div class="mb-4">
<label for="patch_name" class="block text-gray-700">Patch name</label>
<input type="text" id="patch_name" class="w-full mt-1 p-2 border border-gray-300 rounded-md"
wire:model.defer="PATCHNAME">
</div>
<div class="mb-4">
<label for="patch_date" class="block text-gray-700">Patch date</label>
<input type="datetime-local" id="patch_date"
class="w-full mt-1 p-2 border border-gray-300 rounded-md" wire:model.defer="PDATE">
</div>
<div class="mb-4">
<label for="php_version" class="block text-gray-700">PHP Version</label>
<select id="php_version" wire:model.defer="PHP_VERSION"
class="w-full mt-1 p-2 border border-gray-300 rounded-md">
<option value="0">ALL</option>
<option value="1">32Bits (PHP 5.2)</option>
<option value="2">64Bits (PHP 5.6)</option>
<option value="3">64Bits (PHP 8.0)</option>
</select>
</div>
<div class="mb-4">
<label for="patch_level" class="block text-gray-700">Patch level</label>
<input type="text" id="patch_level" class="w-full mt-1 p-2 border border-gray-300 rounded-md"
wire:model.defer="PLEVEL">
</div>
<div class="mb-4">
<label for="code" class="block text-gray-700">Patch Code</label>
<input type="text" id="code" wire:model.defer="PCODE"
class="w-full mt-1 p-2 border border-gray-300 rounded-md">
</div>
<div class="mb-4">
<label for="major_version" class="block text-gray-700">Major version</label>
<input type="text" id="major_version" class="w-full mt-1 p-2 border border-gray-300 rounded-md"
wire:model.defer="MAJOR_VERSION">
</div>
<div class="mb-4">
<label for="pdesc" class="block text-gray-700">Patch Description</label>
<input type="text" id="pdesc" wire:model.defer="PDESC"
class="w-full mt-1 p-2 border border-gray-300 rounded-md">
</div>
<div class="mb-4">
<label for="remark" class="block text-gray-700">Remark</label>
<input type="text" id="remark" wire:model.defer="Remark"
class="w-full mt-1 p-2 border border-gray-300 rounded-md">
</div>
<div class="mb-4">
<label for="owner" class="block text-gray-700">Owner</label>
<input type="text" id="owner" wire:model.defer="POWNER"
class="w-full mt-1 p-2 border border-gray-300 rounded-md" value="aom">
</div>
<div class="mb-4">
<label for="papprovedate" class="block text-gray-700">Papprovedate</label>
<input type="datetime-local" id="papprovedate" wire:model.defer="PAPPROVEDATE"
class="w-full mt-1 p-2 border border-gray-300 rounded-md" value="2024-03-27T15:00">
</div>
<div class="mb-4">
<label for="ptype" class="block text-gray-700">Ptype</label>
<input type="text" id="ptype" wire:model.defer="PTYPE"
class="w-full mt-1 p-2 border border-gray-300 rounded-md">
</div>
<div class="mb-4">
<label for="specific_customer" class="block text-gray-700">Specific Customer</label>
<input type="text" id="specific_customer"
class="w-full mt-1 p-2 border border-gray-300 rounded-md">
</div>
<div class="mb-4">
<label for="patchcode" class="block text-gray-700">Patchcode</label>
<textarea id="patchcode" wire:model.defer="PATCHCODE" class="w-full mt-1 p-2 border border-gray-300 rounded-md"
rows="5">pathcode</textarea>
</div>
<div class="mb-4">
<label for="uninstall" class="block text-gray-700">Uninstall</label>
<input type="text" id="uninstall" wire:model.defer="UNINSTALL"
class="w-full mt-1 p-2 border border-gray-300 rounded-md" value="$b=1">
</div>
<div class="mb-4">
<label for="patchcode_server" class="block text-gray-700">Patchcode_server</label>
<textarea id="patchcode_server" wire:model.defer="PATCHCODE_SERVER"
class="w-full mt-1 p-2 border border-gray-300 rounded-md" rows="5"></textarea>
</div>
<div class="flex justify-center">
<button type="button" wire:click="save"
class="bg-stone-700 text-white px-4 py-2 rounded-md hover:bg-blue-600">Save</button>
<div class="mb-4">
<label for="pageCode" class="block text-sm font-medium text-gray-700">Page Code</label>
<div class="w-full mt-1 p-2 border border-gray-300 rounded-md flex flex-wrap">
@foreach ($searchByPage as $page)
<div class="w-1/2 mb-2 flex items-center">
<input type="checkbox" wire:model.defer="pageCode" value="{{ $page['pagecode'] }}" id="page_{{ $page['pagecode'] }}"
class="mr-2">
<label for="page_{{ $page['pagecode'] }}" class="text-gray-700">{{ $page['pagename'] }}</label>
</div>
@endforeach
</div>
@error('pageCode') <span class="text-red-500">{{ $message }}</span> @enderror
</div>
<div class="flex items-center justify-center">
<button type="submit"
class="bg-primary inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
Save
</button>
</div>
</form>
</div>
</div>
</div>
<livewire:pages.patch.modal-edit-code>
</div>
......@@ -31,8 +31,8 @@
<div class="px-2 ml-4">
<button type="button" class="py-2 px-3 bg-stone-700 rounded-lg text-white"
wire:click="showparameterAddForm">Add</button>
<button type="button" class="py-2 px-3 bg-stone-700 rounded-lg text-white"
wire:click="deleteSelectedParameters">Delete</button>
<button type="button" class="py-2 px-3 bg-stone-700 rounded-lg text-white"
onclick="confirmDeleteSelected()">Delete</button>
</div>
<div class="inline-flex flex-initial">
<div x-data="{ isInputActive: true }">
......@@ -125,8 +125,12 @@
<td class="whitespace-nowrap px-1 py-3 sm:px-2">
{{ \Illuminate\Support\Str::limit($para->name, 40) }}</td>
<td class="whitespace-nowrap px-1 py-3 sm:px-2">{{ $para->value }}</td>
<td class="whitespace-nowrap px-1 py-3 sm:px-2">{{ $para->description }}</td>
<td class="whitespace-nowrap px-1 py-3 sm:px-2">{{ $para->pageCode }}</td>
<td class="whitespace-nowrap px-1 py-3 sm:px-2" title="{{ $para->description }}">
{{ \Illuminate\Support\Str::limit($para->description, 40) }}
</td>
<td class="whitespace-nowrap px-1 py-3 sm:px-2" title="{{ $para->pageCode }}">
{{ \Illuminate\Support\Str::limit($para->pageCode, 40) }}
</td>
<td class="whitespace-nowrap px-1 py-3 sm:px-2">{{ $para->active }}</td>
<td class="whitespace-nowrap px-1 py-3 sm:px-2">
<div class="flex justify-center space-x-2">
......@@ -134,7 +138,7 @@
class="btn h-8 w-8 p-0 text-info hover:bg-info/20 focus:bg-info/20 active:bg-info/25">
<i class="fa fa-edit"></i>
</a>
<a wire:click="deleteParameter({{ $para->PID }})"
<a onclick="confirmDelete({{ $para->PID }})"
class="btn h-8 w-8 p-0 text-danger hover:bg-danger/20 focus:bg-danger/20 active:bg-danger/25">
<i class="fa fa-trash"></i>
</a>
......@@ -153,8 +157,24 @@
@elseif($action === 'add')
<livewire:pages.parameter.parameter-create />
@elseif($action === 'edit')
<livewire:pages.parameter.parameter-edit :editPid="$editPid" />
@livewire('pages.parameter.parameter-edit', ['editPid' => $editPid])
@endif
</main>
</div>
<script>
function confirmDelete(pid) {
if (confirm("Are you sure you want to delete this parameter?")) {
Livewire.emit('deleteItem', pid);
}
}
function confirmDeleteSelected() {
if (confirm("Are you sure you want to delete the selected parameters?")) {
Livewire.emit('deleteSelected');
}
}
</script>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment