@@ -59,6 +59,16 @@ class CrudTable extends Vue {
5959 @Prop ({ default: false }) enableViewSwitcher! : boolean
6060 @Prop ({ default: ' No items yet' }) emptyStateText! : string
6161 @Prop ({ default: ' ' }) search! : string
62+ @Prop ({ default: true }) showPagination! : boolean
63+ @Prop ({ default: true }) enableRowHover! : boolean ;
64+
65+ getRowClass() {
66+ return {
67+ ' dynamic-hover' : this .enableRowHover ,
68+ ' transition-all' : true ,
69+ };
70+ }
71+
6272
6373 items: DescriptiveIdentifiable [] = []
6474 totalItems = 0
@@ -97,6 +107,8 @@ class CrudTable extends Vue {
97107 }
98108
99109 mounted() {
110+ console .log (this .showPagination , " VVVVVVVVVVVVVVVVV" )
111+ console .log (this .items .length , " kasjdlsajdksajdl" )
100112 const urlSearch = (this .$route .query .search as string ) || ' '
101113 this .loading = true
102114 this .initialSearchCompleted = false
@@ -205,7 +217,10 @@ class CrudTable extends Vue {
205217 this .totalItems = page .totalElements ?? 0
206218 this .items = page .content ?? []
207219 this .initialSearchCompleted = true
220+
221+ this .$emit (' items-count' , this .items .length )
208222 })
223+
209224 .catch ((error : unknown ) => {
210225 console .error (' [CRUD Table Alert]:' , error )
211226 this .loading = false
@@ -223,20 +238,21 @@ export default toNative(CrudTable)
223238 <template #start >
224239 <IconField class =" w-full max-w-sm" >
225240 <InputIcon class =" pi pi-search" />
226- <InputText v-model =" searchText" placeholder =" Search" @input =" onSearchChange" @keyup.enter =" find" />
241+ <InputText v-model =" searchText" placeholder =" Search" size =" small" @input =" onSearchChange"
242+ @keyup.enter =" find" />
227243 </IconField >
228244 </template >
229245
230246 <template #end >
231247 <div class =" flex items-center gap-2 h-[33px]" >
232- <SelectButton v-if =" enableViewSwitcher" v-model =" activeView" :options =" viewOptions" optionValue = " value "
233- dataKey =" value" class = " h-[33px] " >
248+ <SelectButton size = " small " v-if =" enableViewSwitcher" v-model =" activeView" :options =" viewOptions"
249+ optionValue =" value" dataKey = " value " >
234250 <template #option =" slotProps " >
235251 <i :class =" slotProps.option.icon" ></i >
236252 </template >
237253 </SelectButton >
238- <Button v-if =" !disableModifications && isShowAddNew" @click =" addItem" :label = " createNewButtonText "
239- icon =" pi pi-plus" class = " h-[33px] " />
254+ <Button size = " small " v-if =" !disableModifications && isShowAddNew" @click =" addItem"
255+ :label = " createNewButtonText " icon =" pi pi-plus" />
240256 </div >
241257 </template >
242258 </Toolbar >
@@ -245,38 +261,56 @@ export default toNative(CrudTable)
245261 <div v-if =" isColumnView" >
246262 <div v-if =" items.length > 0" class =" grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4" >
247263 <Card v-for =" (item, index) in items" :key =" item.id || index"
248- class =" cursor-pointer hover:shadow-md transition-shadow h-[152px ] flex flex-col justify-between"
264+ class =" cursor-pointer relative hover:shadow-md transition-shadow h-[170px ] flex flex-col justify-between"
249265 @click =" handleCardClick(item, index)" >
266+ <template #title >
267+ <h3 class =" " >{{ item?.id }}</h3 >
268+ </template >
269+
250270 <template #content >
251- <div >
252- <h3 class =" font-semibold text-[#101010] mb-1" >{{ item?.id }}</h3 >
253- <p class =" text-sm text-gray-500 truncate" >{{ item?.description }}</p >
254- </div >
255- <div class =" flex gap-2 mt-3" >
256- <Button severity =" secondary" text class =" p-2"
271+ <p class =" truncate-multiline max-h-[46px]" >{{ item?.description }}</p >
272+
273+ </template >
274+
275+ <template #footer >
276+ <div class =" flex p-5 gap-4 absolute bottom-0 left-0" >
277+ <Button severity =" secondary" text class =" !p-0"
257278 @click.stop =" $router.push({ path: '/graphql', query: { namespace: item.id } })" >
258279 <img src =" @/assets/graphql.svg" alt =" GraphQL" class =" w-5 h-5" />
259280 </Button >
260- <Button severity =" secondary" text class =" p-2 "
281+ <Button severity =" secondary" text class =" !p-0 "
261282 @click.stop =" $router.push('/scalar-ui.html?namespace=' + item.id)" >
262283 <img src =" @/assets/scalar.svg" alt =" OpenAPI" class =" w-5 h-5" />
263284 </Button >
264285 </div >
265286 </template >
266287 </Card >
288+
267289 </div >
268290 <div v-else class =" flex flex-col items-center justify-center text-gray-500 py-20 h-[calc(100vh-300px)]" >
269291 <p class =" text-sm" >{{ emptyStateText }}</p >
270292 </div >
271293
272294 <Paginator :rows =" options.rows" :totalRecords =" totalItems" @page =" onPaginatorPage" class =" mt-4"
273- v-if =" items.length !== 0 " />
295+ v-if =" showPagination " />
274296 </div >
275297
276298 <div v-if =" isBurgerView" class =" p-4 border text-[color:var(--surface-200)] rounded-xl" >
277- <DataTable :value =" items" :rows =" options.rows" :totalRecords =" totalItems" :loading =" loading"
278- :paginator =" items.length > 0" :first =" options.first" :rowsPerPageOptions =" [5, 10, 20]" dataKey =" id"
279- @page =" onDataTablePage" @row-click =" onRowClick" sortMode =" multiple" table >
299+ <DataTable
300+ :value =" items"
301+ :rows =" options.rows"
302+ :totalRecords =" totalItems"
303+ :loading =" loading"
304+ :paginator =" showPagination"
305+ :first =" options.first"
306+ :rowsPerPageOptions =" [5, 10, 20]"
307+ dataKey =" id"
308+ @page =" onDataTablePage"
309+ @row-click =" onRowClick"
310+ sortMode =" multiple"
311+ :rowClass =" getRowClass"
312+
313+ >
280314 <Column v-for =" col in computedHeaders" :key =" col.field" :field =" col.field" :header =" col.header"
281315 :sortable =" col.sortable !== false" >
282316 <template #body =" slotProps " >
@@ -316,4 +350,17 @@ export default toNative(CrudTable)
316350 border : none !important ;
317351 box-shadow : none !important ;
318352}
353+
354+ .truncate-multiline {
355+ display : -webkit-box ;
356+ -webkit-line-clamp : 2 ;
357+ -webkit-box-orient : vertical ;
358+ overflow : hidden ;
359+ }
360+
361+ .dynamic-hover :hover {
362+ cursor : pointer ;
363+ background-color : var (--row-hover-color , #eff6ff ) !important ;
364+ transition : background-color 0.3s ease !important ;
365+ }
319366 </style >
0 commit comments