Skip to content

Commit

Permalink
#48 Update table after add serie
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcellino-Palerme committed Jun 24, 2024
1 parent 3abf9ec commit 25d0e1c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
12 changes: 9 additions & 3 deletions components/ManageSerie.async.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as v from 'valibot';
const { t } = useI18n();
const dialog = ref<boolean>(false);
const validateForm = ref(false);

const rUpload = ref(false);

const nameRules = ref([
(value: string) =>
Expand All @@ -28,7 +28,7 @@ const rDaughterLoading = ref<boolean>(false);
/**
* Add a new serie
*/
function add() {
async function add() {
// reset form
rDaughterTable.value = [];
nameSerie.value = "";
Expand Down Expand Up @@ -117,8 +117,13 @@ async function submit (event) {
nameSerie: event.target.elements.nameSerie.value,
daughterGroup,
}),
})
.then(() => {
rUpload.value = !rUpload.value;
})
.catch((error) => {
// TODO: show error message
});

}

</script>
Expand All @@ -127,6 +132,7 @@ async function submit (event) {
<table-db-action
name-db-table="view_serie"
:add="add"
:update="rUpload"
/>
<v-dialog
v-model="dialog"
Expand Down
8 changes: 7 additions & 1 deletion components/TableDbAction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ const props = defineProps({
default: 10,
required: false
},
// ask update table: just toggle update variable in parent component
update:{
type:Boolean,
default:false,
required:false
},
// define actions
// thx: https://github.com/vuejs/rfcs/discussions/397#discussioncomment-7745658
// add
Expand Down Expand Up @@ -78,7 +84,7 @@ type typePropsAction = typeof props.add
// define type to use string as index of action props
type keyPropsAction = keyof typeof props

const rfUpdate = ref<boolean>(false);
const rfUpdate = toRef(props, "update");
// For internationalization
const { t } = useI18n();

Expand Down

0 comments on commit 25d0e1c

Please sign in to comment.