vi-grid-builder 2.1.1 → 2.1.3

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 CHANGED
@@ -127,33 +127,90 @@ npm run dev
127
127
  ## Example config for columns
128
128
 
129
129
  ```js
130
- columns: [
130
+ columns: [{
131
+ label: 'ID',
132
+ name: 'id',
133
+ type: 'number',
134
+ sortable: true,
135
+ },
131
136
  {
132
- label: 'ID',
133
- type: 'vi-grid-text',
134
- name: 'id',
135
- sortable: true,
136
- align: 'right'
137
+ label: 'Title',
138
+ name: 'title',
137
139
  },
138
140
  {
139
- label: 'Name',
140
- type: 'vi-grid-text',
141
- name: 'user',
142
- format: (row) => `${row.firstName} ${row.lastName}`,
143
- align: 'center'
141
+ label: 'Link',
142
+ name: 'link',
143
+ type: 'link',
144
+ // link:'link'
144
145
  },
145
146
  {
146
- label: 'Hidden column',
147
- type: 'vi-grid-text',
147
+ label: 'Link with title',
148
148
  name: 'title',
149
- isVisible: false // This can be a function as well
149
+ type: 'link',
150
+ link: 'link'
150
151
  },
151
152
  {
152
- label: 'Hidden column with custom rule',
153
- type: 'vi-grid-text',
154
- name: 'title',
155
- isVisible: () => user.role === 'member'
156
- }
153
+ label: 'Price',
154
+ name: 'price',
155
+ type: 'number',
156
+ sortable: true,
157
+ format: {
158
+ style: 'currency',
159
+ currency: 'USD',
160
+ }
161
+ },
162
+ {
163
+ label: 'Image',
164
+ name: 'image',
165
+ type: 'image'
166
+ },
167
+ {
168
+ label: 'Status',
169
+ name: 'status',
170
+ type: 'badge'
171
+ },
172
+ {
173
+ label: 'Date',
174
+ name: 'date',
175
+ type: 'date',
176
+ mode: 'date'
177
+ },
178
+ {
179
+ label: 'Time',
180
+ name: 'date',
181
+ type: 'date',
182
+ },
183
+ {
184
+ label: 'Simple actions',
185
+ name: 'actions',
186
+ type: 'actions',
187
+ actions: [
188
+ {
189
+ action: 'edit',
190
+ name: 'Edit post'
191
+ },
192
+ {
193
+ action: 'remove',
194
+ name: 'Remove post'
195
+ }
196
+ ]
197
+ },
198
+ {
199
+ label: 'Kebab type actions',
200
+ name: 'actions',
201
+ type: 'actions',
202
+ kebab: true,
203
+ actions: [
204
+ {
205
+ action: 'edit',
206
+ name: 'Edit post'
207
+ },
208
+ {
209
+ action: 'remove',
210
+ name: 'Remove post'
211
+ }
212
+ ]
213
+ },
157
214
  ]
158
215
  ```
159
216
 
@@ -182,45 +239,46 @@ Props that you will receive for the custom field are:
182
239
 
183
240
  The component can look like this
184
241
 
185
- ```js
242
+ ```vue
243
+
186
244
  <template>
187
- <div class="avatar">
188
- <img v-if="row.picture"
189
- :src="row.picture" alt="User Avatar" class="avatar-img" />
190
- <div v-else class="avatar-initials">{{initials}}</div>
191
- </div>
245
+ <div class="avatar">
246
+ <img v-if="row.picture"
247
+ :src="row.picture" alt="User Avatar" class="avatar-img"/>
248
+ <div v-else class="avatar-initials">{{initials}}</div>
249
+ </div>
192
250
  </template>
193
251
 
194
252
  <script>
195
- export default {
253
+ export default {
196
254
  name: 'UserAvatar',
197
255
  props: {
198
- field: {
199
- type: Object,
200
- },
201
- value: {},
202
- originalValue: {},
203
- row: {
204
- type: Object,
205
- }
206
- },
256
+ field: {
257
+ type: Object,
258
+ },
259
+ value: {},
260
+ originalValue: {},
261
+ row: {
262
+ type: Object,
263
+ }
264
+ },
207
265
  computed: {
208
- initials() {
209
- if (this.row.name) {
210
- const nameParts = this.row.name.split(' ');
211
- return nameParts.map(part => part[0].toUpperCase()).join('');
212
- }
213
- return '';
214
- }
215
- }
216
- };
266
+ initials() {
267
+ if (this.row.name) {
268
+ const nameParts = this.row.name.split(' ');
269
+ return nameParts.map(part => part[0].toUpperCase()).join('');
270
+ }
271
+ return '';
272
+ }
273
+ }
274
+ };
217
275
  </script>
218
276
  ```
219
277
 
220
278
  Then we need to add this component as part of the settings for the plugin.
221
279
  See example:
222
280
 
223
- ```js
281
+ ```javascript
224
282
  import UserAvatar from "./components/user/UserAvatar.vue";
225
283
  import ViGridBuilder from "vi-grid-builder";
226
284
 
@@ -230,23 +288,12 @@ const app = createApp(App)
230
288
  UserAvatar
231
289
  }
232
290
  })
291
+ ```
233
292
 
234
- After
235
- adding
236
- the
237
- component in the
238
- fieldComponents
239
- we
240
- can
241
- use
242
- the
243
- new field
244
- type in the
245
- definition
246
- for the columns, like
293
+ After adding the component in the fieldComponents we can use the new field type in the definition for the columns, like
247
294
  this
248
- :
249
295
 
296
+ ```javascript
250
297
  columns: [
251
298
  {
252
299
  label: 'User',