Skip to content

Commit bf5e365

Browse files
committed
doc and examples
1 parent 7b26b9d commit bf5e365

File tree

3 files changed

+56
-79
lines changed

3 files changed

+56
-79
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ jobs:
2424
- "./dist/build/crud-table.css"
2525
skip_cleanup: true
2626
on:
27-
tags: false
27+
tags: true

README.md

Lines changed: 55 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
# svelte-generic-crud-table
22
Use as:
3-
- Web-component: `<crud-table></crud-table>` [![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://www.webcomponents.org/element/svelte-generic-crud-table)
3+
- [![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://www.webcomponents.org/element/svelte-generic-crud-table): `<crud-table></crud-table>`
44
- or Svelte-component: `import SvelteGenericCrudTable from 'svelte-generic-crud-table'`
55

6-
See examples below...
7-
8-
9-
[![Build Status](https://travis-ci.com/ivosdc/svelte-generic-crud-table.svg?branch=master)](https://travis-ci.com/ivosdc/svelte-generic-crud-table)
10-
[![Coverage Status](https://coveralls.io/repos/github/ivosdc/svelte-generic-crud-table/badge.svg?branch=master)](https://coveralls.io/github/ivosdc/svelte-generic-crud-table?branch=master)
11-
126
A self-containing sortable table component with inline edit option.
137

148
Allows CRUD-operations for Object-Arrays.
@@ -24,76 +18,17 @@ npm install -save svelte-generic-crud-table
2418
```
2519

2620
[![Donate](https://github.com/ivosdc/svelte-generic-crud-table/raw/master/assets/donate.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=7V5M288MUT7GE&source=url)
21+
22+
### master state:
23+
[![Build Status](https://travis-ci.com/ivosdc/svelte-generic-crud-table.svg?branch=master)](https://travis-ci.com/ivosdc/svelte-generic-crud-table)
24+
[![Coverage Status](https://coveralls.io/repos/github/ivosdc/svelte-generic-crud-table/badge.svg?branch=master)](https://coveralls.io/github/ivosdc/svelte-generic-crud-table?branch=master)
25+
2726
# Usage
2827
Use the svelte-generic-crud-table in your component to show and, if you like, edit,update and delete it's content.
2928
Just include the table as seen in the example below.
3029

3130

32-
### Set options - Svelte-Component:
33-
```
34-
<script>
35-
import SvelteGenericCrudTable from "svelte-generic-crud-table";
36-
37-
function handleDelete(event) {
38-
const id = event.detail.id; // position in myObjectArray
39-
const body = event.detail.body; // object to delete
40-
console.log(JSON.stringify(event.detail.body));
41-
myObjectArray.slice(id,1);
42-
}
43-
44-
function handleUpdate(event) {
45-
const id = event.detail.id; // position in table
46-
const body = event.detail.body;
47-
console.log(JSON.stringify(body));
48-
myObjectArray[id] = body;
49-
}
50-
51-
function handleCreate(event) {
52-
console.log(JSON.stringify(event.detail)); // empty object is passed by now
53-
myObjectArray.push({id: -1, name:'new Element', sthg:'2345', why:'1234'})
54-
myObjectArray = myObjectArray;
55-
}
56-
57-
function handleDetails(event) {
58-
const id = event.detail.id; // position in table
59-
const body = event.detail.body;
60-
console.log(JSON.stringify(body));
61-
}
62-
63-
function handleSort(event) {
64-
console.log('sort: ' + e.detail.column);
65-
}
66-
67-
// example object array. This should be your db query result.
68-
const myObjectArray = [
69-
{id: 1, name: "A_NAME_1", sthg: "A_STHG_1", why: "because"},
70-
{id: 2, name: "A_NAME_2", sthg: "A_STHG_2", why: "I can"}
71-
]
72-
</script>
73-
74-
<main>
75-
<SvelteGenericCrudTable on:delete={handleDelete}
76-
on:update={handleUpdate}
77-
on:create={handleCreate}
78-
on:details={handleDetails}
79-
on:sort={handleSort}
80-
table_config={{
81-
name: 'Awesome',
82-
options: ['CREATE', 'EDIT', 'DELETE', 'DETAILS'],
83-
columns_setting: [
84-
// columns order is relevant
85-
{name: 'id', show: false, edit: true, size: '200px'},
86-
{name: 'name', show: true, edit: true, size: '200px'},
87-
{name: 'why', show: true, edit: true, size: '200px'},
88-
{name: 'sthg', show: true, edit: false, size: '200px'}
89-
]
90-
}}
91-
table_data={JSON.stringify(myObjectArray)}></SvelteGenericCrudTable>
92-
</main>
93-
```
94-
95-
96-
### As Web-Component `<crud-table></crud-table>`
31+
### `<crud-table></crud-table>`
9732
```
9833
<custom-element-demo>
9934
<template>
@@ -205,7 +140,55 @@ Just include the table as seen in the example below.
205140
</template>
206141
</custom-element-demo>
207142
```
143+
208144
```html
209145
<crud-table></crud-table>
210146
```
211147

148+
### Svelte-Component:
149+
```
150+
<script>
151+
import SvelteGenericCrudTable from "svelte-generic-crud-table";
152+
153+
function handleDelete(event) {
154+
}
155+
156+
function handleUpdate(event) {
157+
}
158+
159+
function handleCreate(event) {
160+
}
161+
162+
function handleDetails(event) {
163+
}
164+
165+
function handleSort(event) {
166+
}
167+
168+
// example object array. This should be your db query result.
169+
const myObjectArray = [
170+
{id: 1, name: "A_NAME_1", sthg: "A_STHG_1", why: "because"},
171+
{id: 2, name: "A_NAME_2", sthg: "A_STHG_2", why: "I can"}
172+
]
173+
</script>
174+
175+
<main>
176+
<SvelteGenericCrudTable on:delete={handleDelete}
177+
on:update={handleUpdate}
178+
on:create={handleCreate}
179+
on:details={handleDetails}
180+
on:sort={handleSort}
181+
table_config={{
182+
name: 'Awesome',
183+
options: ['CREATE', 'EDIT', 'DELETE', 'DETAILS'],
184+
columns_setting: [
185+
// columns order is relevant
186+
{name: 'id', show: false, edit: true, size: '200px'},
187+
{name: 'name', show: true, edit: true, size: '200px'},
188+
{name: 'why', show: true, edit: true, size: '200px'},
189+
{name: 'sthg', show: true, edit: false, size: '200px'}
190+
]
191+
}}
192+
table_data={JSON.stringify(myObjectArray)}></SvelteGenericCrudTable>
193+
</main>
194+
```

dist/donate.html

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)