11<template >
2- <div class =" bg-white w-2/3-screen lg:w-1/3-screen overflow-hidden flex flex-col" v-if =" loadsUnits" >
3- <div id =" header" class =" h-16 flex justify-center items-center flex-shrink-0" >
4- <h3 class =" font-bold text-gray-700" >{{ __( 'Choose Selling Unit' ) }}</h3 >
5- </div >
6- <div v-if =" unitsQuantities.length > 0" class =" grid grid-flow-row grid-cols-2 overflow-y-auto" >
7- <div @click =" selectUnit( unitQuantity )" :key =" unitQuantity.id" v-for =" unitQuantity of unitsQuantities" class =" hover:bg-gray-200 cursor-pointer border flex-shrink-0 border-gray-200 flex flex-col items-center justify-center" >
8- <div class =" h-40 w-full flex items-center justify-center overflow-hidden" >
9- <img v-if =" unitQuantity.preview_url" :src =" unitQuantity.preview_url" class =" object-cover h-full" :alt =" unitQuantity.unit.name" >
10- <div class =" h-40 flex items-center justify-center" v-if =" ! unitQuantity.preview_url" >
11- <i class =" las la-image text-gray-600 text-6xl" ></i >
2+ <div class =" h-full w-full flex items-center justify-center" >
3+ <div class =" bg-white w-2/3-screen lg:w-1/3-screen overflow-hidden flex flex-col" v-if =" unitsQuantities.length > 0" >
4+ <div id =" header" class =" h-16 flex justify-center items-center flex-shrink-0" >
5+ <h3 class =" font-bold text-gray-700" >{{ __( 'Choose Selling Unit' ) }}</h3 >
6+ </div >
7+ <div v-if =" unitsQuantities.length > 0" class =" grid grid-flow-row grid-cols-2 overflow-y-auto" >
8+ <div @click =" selectUnit( unitQuantity )" :key =" unitQuantity.id" v-for =" unitQuantity of unitsQuantities" class =" hover:bg-gray-200 cursor-pointer border flex-shrink-0 border-gray-200 flex flex-col items-center justify-center" >
9+ <div class =" h-40 w-full flex items-center justify-center overflow-hidden" >
10+ <img v-if =" unitQuantity.preview_url" :src =" unitQuantity.preview_url" class =" object-cover h-full" :alt =" unitQuantity.unit.name" >
11+ <div class =" h-40 flex items-center justify-center" v-if =" ! unitQuantity.preview_url" >
12+ <i class =" las la-image text-gray-600 text-6xl" ></i >
13+ </div >
1214 </div >
13- </ div >
14- <div class =" h-0 w-full" >
15- < div class =" relative w-full flex items-center justify-center -top-10 h-20 py-2 flex-col " style = " background : rgb ( 255 255 255 / 73 % ) " >
16- < h3 class =" font-bold text-gray-700 py-2 text-center " >{{ unitQuantity.unit.name }} ({{ unitQuantity .quantity }})</ h3 >
17- <p class = " text-sm font-medium text-gray-600 " >{{ unitQuantity.sale_price | currency }}</ p >
15+ < div class = " h-0 w-full " >
16+ <div class =" relative w-full flex items-center justify-center -top-10 h-20 py-2 flex-col " style = " background : rgb ( 255 255 255 / 73 % ) " >
17+ < h3 class =" font-bold text-gray-700 py-2 text-center " >{{ unitQuantity.unit.name }} ({{ unitQuantity .quantity }})</ h3 >
18+ < p class =" text-sm font-medium text-gray-600 " >{{ unitQuantity.sale_price | currency }}</ p >
19+ </ div >
1820 </div >
1921 </div >
2022 </div >
@@ -60,6 +62,11 @@ export default {
6062 */
6163 if ( this .$popupParams .product .$original ().selectedUnitQuantity !== undefined ) {
6264 this .selectUnit ( this .$popupParams .product .$original ().selectedUnitQuantity );
65+ } else if (
66+ this .$popupParams .product .$original ().unit_quantities !== undefined &&
67+ this .$popupParams .product .$original ().unit_quantities .length === 1
68+ ) {
69+ this .selectUnit ( this .$popupParams .product .$original ().unit_quantities [0 ] );
6370 } else {
6471 this .loadsUnits = true ;
6572 this .loadUnits ();
@@ -73,7 +80,7 @@ export default {
7380
7481 if ( result .length === 0 ) {
7582 this .$popup .close ();
76- return nsSnackBar .error ( __ ( ' This product doesn\' t has any unit defined for selling.' ) ).subscribe ();
83+ return nsSnackBar .error ( __ ( ' This product doesn\' t have any unit defined for selling.' ) ).subscribe ();
7784 }
7885
7986 this .unitsQuantities = result;
0 commit comments