File tree Expand file tree Collapse file tree 7 files changed +78
-0
lines changed
Views/Traits/Configuration Expand file tree Collapse file tree 7 files changed +78
-0
lines changed Original file line number Diff line number Diff line change @@ -262,13 +262,19 @@ public function setCollapsingColumnsDisabled(): self
262
262
return $ this ;
263
263
}
264
264
265
+ /**
266
+ * @return $this
267
+ */
265
268
public function setTableRowUrl (callable $ callback ): self
266
269
{
267
270
$ this ->trUrlCallback = $ callback ;
268
271
269
272
return $ this ;
270
273
}
271
274
275
+ /**
276
+ * @return $this
277
+ */
272
278
public function setTableRowUrlTarget (callable $ callback ): self
273
279
{
274
280
$ this ->trUrlTargetCallback = $ callback ;
Original file line number Diff line number Diff line change @@ -276,16 +276,29 @@ public function collapsingColumnsAreDisabled(): bool
276
276
return $ this ->getCollapsingColumnsStatus () === false ;
277
277
}
278
278
279
+ /**
280
+ * @return bool
281
+ */
279
282
public function hasTableRowUrl (): bool
280
283
{
281
284
return $ this ->trUrlCallback !== null ;
282
285
}
283
286
287
+ /**
288
+ * @param $row
289
+ *
290
+ * @return ?string
291
+ */
284
292
public function getTableRowUrl ($ row ): ?string
285
293
{
286
294
return $ this ->trUrlCallback ? call_user_func ($ this ->trUrlCallback , $ row ) : null ;
287
295
}
288
296
297
+ /**
298
+ * @param $row
299
+ *
300
+ * @return ?string
301
+ */
289
302
public function getTableRowUrlTarget ($ row ): ?string
290
303
{
291
304
return $ this ->trUrlTargetCallback ? call_user_func ($ this ->trUrlTargetCallback , $ row ) : null ;
Original file line number Diff line number Diff line change @@ -177,6 +177,9 @@ public function footer($callback = null): self
177
177
return $ this ;
178
178
}
179
179
180
+ /**
181
+ * @return $this
182
+ */
180
183
public function unclickable (): self
181
184
{
182
185
$ this ->clickable = false ;
Original file line number Diff line number Diff line change 7
7
use Rappasoft \LaravelLivewireTables \DataTableComponent ;
8
8
use Rappasoft \LaravelLivewireTables \Exceptions \DataTableConfigurationException ;
9
9
use Rappasoft \LaravelLivewireTables \Views \Column ;
10
+ use Rappasoft \LaravelLivewireTables \Views \Columns \LinkColumn ;
10
11
11
12
trait ColumnHelpers
12
13
{
@@ -510,6 +511,9 @@ public function arrayToAttributes(array $attributes)
510
511
}, array_keys ($ attributes )));
511
512
}
512
513
514
+ /**
515
+ * @return bool
516
+ */
513
517
public function isClickable (): bool
514
518
{
515
519
return $ this ->clickable &&
Original file line number Diff line number Diff line change @@ -211,4 +211,28 @@ public function can_set_collapsing_columns_status(): void
211
211
212
212
$ this ->assertTrue ($ this ->basicTable ->getCollapsingColumnsStatus ());
213
213
}
214
+
215
+ /** @test */
216
+ public function can_set_tr_url (): void
217
+ {
218
+ $ this ->assertNull ($ this ->basicTable ->getTableRowUrl (1 ));
219
+
220
+ $ this ->basicTable ->setTableRowUrl (function ($ row ) {
221
+ return 'https://example.com ' ;
222
+ });
223
+
224
+ $ this ->assertSame ($ this ->basicTable ->getTableRowUrl (1 ), 'https://example.com ' );
225
+ }
226
+
227
+ /** @test */
228
+ public function can_set_tr_url_target (): void
229
+ {
230
+ $ this ->assertNull ($ this ->basicTable ->getTableRowUrlTarget (1 ));
231
+
232
+ $ this ->basicTable ->setTableRowUrlTarget (function ($ row ) {
233
+ return '__blank ' ;
234
+ });
235
+
236
+ $ this ->assertSame ($ this ->basicTable ->getTableRowUrlTarget (1 ), '__blank ' );
237
+ }
214
238
}
Original file line number Diff line number Diff line change @@ -140,4 +140,16 @@ public function can_get_collapsing_columns_status(): void
140
140
141
141
$ this ->assertFalse ($ this ->basicTable ->getCollapsingColumnsStatus ());
142
142
}
143
+
144
+ /** @test */
145
+ public function can_check_for_tr_url (): void
146
+ {
147
+ $ this ->assertFalse ($ this ->basicTable ->hasTableRowUrl ());
148
+
149
+ $ this ->basicTable ->setTableRowUrl (function ($ row ) {
150
+ return 'https://example.com ' ;
151
+ });
152
+
153
+ $ this ->assertTrue ($ this ->basicTable ->hasTableRowUrl ());
154
+ }
143
155
}
Original file line number Diff line number Diff line change @@ -80,4 +80,20 @@ public function can_exclude_from_column_select(): void
80
80
81
81
$ this ->assertFalse ($ column ->isSelectable ());
82
82
}
83
+
84
+ /** @test */
85
+ public function can_make_column_unclickable (): void
86
+ {
87
+ $ column = Column::make ('Name ' );
88
+
89
+ $ column ->setComponent ($ this ->basicTable );
90
+
91
+ $ this ->basicTable ->setTableRowUrl (fn ($ row ) => 'https://example.com ' );
92
+
93
+ $ this ->assertTrue ($ column ->isClickable ());
94
+
95
+ $ column ->unclickable ();
96
+
97
+ $ this ->assertFalse ($ column ->isClickable ());
98
+ }
83
99
}
You can’t perform that action at this time.
0 commit comments