fixes: pagination & users permissions

This commit is contained in:
Alexandro Uc Santos
2024-03-13 21:39:26 -06:00
parent cbd076e887
commit c286da773e
18 changed files with 92 additions and 63 deletions

View File

@@ -151,6 +151,7 @@
</div>
<div class="btn-row" v-if="!readOnly && authStore.user?.permissions === 'role_shipper'">
<button
v-if="authStore.user?.job_role === 'owner' || authStore.user?.job_role === 'manager'"
class="btn-primary-sm bg-dark"
@click="handleDeleteLoad"
><i class="fa-solid fa-ban clear-sm"></i> Cancelar</button>
@@ -164,6 +165,7 @@
Evidencias
</button>
<button
v-if="authStore.user?.job_role === 'owner' || authStore.user?.job_role === 'manager'"
class="btn-primary-sm"
data-toggle="modal" data-target="#formLoadModal"
@click="openEditModal"

View File

@@ -1,6 +1,7 @@
<script setup>
import Swal from 'sweetalert2';
import { useCompanyStore } from '../stores/company';
import { useAuthStore } from '../stores/auth';
const props = defineProps({
location: {
@@ -12,6 +13,7 @@
defineEmits(['set-location'])
const companyStore = useCompanyStore();
const authStore = useAuthStore();
const handleDeleteLocation = async() => {
Swal.fire({
@@ -70,7 +72,7 @@
{{ location.description }}
</div>
</div>
<div class="card-footer">
<div class="card-footer" v-if="authStore.user?.job_role === 'owner' || authStore.user?.job_role === 'manager'">
<button
class="btn btn-dark radius-sm"
@click="handleDeleteLocation"

View File

@@ -3,6 +3,7 @@
import { getDateMonthDay } from '../helpers/date_formats';
import { getStatusLoad } from '../helpers/status';
import { useCompanyStore } from '../stores/company';
import { useAuthStore } from '../stores/auth';
const props = defineProps({
proposal: {
@@ -12,6 +13,7 @@ import { getDateMonthDay } from '../helpers/date_formats';
})
const companyStore = useCompanyStore();
const authStore = useAuthStore();
const handleWithdrawnProposal = async() => {
@@ -104,7 +106,9 @@ import { getDateMonthDay } from '../helpers/date_formats';
<i class="fa-solid fa-ban"></i>
Retirado
</div>
<button v-else
<button
v-else
v-if="authStore.user?.job_role === 'owner' || authStore.user?.job_role === 'manager'"
type="button"
class="btn btn-danger radius-sm"
@click="handleWithdrawnProposal"
@@ -113,6 +117,7 @@ import { getDateMonthDay } from '../helpers/date_formats';
Retirar
</button>
<button
v-if="authStore.user?.job_role === 'owner' || authStore.user?.job_role === 'manager'"
class="btn-primary-sm radius-sm"
@click="$emit('set-proposal', {proposal: proposal, modal: 'edit'})"
data-toggle="modal" data-target="#makeProposalModal"

View File

@@ -2,6 +2,7 @@
import Swal from 'sweetalert2';
import { getDateMonthDay } from '../helpers/date_formats';
import { useCompanyStore } from '../stores/company';
import { useAuthStore } from '../stores/auth';
const props = defineProps({
user: {
@@ -19,6 +20,7 @@
defineEmits(['set-user'])
const companyStore = useCompanyStore();
const authStore = useAuthStore();
const handleDelete = async() => {
Swal.fire({
@@ -66,7 +68,7 @@
<div class="card-fixed flex-column">
<div class="row">
<div class="col-lg-6 col-sm-12">
<p><span>Nombre de usuario:</span> {{user.name}}</p>
<p><span>Nombre de usuario:</span> {{user.first_name}} {{user.last_name}}</p>
<p v-if="user.employee_id"><span class="font-weight-bold mr-1">Número de registro:</span> {{user.employee_id}}</p>
<p><span>Teléfono 1: </span>{{user.phone}}</p>
<p><span>Teléfono 2: </span>{{user.phone2}}</p>
@@ -93,14 +95,14 @@
<p><span>Rol del usuario: </span>{{user.job_role}}</p>
</div>
</div>
<div class="btn-row" v-if="readonly === false">
<div class="btn-row" v-if="readonly === false && (authStore.user?.job_role === 'owner' || authStore.user?.job_role === 'manager')">
<button
class="btn-primary-sm radius-sm"
data-toggle="modal"
data-target="#userModal"
@click="$emit('set-user')"
><i class="fa-solid fa-pen-to-square"></i> Editar</button>
<button
><i class="fa-solid fa-pen-to-square"></i> Editar</button>
<button
class="btn btn-dark radius-sm"
@click="handleDelete"
><i class="fa-solid fa-trash"></i> Eliminar</button>

View File

@@ -2,6 +2,7 @@
import Swal from 'sweetalert2';
import { getDateMonthDayEs } from '../helpers/date_formats';
import { useVehiclesStore } from '../stores/vehicles';
import { useAuthStore } from '../stores/auth';
const props = defineProps({
vehicle: {
@@ -13,6 +14,7 @@
defineEmits(['set-vehicle']);
const vehicleStore = useVehiclesStore();
const authStore = useAuthStore();
const handleDeleteVehicle = async() => {
Swal.fire({
@@ -102,12 +104,14 @@
</div>
<div class="card-footer">
<button
v-if="authStore.user?.job_role === 'owner' || authStore.user?.job_role === 'manager'"
class="btn btn-dark radius-sm"
@click="handleDeleteVehicle"
>
<i class="fa-solid fa-trash" /> <span class="clear-xsm">Eliminar</span>
</button>
<button
v-if="authStore.user?.job_role === 'owner' || authStore.user?.job_role === 'manager'"
class="btn-primary-sm radius-sm"
@click="$emit('set-vehicle', {vehicle: vehicle, modal: 'form'})"
data-toggle="modal"

View File

@@ -94,13 +94,15 @@
job_role: userForm.job_role,
permissions: authStore.user.permissions,
company: authStore.user.company,
categories: userForm.categories.length <= 0 ? null : userForm.categories?.map((e) => e._id),
categories: userForm.categories?.length <= 0 ? null : userForm.categories?.map((e) => e._id),
user_city: userForm.user_city?.length <= 0 ? null : userForm.user_city?.map((e) => e.city_name),
user_state: userForm.user_state?.length <= 0 ? null : userForm.user_state?.map((e) => e.state_name),
truck_type: userForm.truck_type?.length <= 0 ? null : userForm.truck_type?.map((e) => e.meta_value),
user_description: userForm.user_description
}
console.log(userData);
const dataUpdate = {
categories: userForm.categories,
name: userForm.name + ' ' + userForm.last_name
@@ -180,6 +182,8 @@
type="number"
v-model:field="userForm.phone"
:filled="false"
:step="1"
:error="errors.phone"
/>
<CustomInput
@@ -187,6 +191,7 @@
name="phone2"
type="number"
v-model:field="userForm.phone2"
:step="1"
:filled="false"
/>
<CustomInput
@@ -194,6 +199,7 @@
name="email"
type="email"
v-model:field="userForm.email"
:readonly="(props.user) ? true : false"
:filled="false"
:error="errors.email"
/>
@@ -206,8 +212,9 @@
v-model="userForm.job_role"
>
<option disabled value="">-- Seleccionar rol --</option>
<option value="owner">Dueño</option>
<!-- <option value="owner">Dueño</option> -->
<option value="manager">Gerente</option>
<option value="staff">Personal</option>
<option v-if="authStore.user?.permissions === 'role_carrier'" value="driver">Conductor</option>
</select>
</div>

View File

@@ -12,19 +12,20 @@ import { onMounted, ref } from 'vue';
},
currentPage: {
type: Number,
default: 1
default: 0
}
})
const emits = defineEmits(['get-elements'])
const currentPage = ref(1);
const currentPage = ref(0);
const totalPage = ref(0)
onMounted(() => {
currentPage.value = props.currentPage;
totalPage.value = Math.ceil(props.total / props.limit)
})
const setPage = (p) => {
const setPage = (p) => {
console.log('Page:', p);
currentPage.value = p
const skip = (p - 1) * props.limit;
emits('get-elements', {skip: skip, page: p});
@@ -37,8 +38,8 @@ import { onMounted, ref } from 'vue';
<div class="box-pages" v-if="totalPage > 1">
<div
v-for="p in totalPage"
:class="[currentPage === p ? 'page page-active' : 'page']"
@click="setPage(p)"
:class="[currentPage === (p - 1) ? 'page page-active' : 'page']"
@click="setPage(p - 1)"
>
{{ p }}
</div>

View File

@@ -35,6 +35,10 @@
},
error: {
type: String,
},
step: {
type: Number,
default: 0.1
}
})
@@ -52,7 +56,7 @@
:id="name"
:name="name"
:min="0"
:step="0.1"
:step="step"
:value="field"
:disabled="readonly"
:readonly="readonly"