1.0.10 • Published 5 years ago

vue-crud-component v1.0.10

Weekly downloads
16
License
MIT
Repository
github
Last release
5 years ago

Introduction

Vue Crud Component is a Vue.js component which do all the annoying repetitive administration views for you. This component uses Bootstrap classes. So, if you wish you can add bootstrap css or style it by yourself.

Installation

yarn add vue-crud-component or npm install --save vue-crud-component

// JS
import CrudComponent from 'vue-crud-component'
Vue.use(CrudComponent)
// HTML
<template>
  <crud-component></crud-component>
</template>

You can set your own name of the component by passing name property within object in a second argument of the Vue.use() method. Vue.use(CrudComponent, {name: 'custom-component-name'})

The default component name is crud-component.

Since this component is using bootstrap classes I recommend you to include bootstrap css. Here is a manual.

Setup

Parameters

Parametertyperequireddefaultdescription
dataArraytruenullIt expects Array of Objects which are used to show data in a table.
fieldsObjecttruenullIn this Object you can specify type of the specific fields. eg. birthdate can be set to DateTime. You can find more detailed documentation of this parameter at Fields parameter documentation.
http-createStringfalsecurrentPage/createPost request URL for create action. {id} will be replaced with unique-identifier parameter
http-updateStringfalsecurrentPage/{id}Put request URL for update action. {id} will be replaced with unique-identifier parameter
http-deleteStringfalsecurrentPage/{id}Delete request URL for delete action. {id} will be replaced with unique-identifier parameter
allow-searchBooleanfalsetrueIf set to true search input is visible.
allow-filterBooleanfalsetrueIf set to true filter button is visible.
allow-createBooleanfalsetrueIf set to true create button is visible.
allow-updateBooleanfalsetrueIf set to true update button is visible and record is editable.
allow-deleteBooleanfalsetrueIf set to true delete button is visible.
entity-singularStringfalseRecordIt expects Array of Objects which are used to show data in a table.
entity-pluralStringfalseRecordsIt expects Array of Objects which are used to show data in a table.
unique-identifierStringtrueidIt expects Array of Objects which are used to show data in a table. It is name of the property in object of data parameter.

Fields parameter documentation

Field is a parameter of the component that is expected to be an Object. In fields parameter are specified types and additional configuration of values inside every single record of the data parameter.

Every field key in the fields parameter has to be equal to some key in data parameter. If the field key isn't found in data, it's value is considered as null and can be updated or created in form.

Fields can contain following options

KeytypeRequiredDefaultExtra info
typeStringtruenullAvailable values: ID, Email, Text, Number, Select, Checkbox, Radio, DateTime, Custom
titleStringfalsekey of the field
locationArrayfalse['preview', 'form']
rulesObjectfalseSince validation is made by vee-validate you can use their's validation options. Bear in mind that options has to be in Object format. eg. {required: true, min: 3}
componentString, VueComponenttrueBy default every type has it's on component except CustomThis component is used while editing / creating record. It has to emit input event because it has set v-model attribute.
sortableBooleanfalsefalseIf set to true the column in table will be sortable.
searchableBooleanfalsefalseIf set to true input search will look up for string in this column.
filterableBooleanfalsefalseIf set to true the column values will appear in the filter button.
canBeCreatedBooleanfalsetrueIf set to false this field won't appear in form while creating of the record.
componentPropsObjectfalseempty Objectyou can pass any required props down to the component (or custom component) in Object. eg. {options: {name: 'Default Name'}}

Example:

<crud-component :data="[{
    "id": 88,  
    "first_name": "Wilhelm",  
	"last_name": "McCahey",  
	"email": "wmccahey2f@microsoft.com",  
	"credit_card": "maestro"
}, ...]"
:fields="{
    id: {
	    type: 'ID',
	    title: 'ID',
	    sortable: true
    },
    first_name: {
	    type: 'Text',
	    title: 'First Name',
	    sortable: true
    },
    last_name: {
	    type: 'Text',
	    title: 'Last Name',
	    sortable: true
    },
    credit_card: {
	    type: 'Select',
	    title: 'Credit Card Type',
	    filterable: true,
	    componentProps: {
		    options: {
			    maestro: 'Maestro',
			    master_card: 'Master Card',
			    visa: 'Visa'
		    }
	    }
    },
    email: {
	    type: 'Email',
	    title: 'Email'
    }
}"

Customization

At the moment the only customizable thing is preview of the records. I will provide more information soon...

Vue Crud Component uses following packages:

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago