@ -8,21 +8,25 @@
<table id="tbc">
<table id="tbc">
<thead>
<thead>
<tr>
<tr>
<th data-sort="string"><%=Html.Translate("Title")%></th>
<th data-sort="string"><%=Html.Translate("Title")%>
</th>
</tr>
</tr>
</thead>
</thead>
<tbody id="tbcb">
<tbody id="tbcb">
<% int lc=0;
<% int lc=0;
foreach (var ci in (IEnumerable<Circle>) ViewData["Circles"]) { lc++; %>
foreach (var ci in (IEnumerable<Circle>) ViewData["Circles"]) { lc++; %>
<tr class="<%= (lc%2==0)?"even ":"odd " %>row" id="c_<%=ci.Id%>">
<tr class="<%= (lc%2==0)?"even ":"odd " %>row" id="c_<%=ci.Id%>">
<td><%=Html.FormatCircle(ci)%></td>
<td cid="<%=ci.Id%>" style="cursor: pointer;" class="btnselcircle" ><%=Html.FormatCircle(ci)%></td>
<td>
<td>
<input type="button" value="<%=Html.Translate("Remove")%>" class="btnremovecircle actionlink" cid="<%=ci.Id%>"/>
<input type="button" value="<%=Html.Translate("Remove")%>"
class="btnremovecircle actionlink" cid="<%=ci.Id%>"/>
</td>
</td>
</tr>
</tr>
<% } %>
<% } %>
</tbody>
</tbody>
</table>
</table>
<div class="actionlink" id="btednvcirc" did="fncirc">Ajouter un cercle</div>
<script>
<script>
$(function(){
$(function(){
$("#tbc").stupidtable();
$("#tbc").stupidtable();
@ -30,19 +34,13 @@ $("#tbc").stupidtable();
</script>
</script>
</asp:Content>
</asp:Content>
<asp:Content ID="MASContentContent" ContentPlaceHolderID="MASContent" runat="server">
<asp:Content ID="MASContentContent" ContentPlaceHolderID="MASContent" runat="server">
<div id="fncirc" class="hidden">
<div id="dfnuser" class="hidden panel">
<%= Html.Partial("~/Views/Account/Register.ascx",new RegisterClientModel(),new ViewDataDictionary(ViewData)
<div class="panel">
{
TemplateInfo = new System.Web.Mvc.TemplateInfo
{
HtmlFieldPrefix = ViewData.TemplateInfo.HtmlFieldPrefix==""?"ur":ViewData.TemplateInfo.HtmlFieldPrefix+"_ur"
}
}) %>
</div>
<form>
<form>
<fieldset>
<fieldset>
<legend>Nouveau cercle </legend>
<legend id="lgdnvcirc"></legend>
<span id="msg" class="field-validation-valid error"></span>
<span id="msg" class="field-validation-valid error"></span>
<label for="title"><b><%=Html.Translate("Title")%></b></label>
<label for="title"><b><%=Html.Translate("Title")%></b></label>
<input type="text" id="title" name="title" class="inputtext"/>
<input type="text" id="title" name="title" class="inputtext"/>
@ -55,37 +53,58 @@ $("#tbc").stupidtable();
<yavsc:InputUserName
<yavsc:InputUserName
id="users"
id="users"
name="users"
name="users"
emptyvalue="[nouvel utilisateur ]"
emptyvalue="[aucun ]"
onchange="onmembersChange(this.value);"
onchange="onmembersChange(this.value);"
multiple="true"
multiple="true"
runat="server" >
runat="server" >
</yavsc:InputUserName>
</yavsc:InputUserName>
</th>
</tr>
</thead>
<tbody id="tbmbrsb">
</tbody>
</table>
<input type="button" id="btnnewcircle" value="<%=Html.Translate("Create")%>" class="actionlink rowbtnct" />
</fieldset>
</form>
</div>
</div>
<script>
<script>
function message(msg) {
if (msg) {
$("#msg").removeClass("hidden");
$("#msg").text(msg);
} else { $("#msg").addClass("hidden"); } }
function onmembersChange(newval)
var cformhidden=true;
var errspanid="msg";
function getCircle(id)
{
{
if (newval=='')
$.getJSON("<%=Url.Content("~/api/Circle/Get/")%>"+id,
$("#dfnuser").removeClass("hidden");
function(json) { $("#title").val( json.Title); $("#users").val( json.Members ) ; });
else
$("#dfnuser").addClass("hidden");
}
}
function clearRegistrationValidation(){
$("#Err_ur_Name").text("");
function editNewCircle() {
$("#Err_ur_UserName").text("");
if ($('#fncirc').hasClass('hidden')) $('#fncirc').removeClass('hidden')
$("#Err_ur_Mobile").text("");
$('#lgdnvcirc').html("Creation d'un cercle");
$("#Err_ur_Phone").text("");
$("#Err_ur_Email").text("");
$("#Err_ur_Address").text("");
$("#Err_ur_ZipCode").text("");
$("#Err_ur_CityAndState").text("");
$("#Err_ur_IsApprouved").text("");
}
}
function clearCircleValidation() {}
function selectCircle() {
if ($('#fncirc').hasClass('hidden')) $('#fncirc').removeClass('hidden')
var id = $(this).attr('cid');
$('#lgdnvcirc').html("Edition du cercle");
// get it from the server
getCircle(id);
}
function onmembersChange(newval)
{
}
function removeCircle() {
function removeCircle() {
message(false);
message(false);
var id = $(this).attr('cid');
var id = $(this).attr('cid');
@ -93,8 +112,8 @@ $("#tbc").stupidtable();
url: "<%=Url.Content("~/api/Circle/Delete/")%>"+id,
url: "<%=Url.Content("~/api/Circle/Delete/")%>"+id,
type: "GET",
type: "GET",
success: function (data) {
success: function (data) {
// Drops the detroyed circle row
// Drops the row
$("c_"+id).remove();
$("# c_"+id).remove();
},
},
statusCode: {
statusCode: {
400: function(data) {
400: function(data) {
@ -125,56 +144,23 @@ $("#tbc").stupidtable();
url: "<%=Url.Content("~/api/Circle/Create")%>",
url: "<%=Url.Content("~/api/Circle/Create")%>",
type: "POST",
type: "POST",
data: circle,
data: circle,
success: function (data ) {
success: function (i d) {
// Adds a node rendering the new circle
// Adds a node rendering the new circle
$("#tbcb").append("<tr><td>"+circle.title+" <br><i>"+circle.users+"</i></td></tr>");
$('<tr id="c_'+id+'"/>').addClass('selected row')
},
.appendTo('#tbcb');
statusCode: {
400: function(data) {
$('<td>'+circle.title+'<br><i>'+
$.each(data.responseJSON, function (key, value) {
circle.users+
var errspanid = "Err_cr_" + value.key.replace("model.","");
'</i></td></td>')
var errspan = document.getElementById(errspanid);
.appendTo('#c_'+id);
if (errspan==null)
alert('enoent '+errspanid);
$('<td><input class="btnremovecircle actionlink" cid="'+id+'" type="button" value="Remove" onclick="removeCircle"></td>').appendTo('#c_'+id);
else
errspan.innerHTML=value.errors.join("<br/>");
});
}
},
error: function (xhr, ajaxOptions, thrownError) {
if (xhr.status!=400)
message(xhr.status+" : "+xhr.responseText);
else message(false);
}});
}
function addUser()
{
message(false);
var user={
UserName: $("#ur_UserName").val(),
Name: $("#ur_Name").val(),
Password: $("#ur_Password").val(),
Email: $("#ur_Email").val(),
Address: $("#ur_Address").val(),
CityAndState: $("#ur_CityAndState").val(),
ZipCode: $("#ur_ZipCode").val(),
Phone: $("#ur_Phone").val(),
Mobile: $("#ur_Mobile").val(),
IsApprouved: true
};
clearRegistrationValidation();
$.ajax({
url: "<%=Url.Content("~/api/FrontOffice/Register")%>",
type: "POST",
data: user,
success: function (data) {
$("#users option:last").after($('<option>'+user.UserName+'</option>'));
},
},
statusCode: {
statusCode: {
400: function(data) {
400: function(data) {
$.each(data.responseJSON, function (key, value) {
$.each(data.responseJSON, function (key, value) {
var errspanid = "Err_u r_" + value.key.replace("model.","");
var errspanid = "Err_cr_" + value.key.replace("model.","");
var errspan = document.getElementById(errspanid);
var errspan = document.getElementById(errspanid);
if (errspan==null)
if (errspan==null)
alert('enoent '+errspanid);
alert('enoent '+errspanid);
@ -189,22 +175,11 @@ $("#tbc").stupidtable();
else message(false);
else message(false);
}});
}});
}
}
</script>
</th>
</tr>
</thead>
<tbody id="tbmbrsb">
</tbody>
</table>
<input type="button" id="btnnewcircle" value="<%=Html.Translate("Create")%>" class="actionlink rowbtnct" />
</fieldset>
</form>
<script>
$(document).ready(function () {
$(document).ready(function () {
$("#btnnewuser").click(addUser );
$('#btednvcirc').click(editNewCircle);
$("#btnnewcircle").click(addCircle);
$("#btnnewcircle").click(addCircle);
$(".btnremovecircle").click(removeCircle);
$(".btnremovecircle").click(removeCircle);
$(".btnselcircle").click(selectCircle);
});
});
</script>
</script>
</asp:Content>
</asp:Content>