-
Notifications
You must be signed in to change notification settings - Fork 47
/
form.html.heex
214 lines (191 loc) · 5.81 KB
/
form.html.heex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<% bsname = view_colour() %>
<%= form_for @changeset, @action, fn f -> %>
<%= if @changeset.action do %>
<div class="alert alert-danger">
<p>Oops, something went wrong! Please check the errors below.</p>
</div>
<% end %>
<div class="form-group row">
<div class="col-xl-4 col-lg-4">
<%= label(f, :name, class: "control-label") %>
<%= text_input(f, :name, class: "form-control", disabled: "disabled") %>
<%= error_tag(f, :name) %>
</div>
<%= if allow?(@conn, "Admin") do %>
<div class="col-xl-4 col-lg-4">
<%= label(f, :email, class: "control-label") %>
<%= text_input(f, :email, class: "form-control") %>
<%= error_tag(f, :email) %>
</div>
<% end %>
<div class="col-xl-4 col-lg-4">
<%= if assigns[:user].smurf_of_id do %>
<%= link(raw("<i class='far fa-fw fa-link-slash'></i> Clear smurf link"),
to: ~p"/teiserver/admin/users/cancel_smurf_mark/#{@user.id}",
method: :delete,
class: "btn btn-outline-warning"
) %>
<% end %>
</div>
</div>
<div class="form-group row px-3 py-2">
<div :if={allow?(@conn, "Server")} class="col">
<h5>Management</h5>
<%= for r <- @management_roles do %>
<% style = @role_styling_map[r]
label =
if style do
raw(
"<i class='fa-fw #{style[:icon]}' style='color: #{style[:colour]}'></i> #{r}"
)
else
r
end %>
<%= central_component("checkbox",
id: "user_#{r}",
name: "user[#{r}]",
label: label,
checked: r in (@changeset.data.roles || [])
) %>
<% end %>
</div>
<div :if={allow?(@conn, "Admin")} class="col">
<h5>Moderation</h5>
<%= for r <- @moderation_roles do %>
<% style = @role_styling_map[r]
label =
if style do
raw(
"<i class='fa-fw #{style[:icon]}' style='color: #{style[:colour]}'></i> #{r}"
)
else
r
end %>
<%= central_component("checkbox",
id: "user_#{r}",
name: "user[#{r}]",
label: label,
checked: r in (@changeset.data.roles || [])
) %>
<% end %>
</div>
<div :if={allow?(@conn, "Admin")} class="col">
<h5>Staff</h5>
<%= for r <- @staff_roles do %>
<% style = @role_styling_map[r]
label =
if style do
raw(
"<i class='fa-fw #{style[:icon]}' style='color: #{style[:colour]}'></i> #{r}"
)
else
r
end %>
<%= central_component("checkbox",
id: "user_#{r}",
name: "user[#{r}]",
label: label,
checked: r in (@changeset.data.roles || [])
) %>
<% end %>
</div>
<div :if={allow?(@conn, "Admin")} class="col">
<h5>Community</h5>
<%= for r <- @community_roles do %>
<% style = @role_styling_map[r]
label =
if style do
raw(
"<i class='fa-fw #{style[:icon]}' style='color: #{style[:colour]}'></i> #{r}"
)
else
r
end %>
<%= central_component("checkbox",
id: "user_#{r}",
name: "user[#{r}]",
label: label,
checked: r in (@changeset.data.roles || [])
) %>
<% end %>
</div>
<div :if={allow?(@conn, "Admin")} class="col">
<h5>Privileged</h5>
<%= for r <- @privileged_roles do %>
<% style = @role_styling_map[r]
label =
if style do
raw(
"<i class='fa-fw #{style[:icon]}' style='color: #{style[:colour]}'></i> #{r}"
)
else
r
end %>
<%= central_component("checkbox",
id: "user_#{r}",
name: "user[#{r}]",
label: label,
checked: r in (@changeset.data.roles || [])
) %>
<% end %>
</div>
<div class="col">
<h5>Property</h5>
<%= for r <- @property_roles do %>
<% style = @role_styling_map[r]
label =
if style do
raw(
"<i class='fa-fw #{style[:icon]}' style='color: #{style[:colour]}'></i> #{r}"
)
else
r
end %>
<%= central_component("checkbox",
id: "user_#{r}",
name: "user[#{r}]",
label: label,
checked: r in (@changeset.data.roles || [])
) %>
<% end %>
</div>
</div>
<div :if={allow?(@conn, "Admin")} class="row mt-2">
<div class="col">
<%= input_with_type(f, :colour, "color") %>
</div>
<div class="col">
<%= central_component("fa5_icon_picker", %{form: f, field: :icon}) %>
</div>
</div>
<div :if={allow?(@conn, "Server")} class="row mt-2">
<div class="col">
<%= label(f, :behaviour_score, class: "control-label") %>
<%= text_input(f, :behaviour_score, class: "form-control") %>
<%= error_tag(f, :behaviour_score) %>
</div>
<div class="col">
<%= label(f, :trust_score, class: "control-label") %>
<%= text_input(f, :trust_score, class: "form-control") %>
<%= error_tag(f, :trust_score) %>
</div>
<div class="col">
<%= label(f, :social_score, class: "control-label") %>
<%= text_input(f, :social_score, class: "form-control") %>
<%= error_tag(f, :social_score) %>
</div>
</div>
<div class="form-group m-2 my-4">
<%= if @changeset.data.id do %>
<a href={~p"/teiserver/admin/user/#{@user}"} class="btn btn-secondary btn-outline">
Cancel
</a>
<% end %>
<input
type="submit"
value="Save changes"
name="form.submitted"
class={"btn btn-#{bsname} float-end"}
/>
</div>
<% end %>