* Circles.aspx: fixes circle updates

* yavsc.circles.js: * refactoring
* fixes circle update
vnext
Paul Schneider 9 years ago
parent edf89cf739
commit e9eddf56a7
3 changed files with 51 additions and 36 deletions

@ -1,3 +1,10 @@
2015-09-10 Paul Schneider <paul@pschneider.fr>
* Circles.aspx: fixes circle updates
* yavsc.circles.js: * refactoring
* fixes circle update
2015-09-10 Paul Schneider <paul@pschneider.fr>
* instdbws.sql:

@ -2,8 +2,23 @@
var errspanid="msg";
var CirclesApiUrl = apiBaseUrl + "/Circle";
function onAjaxBadInput(data)
{
$.each(data.responseJSON, function (key, value) {
var errspanid = "Err_cr_" + value.key.replace("model.","");
var errspan = document.getElementById(errspanid);
if (errspan==null)
alert('enoent '+errspanid);
else
errspan.innerHTML=value.errors.join("<br/>");
});
}
function onAjaxError(xhr, ajaxOptions, thrownError) {
if (xhr.status!=400)
Yavsc.message(xhr.status+" : "+xhr.responseText);
else Yavsc.message(false);
}
function editNewCircle() {
if ($('#fncirc').hasClass('hidden')) $('#fncirc').removeClass('hidden')
@ -42,26 +57,30 @@ function removeCircle() {
$("#c_"+id).remove();
},
statusCode: {
400: function(data) {
$.each(data.responseJSON, function (key, value) {
var errspanid = "Err_cr_" + value.key.replace("model.","");
var errspan = document.getElementById(errspanid);
if (errspan==null)
alert('enoent '+errspanid);
else
errspan.innerHTML=value.errors.join("<br/>");
});
}
},
400: onAjaxBadInput,
error: function (xhr, ajaxOptions, thrownError) {
if (xhr.status!=400)
Yavsc.message(xhr.status+" : "+xhr.responseText);
else Yavsc.message(false);
}});
}}});
}
function modifyCircle() {
Yavsc.message(false);
var circle = { title: $("#title").val(), id: $('#id').val(), isprivate: $('#isprivate').val() } ;
var id = $('#id').val();
var circle = { title: $("#title").val(), id: id} ;
$.ajax({
url: CirclesApiUrl+"/Update",
type: "POST",
data: circle,
success: function () {
$('#c_'+id+' td:first-child').text(circle.title);
}
,
statusCode: {
400: onAjaxBadInput,
error: onAjaxError
}
});
}
function addCircle()
@ -78,25 +97,14 @@ function addCircle()
$('<tr id="c_'+id+'"/>').addClass('selected row')
.appendTo('#tbcb');
$('<td>'+circle.title+' <br><i>'+
circle.members+
'</i></td></td>')
$('<td>'+circle.title+'</td>').attr('cid',id).click(selectCircle)
.appendTo('#c_'+id);
$('<td><input class="btnremovecircle actionlink" cid="'+id+'" type="button" value="Remove" onclick="removeCircle"></td>').appendTo('#c_'+id);
$('<input type="button" value="Remove">').addClass("actionlink").attr('cid',id).click(removeCircle).appendTo('<td></td>').appendTo('#c_'+id);
},
statusCode: {
400: function(data) {
$.each(data.responseJSON, function (key, value) {
var errspanid = "Err_cr_" + value.key.replace("model.","");
var errspan = document.getElementById(errspanid);
if (errspan==null)
alert('enoent '+errspanid);
else
errspan.innerHTML=value.errors.join("<br/>");
});
}
400: onAjaxBadInput
},
error: function (xhr, ajaxOptions, thrownError) {
if (xhr.status!=400)
@ -104,3 +112,5 @@ function addCircle()
else Yavsc.message(false);
}});
}

@ -12,14 +12,15 @@
</th>
</tr>
</thead>
<style>
.btnselcircle { cursor: pointer; }
</style>
<tbody id="tbcb">
<% int lc=0;
foreach (var ci in (IEnumerable<CircleBase>) ViewData["Circles"]) { lc++; %>
<tr class="<%= (lc%2==0)?"even ":"odd " %>row" id="c_<%=ci.Id%>">
<td cid="<%=ci.Id%>" style="cursor: pointer;" class="btnselcircle" >
<%=ci.Title%></td>
<td>
<input type="button" value="<%=Html.Translate("Remove")%>"
<td cid="<%=ci.Id%>" class="btnselcircle"><%=ci.Title%></td>
<td><input type="button" value="<%=Html.Translate("Remove")%>"
class="btnremovecircle actionlink" cid="<%=ci.Id%>"/>
</td>
</tr>
@ -48,9 +49,6 @@ $("#tbc").stupidtable();
<input type="text" id="title" name="title" class="inputtext" onchange="onCircleChanged"/>
<span id="Err_cr_title" class="field-validation-valid error"></span>
<label for="isprivate"><b><%=Html.Translate("Private circle")%></b></label>
<input type="checkbox" name="isprivate" id="isprivate" onchange="onCircleChanged" />
<input type="button" id="btnnewcircle"
value="<%=Html.Translate("Create")%>" class="actionlink rowbtnct" />
<input type="button" id="btneditcircle"

Loading…