File tree 2 files changed +8
-4
lines changed
2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -108,14 +108,15 @@ public function ajaxData(array|string $data): static
108
108
*
109
109
* @param string $display
110
110
* @param string $id
111
+ * @param string $wrap
111
112
* @return $this
112
113
*/
113
- public function processPaginatedResults (string $ display = 'text ' , string $ id = 'id ' ): static
114
+ public function processPaginatedResults (string $ display = 'text ' , string $ id = 'id ' , string $ wrap = ' results ' ): static
114
115
{
115
116
$ script = 'function(data, params) { ' ;
116
117
$ script .= 'params.page = params.page || 1; ' ;
117
- $ script .= "data.data .map(function(e) { e.text = e. $ display; e.id = e. $ id; return e; }); " ;
118
- $ script .= ' return { results: data.data , pagination: { more: data.meta.current_page < data.meta.last_page } }; ' ;
118
+ $ script .= "data. $ wrap .map(function(e) { e.text = e. $ display; e.id = e. $ id; return e; }); " ;
119
+ $ script .= " return { results: data. $ wrap , pagination: { more: data.meta.current_page < data.meta.last_page } }; " ;
119
120
$ script .= '} ' ;
120
121
121
122
return $ this ->processResults ($ script );
Original file line number Diff line number Diff line change @@ -197,7 +197,10 @@ public function it_can_create_select2_field()
197
197
$ this ->assertEquals ('/url ' , $ field ->opts ['ajax ' ]['url ' ]);
198
198
$ this ->assertStringContainsString ('e.text = e.username ' , $ field ->opts ['ajax ' ]['processResults ' ]);
199
199
$ this ->assertStringContainsString ('e.id = e.user_id ' , $ field ->opts ['ajax ' ]['processResults ' ]);
200
- $ this ->assertStringContainsString ('data.meta.current_page < data.meta.last_page ' , $ field ->opts ['ajax ' ]['processResults ' ]);
200
+ $ this ->assertStringContainsString ('data.results.map ' , $ field ->opts ['ajax ' ]['processResults ' ]);
201
+
202
+ $ field ->processPaginatedResults ('username ' , 'user_id ' , 'data ' );
203
+ $ this ->assertStringContainsString ('data.data.map ' , $ field ->opts ['ajax ' ]['processResults ' ]);
201
204
202
205
$ field ->placeholder ('New Placeholder ' );
203
206
$ this ->assertEquals ('New Placeholder ' , $ field ->opts ['placeholder ' ]['text ' ]);
You can’t perform that action at this time.
0 commit comments