-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathProfile.cshtml
More file actions
372 lines (327 loc) · 15.5 KB
/
Copy pathProfile.cshtml
File metadata and controls
372 lines (327 loc) · 15.5 KB
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<ContentModels.Profile>
@using SgfDevs.Dev
@using ContentModels = Umbraco.Cms.Web.Common.PublishedModels;
@using Umbraco.Cms.Core.Security
@using SGFDevs.Dev
@inject IMemberManager _memberManager
@inject DirectoryHelper _directoryHelper
@inject MemberConverter _memberConverter;
@{
var currentMember = await _memberManager.GetCurrentMemberAsync();
var memberById = await _memberManager.FindByIdAsync(currentMember.Id);
var member = _memberConverter.FromContent(_memberManager.AsPublishedMember(memberById));
var success = TempData["ProfileUpdateSuccess"] != null;
var skills = _directoryHelper.GetSkills();
var currentSkills = (member?.SkillsTags ?? Array.Empty<IPublishedContent>()).Select(x => x.Key.ToString()).ToList();
var groups = _directoryHelper.GetGroups();
var currentGroups = (member?.Groups ?? Array.Empty<IPublishedContent>()).Select(x => x.Key.ToString()).ToList();
var aboutText = "";
if(!string.IsNullOrEmpty(member.AboutText.ToString()))
{
var converter = new ReverseMarkdown.Converter();
aboutText = converter.Convert(member.AboutText.ToString());
}
}
@if(member != null)
{
<div class="form">
<header>
<h1>Edit your profile</h1>
</header>
@if (member.HasValue("ProfileImage"))
{
<div class="field">
<img src="@member.ProfileImage.GetCropUrl(width: 200, height: 200)" />
</div>
}
@* @Html.Partial("ProfileEdit") *@
@if (success)
{
<p>Profile updated</p>
}
@using (Html.BeginUmbracoForm("ProfileUpdate", "Account", FormMethod.Post))
{
<div class="field">
<label for="member.Email">Email</label>
<input type="text" id="member.Email" name="email" class="form-control" value="@currentMember.Email"/>
<span asp-validation-for="@currentMember.Email" class="text-danger"></span>
</div>
<div class="field">
<label asp-for="@member.FirstName">First Name</label>
<input asp-for="@member.FirstName" name="FirstName" class="form-control"/>
<span asp-validation-for="@member.FirstName" class="text-danger"></span>
</div>
<div class="field">
<label asp-for="@member.LastName">Last Name</label>
<input asp-for="@member.LastName" name="LastName" class="form-control"/>
<span asp-validation-for="@member.LastName" class="text-danger"></span>
</div>
<div class="field">
<label asp-for="@member.JobTitle">Job Title</label>
<input asp-for="@member.JobTitle" name="JobTitle" class="form-control"/>
<span asp-validation-for="@member.JobTitle" class="text-danger"></span>
</div>
<div class="profile_image_upload">
<input type="hidden" name="ProfileImagePath" value="" id="profile_image_path"/>
<div class="field">
<label>Update Profile Image</label>
<div class="input" style="margin-top: 10px;">
<input type="file" name="sgf_profile_image" accept="image/png, image/jpeg, image/gif"/>
</div>
</div>
</div>
<div class="field" style="display: block;">
<label asp-for="@member.AboutText">About Text</label>
<div style="margin-top: 0.5em">
<textarea name="AboutText" id="AboutText" class="form-control">@aboutText</textarea>
</div>
<span asp-validation-for="@member.AboutText" class="text-danger"></span>
</div>
<div class="field">
<div class="checkbox_list" data-name="skills">
<div class="label">Skills</div>
<ul>
@foreach (var skill in skills)
{
//var udi = new GuidUdi("document", skill.Key).ToString();
var udi = skill.Key.ToString();
var skillName = string.IsNullOrEmpty(skill.DisplayName) ? skill.Name : skill.DisplayName;
var isCurrentSkill = currentSkills.Contains(udi);
<li>
<label>
@if (isCurrentSkill)
{
<input type="checkbox" name="skill" value="@udi" checked/>
@skillName
}
else
{
<input type="checkbox" name="skill" value="@udi"/>
@skillName
}
</label>
</li>
}
</ul>
<input class="values" type="hidden" value="@string.Join(",", currentSkills)" name="Skills"/>
</div>
</div>
<div class="field">
<div class="checkbox_list">
<div class="label">Groups</div>
<ul>
@foreach (var group in groups)
{
var udi = group.Key.ToString();
var groupName = group.Name;
var isCurrentGroup = currentGroups.Contains(udi);
<li>
<label>
@if (isCurrentGroup)
{
<input type="checkbox" name="group" value="@udi" checked/>
@groupName
}
else
{
<input type="checkbox" name="group" value="@udi"/>
@groupName
}
</label>
</li>
}
</ul>
<input class="values" type="hidden" value="@string.Join(",", currentGroups)" name="Groups"/>
</div>
</div>
<div class="field">
<label asp-for="@member.City">City</label>
<input asp-for="@member.City" name="City" class="form-control"/>
<span asp-validation-for="@member.City" class="text-danger"></span>
</div>
<div class="field">
<label asp-for="@member.State">State</label>
<input asp-for="@member.State" name="State" class="form-control"/>
<span asp-validation-for="@member.State" class="text-danger"></span>
</div>
<div class="field">
<label>Available For Hire</label>
<div class="sgf_toggle input">
@if (member.AvailableForHire)
{
<input type="checkbox" name="AvailableForHire" id="AvailableForHire" value="true" checked>
}
else
{
<input type="checkbox" name="AvailableForHire" id="AvailableForHire" value="false">
}
<label for="AvailableForHire">Available For Hire</label>
</div>
</div>
<div class="field">
<label>Available For Contract Work</label>
<div class="sgf_toggle input">
@if (member.AvailableForContractWork)
{
<input type="checkbox" name="AvailableForContractWork" id="AvailableForContractWork" value="true" checked>
}
else
{
<input type="checkbox" name="AvailableForContractWork" id="AvailableForContractWork" value="false">
}
<label for="AvailableForContractWork">Available For Contract Work</label>
</div>
</div>
<div class="field">
<label asp-for="@member.TwitterUrl">Twitter URL</label>
<input asp-for="@member.TwitterUrl" name="TwitterUrl" class="form-control"/>
<span asp-validation-for="@member.TwitterUrl" class="text-danger"></span>
</div>
<div class="field">
<label asp-for="@member.TwitchUrl">Twitch URL</label>
<input asp-for="@member.TwitchUrl" name="TwitchUrl" class="form-control"/>
<span asp-validation-for="@member.TwitchUrl" class="text-danger"></span>
</div>
<div class="field">
<label asp-for="@member.FacebookUrl">Facebook URL</label>
<input asp-for="@member.FacebookUrl" name="FacebookUrl" class="form-control"/>
<span asp-validation-for="@member.FacebookUrl" class="text-danger"></span>
</div>
<div class="field">
<label asp-for="@member.InstagramUrl">Instagram URL</label>
<input asp-for="@member.InstagramUrl" name="InstagramUrl" class="form-control"/>
<span asp-validation-for="@member.InstagramUrl" class="text-danger"></span>
</div>
<div class="field">
<label asp-for="@member.LinkedInUrl">LinkedIn URL</label>
<input asp-for="@member.LinkedInUrl" name="LinkedInUrl" class="form-control"/>
<span asp-validation-for="@member.LinkedInUrl" class="text-danger"></span>
</div>
<div class="field">
<label asp-for="@member.MeetupUrl">Meetup URL</label>
<input asp-for="@member.MeetupUrl" name="MeetupUrl" class="form-control"/>
<span asp-validation-for="@member.MeetupUrl" class="text-danger"></span>
</div>
<div class="field">
<label asp-for="@member.WebsiteUrl">Website URL</label>
<input asp-for="@member.WebsiteUrl" name="WebsiteUrl" class="form-control"/>
<span asp-validation-for="@member.WebsiteUrl" class="text-danger"></span>
</div>
<div class="field">
<label asp-for="@member.YouTubeUrl">YouTube URL</label>
<input asp-for="@member.YouTubeUrl" name="YouTubeUrl" class="form-control"/>
<span asp-validation-for="@member.YouTubeUrl" class="text-danger"></span>
</div>
<footer>
<button class="button tall wide" type="submit">Save</button>
</footer>
}
<div class="mt_75"></div>
</div>
}
@section TopScripts
{
<style>
.form {
padding: 0 15px;
}
.filepond--root {
max-width: 300px;
}
.filepond--credits {
display: none;
}
.filepond--file-info {
display: none !important;
}
</style>
<link href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css" rel="stylesheet">
<link href="https://unpkg.com/filepond/dist/filepond.css" rel="stylesheet">
<link href="https://unpkg.com/filepond-plugin-image-preview/dist/filepond-plugin-image-preview.css" rel="stylesheet">
<link href="https://unpkg.com/filepond-plugin-image-edit/dist/filepond-plugin-image-edit.css" rel="stylesheet">
<script src="https://unpkg.com/filepond-plugin-image-edit/dist/filepond-plugin-image-edit.js"></script>
<script src="https://unpkg.com/filepond-plugin-image-transform/dist/filepond-plugin-image-transform.js"></script>
<script src="https://unpkg.com/filepond-plugin-image-resize/dist/filepond-plugin-image-resize.js"></script>
<script src="https://unpkg.com/filepond-plugin-image-crop/dist/filepond-plugin-image-crop.js"></script>
<script src="https://unpkg.com/filepond-plugin-image-preview/dist/filepond-plugin-image-preview.js"></script>
<script src="https://unpkg.com/filepond-plugin-image-exif-orientation/dist/filepond-plugin-image-exif-orientation.js"></script>
<script src="https://unpkg.com/filepond-plugin-file-validate-type/dist/filepond-plugin-file-validate-type.js"></script>
<script src="https://unpkg.com/filepond-plugin-file-validate-size/dist/filepond-plugin-file-validate-size.js"></script>
<script src="https://unpkg.com/filepond/dist/filepond.js"></script>
<script src="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
}
@section Head
{
<style>
.validation-summary-errors {
color: red;
font-weight: bold;
}
</style>
}
@section Scripts {
<script>
//const inputElement = document.querySelector('input[type="file"]');
//const pond = FilePond.create(inputElement);
FilePond.registerPlugin(
FilePondPluginFileValidateType,
FilePondPluginImageExifOrientation,
FilePondPluginImagePreview,
FilePondPluginImageCrop,
FilePondPluginImageResize,
FilePondPluginImageTransform,
);
// Select the file input and use
// create() to turn it into a pond
FilePond.create(
document.querySelector('input[type="file"]'),
{
labelIdle: `Drag & Drop your picture or <span class="filepond--label-action">Browse</span>`,
imagePreviewHeight: 300,
imageCropAspectRatio: '1:1',
//imageResizeTargetWidth: 300,
//imageResizeTargetHeight: 300,
//stylePanelLayout: 'compact circle',
stylePanelLayout: 'compact',
styleLoadIndicatorPosition: 'center bottom',
styleProgressIndicatorPosition: 'right bottom',
styleButtonRemoveItemPosition: 'center bottom',
styleButtonProcessItemPosition: 'right bottom',
onprocessfile: function (error, file) {
if (file.serverId) {
var umbPath = file.serverId.replace(/"/g, "");
document.getElementById('profile_image_path').value = umbPath;
}
},
//files: [
// {
// // the server file reference
// source: '132',
// options: {
// type: 'local'
// }
// }
//],
dropOnPage: true
// Use Doka.js as image editor
//imageEditEditor: Doka.create({
// utils: ['crop', 'filter', 'color']
//})
}
);
FilePond.setOptions({
server: {
process: '/api/profile/image-process',
load: '/api/profile/image-load'
}
});
let simplemde = new SimpleMDE({
element: document.getElementById("AboutText"),
autosave: {
enabled: true,
uniqueId: "Psh",
delay: 500,
},
});
</script>
}