En una cotización, poder mover las líneas de detalle

This commit is contained in:
David Arranz 2025-02-18 12:27:08 +01:00
parent d432fb90d2
commit 1396c70d1f
15 changed files with 266 additions and 241 deletions

View File

@ -1,7 +1,7 @@
{ {
"name": "@uecko-presupuestador/client", "name": "@uecko-presupuestador/client",
"private": true, "private": true,
"version": "1.1.1", "version": "1.1.2",
"author": "Rodax Software <dev@rodax-software.com>", "author": "Rodax Software <dev@rodax-software.com>",
"type": "module", "type": "module",
"scripts": { "scripts": {

View File

@ -351,6 +351,25 @@ export function QuoteItemsSortableDataTable<TData extends RowData & RowIdData, T
</Table> </Table>
{createPortal( {createPortal(
<DragOverlay dropAnimation={dropAnimationConfig} className={"z-40 opacity-100"}>
{activeId && (
<div className='relative flex flex-wrap'>
{table.getSelectedRowModel().rows.length ? (
<Badge
variant='destructive'
className='absolute z-50 flex items-center justify-center w-2 h-2 p-3 rounded-full top left -left-2 -top-2'
>
{table.getSelectedRowModel().rows.length}
</Badge>
) : null}
</div>
)}
</DragOverlay>,
document.body
)}
{false &&
createPortal(
<DragOverlay dropAnimation={dropAnimationConfig} className={"z-40 opacity-100"}> <DragOverlay dropAnimation={dropAnimationConfig} className={"z-40 opacity-100"}>
{activeId && ( {activeId && (
<div className='relative flex flex-wrap'> <div className='relative flex flex-wrap'>

View File

@ -62,7 +62,7 @@ export function QuoteItemsSortableTableRow({
key={id} key={id}
id={String(id)} id={String(id)}
className={cn( className={cn(
isDragging ? "opacity-40" : "opacity-100", isDragging ? "opacity-60" : "opacity-100",
"m-0 hover:bg-muted hover:focus-within:bg-accent focus-within:bg-accent" "m-0 hover:bg-muted hover:focus-within:bg-accent focus-within:bg-accent"
)} )}
ref={setNodeRef} ref={setNodeRef}

View File

@ -177,7 +177,7 @@ export const QuoteDetailsCardEditor = ({
}, },
], ],
{ {
enableDragHandleColumn: false, // <--- Desactivado temporalmente enableDragHandleColumn: true,
enableSelectionColumn: true, enableSelectionColumn: true,
enableActionsColumn: true, enableActionsColumn: true,
rowActionFn: (props) => { rowActionFn: (props) => {

View File

@ -245,7 +245,7 @@ export const QuoteEdit = () => {
}; };
if (isSubmitting || isPending) { if (isSubmitting || isPending) {
return <LoadingOverlay title='Guardando cotización' />; //return <LoadingOverlay title='Guardando cotización' />;
} }
if (status === "error") { if (status === "error") {
@ -257,6 +257,8 @@ export const QuoteEdit = () => {
} }
return ( return (
<>
{(isSubmitting || isPending) && <LoadingOverlay title='Guardando cotización' />}
<Form {...form}> <Form {...form}>
<form onSubmit={handleSubmit((data) => onSubmit(data, false))}> <form onSubmit={handleSubmit((data) => onSubmit(data, false))}>
<div className='mx-auto grid max-w-[90rem] flex-1 auto-rows-max gap-6'> <div className='mx-auto grid max-w-[90rem] flex-1 auto-rows-max gap-6'>
@ -311,7 +313,11 @@ export const QuoteEdit = () => {
{/* <TabsTrigger value='history'>{t("quotes.create.tabs.history")}</TabsTrigger>*/} {/* <TabsTrigger value='history'>{t("quotes.create.tabs.history")}</TabsTrigger>*/}
</TabsList> </TabsList>
<TabsContent value='general' forceMount hidden={"general" !== activeTab}></TabsContent> <TabsContent
value='general'
forceMount
hidden={"general" !== activeTab}
></TabsContent>
<TabsContent value='items' forceMount hidden={"items" !== activeTab}></TabsContent> <TabsContent value='items' forceMount hidden={"items" !== activeTab}></TabsContent>
</Tabs> </Tabs>
@ -324,5 +330,6 @@ export const QuoteEdit = () => {
</div> </div>
</form> </form>
</Form> </Form>
</>
); );
}; };

View File

@ -1,6 +1,7 @@
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { Button } from "@/ui"; import { Button } from "@/ui";
import { useSortable } from "@dnd-kit/sortable"; import { useSortable } from "@dnd-kit/sortable";
import { t } from "i18next";
import { GripVerticalIcon } from "lucide-react"; import { GripVerticalIcon } from "lucide-react";
export interface DataTableRowDragHandleCellProps { export interface DataTableRowDragHandleCellProps {
@ -33,7 +34,7 @@ export const DataTableRowDragHandleCell = ({
{...listeners} {...listeners}
> >
<GripVerticalIcon className='w-4 h-4' /> <GripVerticalIcon className='w-4 h-4' />
<span className='sr-only'>Mover fila</span> <span className='sr-only'>{t("common.move_row")}</span>
</Button> </Button>
); );
}; };

View File

@ -14,7 +14,7 @@ export const LoadingOverlay = ({
return ( return (
<div <div
className={ className={
"fixed top-0 bottom-0 left-0 right-0 z-50 w-full h-screen overflow-hidden flex justify-center" "fixed top-0 bottom-0 left-0 right-0 z-50 w-full h-screen overflow-hidden flex justify-center bg-background/85"
} }
{...props} {...props}
> >

View File

@ -41,6 +41,7 @@
"append_article_tooltip": "Select and add an item from the catalog", "append_article_tooltip": "Select and add an item from the catalog",
"append_block": "Append text block", "append_block": "Append text block",
"append_block_tooltip": "Select and add a text block", "append_block_tooltip": "Select and add a text block",
"move_row": "Move row",
"remove_row": "Remove", "remove_row": "Remove",
"remove_selected_rows": "Remove", "remove_selected_rows": "Remove",
"remove_selected_rows_tooltip": "Remove selected row(s)", "remove_selected_rows_tooltip": "Remove selected row(s)",

View File

@ -41,6 +41,7 @@
"append_article_tooltip": "Elegir un artículo del catálogo y añadirlo", "append_article_tooltip": "Elegir un artículo del catálogo y añadirlo",
"append_block": "Añadir bloque de texto", "append_block": "Añadir bloque de texto",
"append_block_tooltip": "Elegir un bloque de texto y añadirlo", "append_block_tooltip": "Elegir un bloque de texto y añadirlo",
"move_row": "Mover fila",
"remove_row": "Eliminar", "remove_row": "Eliminar",
"remove_selected_rows": "Eliminar", "remove_selected_rows": "Eliminar",
"remove_selected_rows_tooltip": "Elimina las fila(s) seleccionadas(s)", "remove_selected_rows_tooltip": "Elimina las fila(s) seleccionadas(s)",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -8,8 +8,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="https://fonts.upset.dev/css2?family=Poppins&display=swap" rel="stylesheet" /> <link href="https://fonts.upset.dev/css2?family=Poppins&display=swap" rel="stylesheet" />
<title>Uecko</title> <title>Uecko</title>
<script type="module" crossorigin src="/assets/index-he4FVkJC.js"></script> <script type="module" crossorigin src="/assets/index-C4XjvTbB.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-B5XW7DrB.css"> <link rel="stylesheet" crossorigin href="/assets/index-ChUo3IMj.css">
</head> </head>
<body> <body>

View File

@ -1,6 +1,6 @@
{ {
"name": "uecko-presupuestador", "name": "uecko-presupuestador",
"version": "1.1.1", "version": "1.1.2",
"author": "Rodax Software <dev@rodax-software.com>", "author": "Rodax Software <dev@rodax-software.com>",
"license": "ISC", "license": "ISC",
"private": true, "private": true,

View File

@ -16,7 +16,7 @@ import { Router } from "express";
export const quoteRouter = (appRouter: Router): void => { export const quoteRouter = (appRouter: Router): void => {
const quoteRoutes: Router = Router({ mergeParams: true }); const quoteRoutes: Router = Router({ mergeParams: true });
// Users CRUD // Quotes CRUD
quoteRoutes.get("/", checkUser, getDealerMiddleware, handleRequest(listQuotesController)); quoteRoutes.get("/", checkUser, getDealerMiddleware, handleRequest(listQuotesController));
quoteRoutes.get("/:quoteId", checkUser, getDealerMiddleware, handleRequest(getQuoteController)); quoteRoutes.get("/:quoteId", checkUser, getDealerMiddleware, handleRequest(getQuoteController));
quoteRoutes.post("/", checkUser, getDealerMiddleware, handleRequest(createQuoteController)); quoteRoutes.post("/", checkUser, getDealerMiddleware, handleRequest(createQuoteController));

View File

@ -8,14 +8,10 @@ export class Result<T, E extends Error = Error> {
protected constructor(props: { isSuccess: boolean; error?: E; object?: T }) { protected constructor(props: { isSuccess: boolean; error?: E; object?: T }) {
const { isSuccess, error, object } = props; const { isSuccess, error, object } = props;
if (isSuccess && error) { if (isSuccess && error) {
throw new Error( throw new Error(`InvalidOperation: A result cannot be successful and contain an error`);
`InvalidOperation: A result cannot be successful and contain an error`,
);
} }
if (!isSuccess && !error) { if (!isSuccess && !error) {
throw new Error( throw new Error(`InvalidOperation: A failing result needs to contain an error message`);
`InvalidOperation: A failing result needs to contain an error message`,
);
} }
this.isSuccess = isSuccess; this.isSuccess = isSuccess;