Datamängdredigerare

Datamändgredigeraren används för att erbjuda användare funktionerna "lägg till", "ändra" och "ta bort" i en datamängd. Komponenten ansvarar inte för hur datamängden och åtgärderna "lägg till", "ändra" och "ta bort" presenteras. Vanligtvis används lista eller tabell för presentation men kan även vara egenutvecklad.

Interaktiv tabell med redigering

Förpopulera objekt

Använd propen beforeCreate med en callback som returnerar ett objekt för att förpopulera data som ska läggas till. Callback anropas innan modalen visas.

<f-crud-dataset :before-create="onBeforeCreate">
    <template #default> ... </template>
</f-crud-dataset>
function onBeforeCreate(): MyInterface {
    return {
        /* ... */
    };
}

Anpassade texter

Texterna i modaler kan anpassas för att bättre beskriva vad som läggs till, ändras eller tas bort genom att använda props. Även texten för "lägg till"-knapp kan ändras via slot add-button.

Datatabell med lägg till-knapp

Interaktiv tabell med knapp

Lista med redigering

Sorterbar lista

API

Props

v-model: T[] Optional

The list of items that should be deleted, modified or added to. If the prop is not set an empty array will be used.

Default: () => []

beforeCreate: (() => T) | undefined Optional

A function that returns an item to the #add template. Can be used to populate data that the user should not input themself e.g. an id. Or to give the user suggestions for inputs. If the prop is not used an empty item will be returned.

Default: undefined

primaryButtonRight: boolean Optional

If true the primary button in the modals will be placed to the right side instead of to the left.

Default: false

beforeSubmit: FValidationFormCallback Optional

If given, this function is called before the [[submit]] event is emitted. See <f-validation-form> beforeSubmit props for more info.

Default: function() { /* do nothing */ }

beforeValidation: FValidationFormCallback Optional

If given, this function is called before the form data is validated and the [[submit]] event is emitted. See <f-validation-form> beforeValidation props for more info.

Default: function() { /* do nothing */ }

onCancel: () => void Optional

If given, this function is called after the modal has been closed.

Default: function() { return undefined; }

addNewModalHeader: string Optional

Property for changing the "add new" modal heading

Default: TranslationService.provider.translate("fkui.crud-dataset.modal.header.add", "Lägg till rad")

modifyModalHeader: string Optional

Property for changing the "modify" modal heading

Default: TranslationService.provider.translate("fkui.crud-dataset.modal.header.modify", "Ändra rad")

deleteModalHeader: string Optional

Property for changing the "delete" modal heading

Default: TranslationService.provider.translate( "fkui.crud-dataset.modal.header.delete", "Är du säker på att du vill ta bort raden?", )

Events

created

Emitted when an item is added.

Arguments:

  • item: T the added item.
deleted

Emitted when an item is deleted.

Arguments:

  • item: T the deleted item.
updated

Emitted when an item is updated.

Arguments:

  • item: T the updated item.

Slots

default

Slot for displaying the data.

add-button

Slot for changing the text in "Add new" button`

add

Slot for inputs when creating a new item. The new item is available through v-slot="{ item }". If any data in the item should be set not by the user the prop beforeCreate can be used to set that data.

Bindings:

  • item: T Item returned by beforeCreate or an empty object.
modify

Slot for inputs when modifying an item. The item being modified is available through v-slot="{ item }".

Bindings:

  • item: T A clone of the current item.
delete

Slot for displaying a warning message before an item is deleted. The item being deleted is available through v-slot="{ item }".

Bindings:

  • item: T Item about to be deleted.

Esc för att stänga Pil upp/ner för att navigera Enter för att välja