-
Notifications
You must be signed in to change notification settings - Fork 1
/
edit.blade.php
128 lines (124 loc) · 6.4 KB
/
edit.blade.php
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
@extends('layouts.sidebarLeft')
@section('title')
@lang('common.edit')
@stop
@section('sidebarLeft')
@include('account.menu')
@stop
@section('content')
<h1 class="page-header">@lang('common.edit')</h1>
<div class="row">
<div class="col-md-5">
<form id="edit-account-form" action="#" method="POST" role="form">
<div class="form-group{{ $errors->first('nick') ? ' has-error' : '' }}">
<label class="control-label" for="nick">@lang('common.nick')</label>
<input type="text" id="nick" name="nick" class="form-control"
value="{{ $user->nick }}"
placeholder="@lang('common.nick')">
@if($errors->first('nick'))
<p class="help-block">{{ $errors->first('nick') }}</p>
@endif
</div>
<div class="form-group{{ $errors->first('email') ? ' has-error' : '' }}">
<label class="control-label" for="email">@choice('common.email', 1)</label>
<input type="email" id="email" name="email" class="form-control"
value="{{ $user->email }}"
placeholder="@choice('common.email', 1)">
@if($errors->first('email'))
<p class="help-block">{{ $errors->first('email') }}</p>
@endif
</div>
<div class="form-group{{ $errors->first('firstName') ? ' has-error' : '' }}">
<label class="control-label" for="firstName">@lang('common.first_name')</label>
<input type="text" id="firstName" name="firstName" class="form-control"
value="{{ $user->firstName }}"
placeholder="@lang('common.first_name')">
@if($errors->first('firstName'))
<p class="help-block">{{ $errors->first('firstName') }}</p>
@endif
</div>
<div class="form-group{{ $errors->first('lastName') ? ' has-error' : '' }}">
<label class="control-label" for="lastName">@lang('common.last_name')</label>
<input type="text" id="lastName" name="lastName" class="form-control"
value="{{ $user->lastName }}"
placeholder="@lang('common.last_name')">
@if($errors->first('lastName'))
<p class="help-block">{{ $errors->first('lastName') }}</p>
@endif
</div>
@if(strpos($user->email,'@'))
@if($user->password)
<div class="separator">
<span>@lang('common.password_change')</span>
</div>
<p class="text-muted">
<i class="fa fa-info-circle"><!-- icon --></i> @lang('common.leave_blank')
</p>
@else
<div class="separator">
<span>@lang('common.password_set')</span>
</div>
<p class="text-success">
<i class="fa fa-info-circle"><!-- icon --></i> @lang('common.set_password_to_login')
</p>
@endif
<div class="form-group{{ $errors->first('password') ? ' has-error' : '' }}">
<label class="control-label" for="password">@lang('common.new_password')</label>
<input type="password" id="password" name="password" class="form-control"
placeholder="@lang('common.new_password')">
@if($errors->first('password'))
<p class="help-block">{{ $errors->first('password') }}</p>
@endif
</div>
<div class="form-group{{ $errors->first('password_confirmation') ? ' has-error' : '' }}">
<label class="control-label" for="passwordConfirmation">@lang('common.password_repeat')</label>
<input type="password" id="passwordConfirmation" name="password_confirmation"
class="form-control"
placeholder="@lang('common.password_repeat')">
@if($errors->first('password_confirmation'))
<p class="help-block">{{ $errors->first('password_confirmation') }}</p>
@endif
</div>
@endif
<button id="edit-account" type="submit" class="btn btn-primary">@lang('common.save')</button>
</form>
</div>
</div>
@stop
@section('footerScripts')
<script type="text/javascript">
$(function() {
$('#edit-account').click(function(event) {
event.preventDefault();
Loading.start('#main-container');
$.ajax({
url: "{{ request()->getScheme() }}://api.{{ request()->getHTTPHost() }}/v1/user/account",
headers: {'X-CSRF-TOKEN': Laravel.csrfToken},
xhrFields: {
withCredentials: true
},
data: $('#edit-account-form').serializeObject(),
type: 'PUT',
success: function(xhr) {
Loading.stop();
// set success message
setGlobalMessage('success', "@lang('common.changes_saved_message')");
hideMessages();
clearFormValidationErrors();
},
error: function(xhr) {
Loading.stop();
if (typeof xhr.responseJSON !== 'undefined' && xhr.status === 422) {
// clear previous errors
clearFormValidationErrors();
$.each(xhr.responseJSON.error.errors, function(index, error) {
// set form errors
setFormValidationErrors(index, error);
});
}
}
});
})
});
</script>
@append