Arreglando UI-delete de Tariba Acabado

This commit is contained in:
imnavajas
2023-07-17 22:30:27 +02:00
parent 6e0493a287
commit 511c73cc0c
5 changed files with 62 additions and 125 deletions

View File

@ -114,7 +114,7 @@ class Tarifaacabado extends \App\Controllers\GoBaseResourceController
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
return redirect()->to(route_to('tarifas/tarifaacabado/edit/' . $id))->with('sweet-success', $message);
return redirect()->to(site_url('tarifas/tarifaacabado/edit/' . $id))->with('sweet-success', $message);
//return redirect()->to(route_to($this->indexRoute))->with('sweet-success', $message);
else:
return $this->redirect2listView('sweet-success', $message);

View File

@ -1,33 +1,14 @@
<?php
// Open-Source License Information:
/*
The MIT License (MIT)
$errorMessage = $errorMessage ?? session('errorMessage');
$warningMessage = session('warningMessage');
Copyright (c) 2020 Ozar (https://www.ozar.net/)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
$errorMessage = $errorMessage ?? session('errorMessage');
$warningMessage = session('warningMessage');
if (session()->has('message')) {
$successMessage = session('message');
}
if (session()->has('error')) {
$errorMessage = is_array(session('error')) ? implode(session('error')) : session('error');
} /* // Uncomment this block if you want the errors listed line by line in the alert
if (session()->has('message')) {
$successMessage = session('message');
}
if (session()->has('error')) {
$errorMessage = is_array(session('error')) ? implode(session('error')) : session('error');
} /* // Uncomment this block if you want the errors listed line by line in the alert
elseif (session()->has('errors')) {
$errorMessage = '<ul class="text-start">';
foreach (session('errors') as $error) :
@ -39,43 +20,56 @@
?>
<?php if (isset($successMessage) && $successMessage): ?>
<div class="alert alert-success" role="alert">
<svg class="bi mt-1 me-3 float-start" width="24" height="24" role="img" aria-label="Success:"><use xlink:href="#check-circle-fill"/></svg>
<button type="button" class="btn-close float-end" data-bs-dismiss="alert" aria-label="Close"></button>
<div>
<h4><?=lang('Basic.global.Success')?>!</h4>
<?= $successMessage; ?>
<div class="alert alert-success alert-dismissible d-flex align-items-baseline" role="alert">
<span class="alert-icon alert-icon-lg text-primary me-2">
<i class="ti ti-check ti-sm"></i>
</span>
<div class="d-flex flex-column ps-1">
<h5 class="alert-heading mb-2"><?= lang('Basic.global.Success') ?></h5>
<p class="mb-0"><?= $successMessage; ?></p>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close">
</button>
</div>
</div>
<?php endif; ?>
<?php if (isset($errorMessage) && $errorMessage): ?>
<div class="alert alert-danger" role="alert">
<svg class="bi mt-1 me-3 float-start" width="24" height="24" role="img" aria-label="Error:"><use xlink:href="#exclamation-triangle-fill"/></svg>
<button type="button" class="btn-close float-end" data-bs-dismiss="alert" aria-label="Close"></button>
<div>
<h4><?=lang('Basic.global.Error')?>!</h4>
<?= $errorMessage; ?>
<div class="alert alert-danger alert-dismissible d-flex align-items-baseline" role="alert">
<span class="alert-icon alert-icon-lg text-primary me-2">
<i class="ti ti-ban ti-sm"></i>
</span>
<div class="d-flex flex-column ps-1">
<h5 class="alert-heading mb-2"><?= lang('Basic.global.Error') ?></h5>
<p class="mb-0"><?= $errorMessage; ?></p>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close">
</button>
</div>
</div>
<?php endif; ?>
<?php if (isset($warningMessage) && $warningMessage): ?>
<div class="alert alert-warning" role="alert">
<svg class="bi mt-1 me-3 float-start" width="24" height="24" role="img" aria-label="Error:"><use xlink:href="#exclamation-triangle-fill"/></svg>
<button type="button" class="btn-close float-end" data-bs-dismiss="alert" aria-label="Close"></button>
<div>
<h4 class="text-start"><?=lang('Basic.global.Warning')?></h4>
<?= $warningMessage ?>
<div class="alert alert-warning alert-dismissible d-flex align-items-baseline" role="alert">
<span class="alert-icon alert-icon-lg text-primary me-2">
<i class="ti ti-bell ti-sm"></i>
</span>
<div class="d-flex flex-column ps-1">
<h5 class="alert-heading mb-2"><?= lang('Basic.global.Warning') ?></h5>
<p class="mb-0"><?= $warningMessage; ?></p>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close">
</button>
</div>
</div>
<?php endif; ?>
<?php endif; ?>
<div id="imn-alert" class="alert alert-warning alert-dismissible d-flex d-none align-items-baseline" role="alert">
<span class="alert-icon alert-icon-lg text-primary me-2">
<i class="ti ti-check ti-sm"></i>
</span>
<div class="d-flex flex-column ps-1">
<h5 class="alert-heading mb-2"><?= lang('Basic.global.Warning') ?></h5>
<p class="mb-0"><?= $warningMessage; ?></p>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close">
</button>
</div>
</div>

View File

@ -11,30 +11,9 @@
<?= lang('Basic.global.deleteConfirmationQuestion') ?>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-bs-dismiss="modal"><?= lang('Basic.global.deleteConfirmationCancel') ?></button>
<a class="btn btn-danger btn-confirm"><?= lang('Basic.global.deleteConfirmationButton') ?></a>
</div><!--//.modal-footer -->
</div><!--//.modal-content -->
</div><!--//.modal-dialog -->
</div><!--//.modal -->
<?php
} else { ?>
<div id="confirm2delete" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="confirm2deleteLabel"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="confirm2deleteLabel"><?= lang('Basic.global.deleteConfirmation') ?></h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<?= lang('Basic.global.deleteConfirmationQuestion') ?>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><?= lang('Basic.global.deleteConfirmationCancel') ?></button>
<a class="btn btn-danger btn-confirm">><?= lang('Basic.global.deleteConfirmationButton') ?></a>
<button type="button" class="btn btn-default"
data-bs-dismiss="modal"><?= lang('Basic.global.deleteConfirmationCancel') ?></button>
<a class="btn btn-danger btn-confirm btn-remove"><?= lang('Basic.global.deleteConfirmationButton') ?></a>
</div><!--//.modal-footer -->
</div><!--//.modal-content -->
</div><!--//.modal-dialog -->

View File

@ -1,5 +1,6 @@
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
<?php //$this->include('themes/_commonPartialsBs/sweetalert') ?>
<?php $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
<?php $this->include('themes/_commonPartialsBs/sweetalert') ?>
<?= $this->extend('themes/backend/vuexy/main/defaultlayout') ?>
<?= $this->section('content'); ?>
<div class="row">
@ -32,49 +33,18 @@
</div><!--//.col -->
</div><!--//.row -->
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close">
</button>
</div>
<div class="modal-body">
<p>Croissant jelly beans donut apple pie. Caramels bonbon lemon drops. Sesame snaps lemon drops lemon drops liquorice icing bonbon pastry pastry carrot cake. Dragée sweet sweet roll sugar plum.</p>
<p>Jelly-o cookie jelly gummies pudding cheesecake lollipop macaroon. Sweet chocolate bar sweet roll carrot cake. Sweet roll sesame snaps fruitcake brownie bear claw toffee bonbon brownie.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary btn-imn" data-bs-dismiss="modal">Borrar</button>
</div>
</div>
</div>
</div>
<?= $this->endSection() ?>
<?= $this->section('additionalInlineJs') ?>
const lastColNr = $('#tableOfTarifasacabado').find("tr:first th").length - 1;
const lastColNr = $('#tableOfTarifasacabado').find("tr:first th").length - 1;
const actionBtns = function(data) {
return `
<td class="text-right py-0 align-middle">
<div class="btn-group btn-group-sm">
<!-- <a href="--><?php //= site_url('/tarifas/tarifaacabado/edit/') ?><!--${data.id}" class="text-body" data-id="${data.id}">-->
<!-- <i class="ti ti-pencil ti-sm mx-2"></i>-->
<!-- </a>-->
<!-- <a class="text-body" data-href="${data.id}" data-bs-toggle="modal" data-bs-target="#exampleModal">-->
<!-- <i class="ti ti-trash ti-sm mx-2"></i>-->
<!-- </a>-->
<i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i>
<i class="ti ti-trash ti-sm btn-del mx-2" data-id="${data.id}" data-bs-toggle="modal" data-bs-target="#exampleModal"></i>
<!-- <i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}"></i>-->
<i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}" data-bs-toggle="modal" data-bs-target="#confirm2delete"></i>
</div>
</td>`;
};
@ -124,11 +94,11 @@
window.location.href = `/tarifas/tarifaacabado/edit/${$(this).attr('data-id')}`;
});
$(document).on('click', '.btn-del', function(e) {
$(".btn-imn").attr('data-id', $(this).attr('data-id'));
$(document).on('click', '.btn-delete', function(e) {
$(".btn-remove").attr('data-id', $(this).attr('data-id'));
});
$(document).on('click', '.btn-imn', function(e) {
$(document).on('click', '.btn-remove', function(e) {
const dataId = $(this).attr('data-id');
const row = $(this).closest('tr');
if ($.isNumeric(dataId)) {
@ -136,6 +106,7 @@
url: `/tarifas/tarifaacabado/delete/${dataId}`,
method: 'GET',
}).done((data, textStatus, jqXHR) => {
$('#confirm2delete').modal('toggle'),
Toast.fire({
icon: 'success',
title: data.msg ?? jqXHR.statusText,
@ -152,7 +123,9 @@
}
});
$('#imn-alert').on('click', function (e) {
$(this).toggleClass('d-none');
});
<?= $this->endSection() ?>

View File

@ -15,17 +15,8 @@
<table id="tableOfTarifaspreimpresion" class="table table-striped table-hover using-exportable-data-table" style="width: 100%;">
<thead>
<tr>
<?php /*
<th><?= lang('Tarifapreimpresion.id') ?></th>
*/ ?>
<th><?= lang('Tarifapreimpresion.nombre') ?></th>
<th><?= lang('Tarifapreimpresion.precio') ?></th>
<?php /*
<th><?= lang('Tarifapreimpresion.userCreatedId') ?></th>
<th><?= lang('Tarifapreimpresion.userUpdateId') ?></th>
<th><?= lang('Tarifapreimpresion.createdAt') ?></th>
<th><?= lang('Tarifapreimpresion.updatedAt') ?></th>
*/ ?>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
</tr>
</thead>