Skip to content

Commit

Permalink
Add filter params
Browse files Browse the repository at this point in the history
Signed-off-by: rovast <rovast@163.com>
  • Loading branch information
rovast committed Sep 1, 2023
1 parent c525cf3 commit 4f91276
Showing 1 changed file with 68 additions and 63 deletions.
131 changes: 68 additions & 63 deletions src/components/IgntCrudRead.vue
Original file line number Diff line number Diff line change
@@ -1,72 +1,13 @@
<template>
<div>
<div v-if="items" class="max-w-xl">
<div
v-for="item in items"
:key="item.id"
class="flex justify-between mb-6 items-start"
>
<div
class="w-10 bg-gray-100 flex items-center justify-center h-10 rounded-lg mr-4"
>
<IgntFileIcon class="text-3xl" />
</div>
<div class="flex-1">
<div v-for="field in itemFields.fields" :key="'field_' + field">
<div class="text-sm text-gray-400 font-semibold capitalize">
{{ field.name }}
</div>
<div class="mb-3 text-base">{{ item[field.name] }}</div>
</div>
</div>
<div class="relative" v-if="address">
<Menu>
<MenuButton>
<IgntDotsIcon class="hover:bg-gray-100 rounded-lg text-3xl" />
</MenuButton>
<transition
enter-active-class="transition duration-100 ease-out"
enter-from-class="transform scale-95 opacity-0"
enter-to-class="transform scale-100 opacity-100"
leave-active-class="transition duration-75 ease-out"
leave-from-class="transform scale-100 opacity-100"
leave-to-class="transform scale-95 opacity-0"
>
<MenuItems class="absolute shadow-std px-3 w-40 rounded-lg">
<MenuItem
:disabled="!loggedIn"
as="div"
class="cursor-pointer py-2 my-2 text-sm text-gray-500 ui-active:text-black ui-active:font-medium"
@click="emit('editItem', item)"
>Edit</MenuItem
>
<MenuItem
:disabled="!loggedIn"
as="div"
class="cursor-pointer py-2 my-2 text-sm text-red-500 ui-active:font-medium"
@click="emit('deleteItem', item)"
>Delete</MenuItem
>
</MenuItems>
</transition>
</Menu>
</div>
</div>
<div v-if="(items || []).length === 0">
<div class="my-4" />
<div>No items</div>
</div>
</div>
</div>
</template>

<script setup lang="ts">
import { useClient } from "@/composables/useClient";
import { IgntFileIcon } from "@ignt/vue-library";
import { IgntDotsIcon } from "@ignt/vue-library";
import { Menu, MenuButton, MenuItems, MenuItem } from "@headlessui/vue";
import { computed, ref } from "vue";
import { useAddress } from "@/def-composables/useAddress";
import { useRoute } from "vue-router";
const route = useRoute();
const props = defineProps({
storeName: {
Expand Down Expand Up @@ -123,7 +64,9 @@ const fetch = async () => {
| "useKeplr"
>
] as any
).query[props.commandName]()
).query[props.commandName]({
deviceName: route.params.name
})
).data[props.itemName.toLowerCase()];
};
const refetch = async () => {
Expand All @@ -134,3 +77,65 @@ const refetch = async () => {
defineExpose({ refetch });
await refetch();
</script>

<template>
<div>
<div v-if="items" class="max-w-xl">
<div
v-for="item in items"
:key="item.id"
class="flex justify-between mb-6 items-start"
>
<div
class="w-10 bg-gray-100 flex items-center justify-center h-10 rounded-lg mr-4"
>
<IgntFileIcon class="text-3xl" />
</div>
<div class="flex-1">
<div v-for="field in itemFields.fields" :key="'field_' + field">
<div class="text-sm text-gray-400 font-semibold capitalize">
{{ field.name }}
</div>
<div class="mb-3 text-base">{{ item[field.name] }}</div>
</div>
</div>
<div class="relative" v-if="address">
<Menu>
<MenuButton>
<IgntDotsIcon class="hover:bg-gray-100 rounded-lg text-3xl" />
</MenuButton>
<transition
enter-active-class="transition duration-100 ease-out"
enter-from-class="transform scale-95 opacity-0"
enter-to-class="transform scale-100 opacity-100"
leave-active-class="transition duration-75 ease-out"
leave-from-class="transform scale-100 opacity-100"
leave-to-class="transform scale-95 opacity-0"
>
<MenuItems class="absolute shadow-std px-3 w-40 rounded-lg">
<MenuItem
:disabled="!loggedIn"
as="div"
class="cursor-pointer py-2 my-2 text-sm text-gray-500 ui-active:text-black ui-active:font-medium"
@click="emit('editItem', item)"
>Edit</MenuItem
>
<MenuItem
:disabled="!loggedIn"
as="div"
class="cursor-pointer py-2 my-2 text-sm text-red-500 ui-active:font-medium"
@click="emit('deleteItem', item)"
>Delete</MenuItem
>
</MenuItems>
</transition>
</Menu>
</div>
</div>
<div v-if="(items || []).length === 0">
<div class="my-4" />
<div>No items</div>
</div>
</div>
</div>
</template>

0 comments on commit 4f91276

Please sign in to comment.