<script setup>
import {getDataColumns, getDataRows, getSaveFunction, setDataRows} from "@/components/forms/other/MassDataInserter.vue";
import { ref, computed, defineEmits, defineProps } from 'vue';
import { SessionUser } from "@/components/session/token/SessionUser.vue";

// Emits
const emit = defineEmits(["onClickSave"]);
const onClickSave = () => {
    // Save the dataRows
    const saveFunction = getSaveFunction();
    if (saveFunction) {
        saveFunction(getDataRows());
    } else {
        console.error("No save function defined");
    }
    // Emit the event
    emit("onClickSave");
}

</script>

<template>
    <!-- Confirm, save and close -->
    <button
        class="button is-light is-fullwidth"
        v-bind:disabled="getDataRows().length === 0"
        @click="onClickSave"
    >
      <span class="icon is-small">
        <i class="fas fa-plus"></i>
      </span>
      <span>{{ SessionUser.objects.global.language.add }}{{ getDataRows().length > 0 ? ( ' ' + getDataRows().length + ' ' + SessionUser.objects.global.language.rows ) : '' }}</span>
    </button>
</template>

<style scoped>

</style>