@@ -19,20 +19,20 @@ defmodule Backpex.Resource do
19
19
search: {"hello", [:title, :description]}
20
20
]
21
21
"""
22
- def list ( criteria , assigns , live_resource ) do
22
+ def list ( criteria , assigns , live_resource , fields ) do
23
23
adapter = live_resource . config ( :adapter )
24
24
25
- adapter . list ( criteria , assigns , live_resource )
25
+ adapter . list ( criteria , assigns , live_resource , fields )
26
26
end
27
27
28
28
@ doc """
29
29
Gets the total count of the current live_resource.
30
30
Possibly being constrained the item query and the search- and filter options.
31
31
"""
32
- def count ( criteria , assigns , live_resource ) do
32
+ def count ( criteria , assigns , live_resource , fields ) do
33
33
adapter = live_resource . config ( :adapter )
34
34
35
- adapter . count ( criteria , assigns , live_resource )
35
+ adapter . count ( criteria , assigns , live_resource , fields )
36
36
end
37
37
38
38
@ doc """
@@ -46,17 +46,17 @@ defmodule Backpex.Resource do
46
46
* `assigns` (map): The current assigns of the socket.
47
47
* `live_resource` (module): The `Backpex.LiveResource` module.
48
48
"""
49
- def get ( primary_value , assigns , live_resource ) do
49
+ def get ( primary_value , assigns , live_resource , fields ) do
50
50
adapter = live_resource . config ( :adapter )
51
51
52
- adapter . get ( primary_value , assigns , live_resource )
52
+ adapter . get ( primary_value , assigns , live_resource , fields )
53
53
end
54
54
55
55
@ doc """
56
56
Same as `get/4` but returns the result or raises an error.
57
57
"""
58
- def get! ( primary_value , assigns , live_resource ) do
59
- case get ( primary_value , assigns , live_resource ) do
58
+ def get! ( primary_value , assigns , live_resource , fields ) do
59
+ case get ( primary_value , assigns , live_resource , fields ) do
60
60
{ :ok , nil } -> raise Backpex.NoResultsError
61
61
{ :ok , result } -> result
62
62
{ :error , _error } -> raise Backpex.NoResultsError
@@ -92,11 +92,10 @@ defmodule Backpex.Resource do
92
92
* `attrs` (map): A map of parameters that will be passed to the `changeset_function`.
93
93
* TODO: docs
94
94
"""
95
- def insert ( item , attrs , assigns , live_resource , opts ) do
95
+ def insert ( item , attrs , assigns , live_resource , fields , opts ) do
96
96
{ after_save_fun , opts } = Keyword . pop ( opts , :after_save_fun , & { :ok , & 1 } )
97
97
98
98
adapter = live_resource . config ( :adapter )
99
- fields = live_resource . fields ( :new , assigns )
100
99
101
100
item
102
101
|> change ( attrs , fields , assigns , live_resource , Keyword . put ( opts , :action , :insert ) )
@@ -114,11 +113,10 @@ defmodule Backpex.Resource do
114
113
* `attrs` (map): A map of parameters that will be passed to the `changeset_function`.
115
114
* TODO: docs
116
115
"""
117
- def update ( item , attrs , assigns , live_resource , opts \\ [ ] ) do
116
+ def update ( item , attrs , assigns , fields , live_resource , opts \\ [ ] ) do
118
117
{ after_save_fun , opts } = Keyword . pop ( opts , :after_save_fun , & { :ok , & 1 } )
119
118
120
119
adapter = live_resource . config ( :adapter )
121
- fields = live_resource . fields ( :edit , assigns )
122
120
123
121
item
124
122
|> change ( attrs , fields , assigns , live_resource , Keyword . put ( opts , :action , :update ) )
0 commit comments