@sulzanoks/vue-datatable 0.2.3 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -0
- package/dist/datatable-card.es.js +240 -203
- package/dist/datatable-card.umd.js +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/Components/DatatableCard.vue +64 -10
package/README.md
CHANGED
|
@@ -82,6 +82,75 @@ The DatatableCard component accepts the following props:
|
|
|
82
82
|
- `label` (String, optional): Text to display inside button.
|
|
83
83
|
- `class` (String, optional): CSS class to apply to button.
|
|
84
84
|
|
|
85
|
+
## Link Parameters (`linkParams`)
|
|
86
|
+
|
|
87
|
+
The `generateLink` method now supports **two modes** for building links:
|
|
88
|
+
|
|
89
|
+
### 1. Laravel Route Name (default / original behavior)
|
|
90
|
+
|
|
91
|
+
Use when you want to leverage Laravel named routes via Ziggy’s `route()` helper.
|
|
92
|
+
|
|
93
|
+
```js
|
|
94
|
+
{
|
|
95
|
+
data: 'title',
|
|
96
|
+
linkParams: {
|
|
97
|
+
name: 'users.show', // Laravel route name
|
|
98
|
+
resourceIds: ['id'], // values taken from the row
|
|
99
|
+
query: { tab: 'info' } // optional query params
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
➡️ If `row.id = 5`, this builds:
|
|
105
|
+
```
|
|
106
|
+
/users/5?tab=info
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### 2. Link Template
|
|
110
|
+
|
|
111
|
+
Use when you want full control over the URL structure without relying on Laravel route names.
|
|
112
|
+
|
|
113
|
+
#### Object Form
|
|
114
|
+
```js
|
|
115
|
+
{
|
|
116
|
+
data: 'title',
|
|
117
|
+
linkParams: {
|
|
118
|
+
template: '/users/{id}/posts/{post_id}',
|
|
119
|
+
params: { post_id: 'latest' }, // override or add interpolation values
|
|
120
|
+
query: { filter: 'active' } // optional query params
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
➡️ If `row.id = 5`, this builds:
|
|
125
|
+
```
|
|
126
|
+
/users/5/posts/latest?filter=active
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
#### String Shorthand
|
|
130
|
+
```js
|
|
131
|
+
{
|
|
132
|
+
data: 'title',
|
|
133
|
+
linkParams: '/users/{id}'
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
➡️ If `row.id = 5`, this builds:
|
|
137
|
+
```
|
|
138
|
+
/users/5
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Template Placeholders
|
|
142
|
+
|
|
143
|
+
Templates support both styles:
|
|
144
|
+
- `{key}` → `/users/{id}`
|
|
145
|
+
- `:key` → `/users/:id`
|
|
146
|
+
|
|
147
|
+
Both will be replaced with the row’s value (or overridden via `params`).
|
|
148
|
+
|
|
149
|
+
### Notes
|
|
150
|
+
- If both `params` and row values define the same key, `params` takes precedence.
|
|
151
|
+
- Query parameters (`query`) are supported in both modes.
|
|
152
|
+
- If you just need a simple route name, use **mode 1**; if you want custom URLs, use **mode 2**.
|
|
153
|
+
|
|
85
154
|
## Internal Methods
|
|
86
155
|
|
|
87
156
|
These methods are meant to be used by component internally, but maybe you can find use for them
|