Skip to content

Commit

Permalink
Create modal with default values
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 fcf1427 commit 8755719
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 59 deletions.
13 changes: 13 additions & 0 deletions src/components/IgntCrud.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { computed, reactive, ref, toRefs } from "vue";
import { useRoute } from "vue-router";
import { useAddress } from "@/def-composables/useAddress";
import { IgntButton } from "@ignt/vue-library";
Expand All @@ -17,6 +18,7 @@ export interface State {
items: Array<any>;
}
const route = useRoute();
const initialState: State = {
visibleModal: "",
activeItem: {},
Expand Down Expand Up @@ -68,6 +70,16 @@ const disableCreate = computed<boolean>(() => {
const onGetItems = values => {
state.items = values;
};
const createModalInitalForm = computed(() => {
if (route.name === "iot.device.events") {
return {
topic: route.params.name
};
}
return {};
});
</script>

<template>
Expand Down Expand Up @@ -111,6 +123,7 @@ const onGetItems = values => {
:store-name="storeName"
:item-name="moduleNameNormalized"
:command-name="`sendMsgCreate${moduleNameNormalized}`"
:inital-data="createModalInitalForm"
@close="
visibleModal = '';
reader?.refetch();
Expand Down
11 changes: 9 additions & 2 deletions src/components/IgntCrudCreate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@submit="submitItem"
>
<template #body>
<div class="my-4" />
<div class="my-4 w-[500px]" />
<div v-for="field in itemFieldsFiltered" :key="'field_' + field">
<label :for="`p${field.name}`" class="sp-label capitalize-first-letter">
{{ field.name }}
Expand Down Expand Up @@ -49,10 +49,17 @@ const props = defineProps({
commandName: {
type: String,
required: true
},
initalData: {
type: Object,
default() {
return {};
}
}
});
const emit = defineEmits(["close"]);
const formData = reactive<any>({});
const formData = reactive<any>(props.initalData);
const { address } = useAddress();
const client = useClient();
// computed
Expand Down
57 changes: 0 additions & 57 deletions src/router/modules/mesh.ts

This file was deleted.

0 comments on commit 8755719

Please sign in to comment.