-
Notifications
You must be signed in to change notification settings - Fork 10
/
wizard_new_accounts.html
198 lines (174 loc) · 8.37 KB
/
wizard_new_accounts.html
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
{% extends "community/_base.html" %}
{% from "macros/box.html" import m_box_content, m_box_menu %}
{% import "community/members_macros.html" as macros with context %}
{%- from "community/macros.html" import wizard_steps -%}
{% from "macros/user.html" import m_user_link, m_user_photo %}
{% block memberscontent %}
{% call m_box_content(_("Members Wizard")) %}
{{ wizard_steps(steps,3) }}
<br>
<div class="row">
<form class="form-horizontal" id="wizard-1">
<div class="form-bootstrapWizard col-sm-offset-2">
<div class="clearfix"></div>
</div>
<div style="margin-right: 8%;margin-left: 8%;">
<div class="tab-content col-sm-12">
<div class="tab-pane active" id="tab1">
<br>
<h3 class="titre"> {{ _("New Users Accounts") }} </h3>
<h4 class="sous_titre">
{{ _("The members below are not registered on the platform. Please create their accounts so that they can join the community.") }}
</h4>
<div class="form-group bloc col-lg-12">
<br>
<label>{{ _("Profile") }}</label>
<h6 class="sous_titre_step2">
{{ _("Complete the information below to create a new user. They will receive a mail instruction to connect.") }}
</h6>
<br>
<div class="input-group col-lg-12">
<div class="alert alert-warning wizard-warning" style="display:none;" role="alert">
<span
class="glyphicon glyphicon-check"
aria-hidden="true"></span>
{{ _("You need to complete all the fields") }}
</div>
{% set table_id = uuid() %}
<table class="table table-condensed table-striped" id="{{ table_id }}">
<tr>
<th>Email</th>
<th>First Name <span class="content-required">*</span></th>
<th>Last Name <span class="content-required">*</span></th>
<th>Role</th>
<th></th>
</tr>
{% set nb_new_accounts = (new_accounts|length) %}
{% if new_accounts %}
{% for user in new_accounts %}
<tr>
<td style="color: gray;font-weight: bold;position: relative;top: 6px;left:3px;">
<input
id="email{{ loop.index-1 }}" value="{{ user.email }}" type="hidden"
name="account"/> {{ user.email }}
</td>
<td>
<input placeholder="First Name" id="first_name{{ loop.index-1 }}" name="first_name"
class="form-control wizard-required" type="text" value="{{ user.first_name }}"/>
</td>
<td>
<input name="last_name" id="last_name{{ loop.index-1 }}" placeholder="Last Name"
class="form-control wizard-required" type="text" value="{{ user.last_name }}"/>
</td>
<td>
<select onchange="" id="role{{ loop.index-1 }}" name="role"
class="form-control role-change" style="">
{% set default_role = user.role %}
<option value="{{ user.role }}"
{%- if default_role == "member" %}selected="selected"{% endif %}
{%- if role == 'member' %}
selected="selected"{%- endif %}>{{ _("Member") }}</option>
<option value="manager"
{%- if default_role == "manager" %}selected="selected"{% endif %}
{%- if role == 'manager' %}selected="selected"{%- endif %}>{{ _("Manager") }}</option>
</select>
</td>
<td>
<a style="position: relative;left: 10px;" id="{{ user.email }}"
onclick="remove_user(this)" class="btn btn-danger"><i class="fa fa-times"></i></a>
</td>
</tr>
{% endfor %}
{% endif %}
</table>
<a class="users-wizard-next btn default" onclick="wizard_check()"
style="float: right;color: white;background: yellowgreen;margin-bottom: 13px;"><i
class="fa fa-floppy-o" aria-hidden="true"></i>
{{ _("Save") }}</a>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
<form method="POST" id="wizard-form" class="form-inline"
action=" {{ url_for('.wizard_saving',community_id=g.community.slug) }}">
{{ csrf_token }}
<input id="existing_account" type="hidden" name="existing_account" value="{{ existing_account }}">
<input id="new_accounts" type="hidden" name="new_accounts" value='{{ new_accounts|tojson }}'>
</form>
<script>
function wizard_check() {
var nb_missed = 0;
$(".wizard-required").each(function (index) {
if ($(this).val().trim() === "") {
$(".wizard-warning").fadeIn();
$(this).css("border", "2px solid coral");
nb_missed += 1;
} else {
$(this).css("border", "0px");
}
});
if (nb_missed === 0) {
var existing_account = $("#existing_account").val();
existing_account = jQuery.parseJSON(existing_account);
var new_accounts = $("#new_accounts").val();
new_accounts = jQuery.parseJSON(new_accounts);
var new_accounts_list = [];
for (var n = 0; n <={{nb_new_accounts}}; n++) {
if ($("#first_name" + n).length !== 0) {
var tmp_account = {};
tmp_account["email"] = $("#email" + n).val();
tmp_account["first_name"] = $("#first_name" + n).val();
tmp_account["last_name"] = $("#last_name" + n).val();
tmp_account["role"] = $("#role" + n).val();
new_accounts_list.push(tmp_account);
}
}
$("#new_accounts").val(JSON.stringify(new_accounts_list));
$("#wizard-form").submit();
}
}
function remove_user(e) {
$(e).closest('tr').fadeOut('slow', function () {
$(e).closest('tr').remove();
var wizard_emails = $("#new_accounts").val();
var tmp_emails = jQuery.parseJSON(wizard_emails);
jQuery.each(tmp_emails, function (i, val) {
if (val.email === e.id) {
delete tmp_emails[i];
}
});
tmp_emails = jQuery.grep(tmp_emails, function (n, i) {
return (n !== "" && n != null);
});
$("#new_accounts").val(JSON.stringify(tmp_emails));
if ($(".table-condensed tr").length === 1) {
$(".table-condensed").closest('tr').remove();
$(".table-condensed").append("<tr><td id='wizard-msg' colspan='5' style='display:none;padding: 10px;color: gray;width: 18cm;'> <i class='fa fa-check-circle' aria-hidden='true'></i> {{_('There is no new accounts')}}</td></tr>");
$("#wizard-msg").fadeIn();
}
});
}
if ($(".table-condensed tr").length === 1) {
$(".table-condensed").closest('tr').remove();
$(".table-condensed").append("<tr><td id='wizard-msg' colspan='5' style='display:none;padding: 10px;color: gray;'> <i class='fa fa-check-circle' aria-hidden='true'></i> {{_('There is no existing accounts')}}</td></tr>");
$("#wizard-msg").fadeIn();
}
</script>
<div class="clearfix"></div>
{% endcall %}
{% endblock %}
{% block sidebar %}
{%- set actions = actions.for_category('members:menu') %}
{%- if actions %}
{% call m_box_menu() %}
<ul class="nav nav-list">
{%- for action in actions %}
<li>{{ action.render() }}</li>
{%- endfor %}
</ul>
{% endcall %}
{%- endif %}
{% endblock %}