* Circles.aspx: fixes circle updates
* yavsc.circles.js: * refactoring * fixes circle update
This commit is contained in:
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>
|
2015-09-10 Paul Schneider <paul@pschneider.fr>
|
||||||
|
|
||||||
* instdbws.sql:
|
* instdbws.sql:
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,23 @@
|
||||||
|
|
||||||
var errspanid="msg";
|
var errspanid="msg";
|
||||||
var CirclesApiUrl = apiBaseUrl + "/Circle";
|
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() {
|
function editNewCircle() {
|
||||||
if ($('#fncirc').hasClass('hidden')) $('#fncirc').removeClass('hidden')
|
if ($('#fncirc').hasClass('hidden')) $('#fncirc').removeClass('hidden')
|
||||||
|
|
@ -42,26 +57,30 @@ function removeCircle() {
|
||||||
$("#c_"+id).remove();
|
$("#c_"+id).remove();
|
||||||
},
|
},
|
||||||
statusCode: {
|
statusCode: {
|
||||||
400: function(data) {
|
400: onAjaxBadInput,
|
||||||
$.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/>");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error: function (xhr, ajaxOptions, thrownError) {
|
error: function (xhr, ajaxOptions, thrownError) {
|
||||||
if (xhr.status!=400)
|
if (xhr.status!=400)
|
||||||
Yavsc.message(xhr.status+" : "+xhr.responseText);
|
Yavsc.message(xhr.status+" : "+xhr.responseText);
|
||||||
else Yavsc.message(false);
|
else Yavsc.message(false);
|
||||||
}});
|
}}});
|
||||||
}
|
}
|
||||||
function modifyCircle() {
|
function modifyCircle() {
|
||||||
Yavsc.message(false);
|
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()
|
function addCircle()
|
||||||
|
|
@ -78,25 +97,14 @@ function addCircle()
|
||||||
$('<tr id="c_'+id+'"/>').addClass('selected row')
|
$('<tr id="c_'+id+'"/>').addClass('selected row')
|
||||||
.appendTo('#tbcb');
|
.appendTo('#tbcb');
|
||||||
|
|
||||||
$('<td>'+circle.title+' <br><i>'+
|
$('<td>'+circle.title+'</td>').attr('cid',id).click(selectCircle)
|
||||||
circle.members+
|
|
||||||
'</i></td></td>')
|
|
||||||
.appendTo('#c_'+id);
|
.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: {
|
statusCode: {
|
||||||
400: function(data) {
|
400: onAjaxBadInput
|
||||||
$.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/>");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
error: function (xhr, ajaxOptions, thrownError) {
|
error: function (xhr, ajaxOptions, thrownError) {
|
||||||
if (xhr.status!=400)
|
if (xhr.status!=400)
|
||||||
|
|
@ -104,3 +112,5 @@ function addCircle()
|
||||||
else Yavsc.message(false);
|
else Yavsc.message(false);
|
||||||
}});
|
}});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,14 +12,15 @@
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
<style>
|
||||||
|
.btnselcircle { cursor: pointer; }
|
||||||
|
</style>
|
||||||
<tbody id="tbcb">
|
<tbody id="tbcb">
|
||||||
<% int lc=0;
|
<% int lc=0;
|
||||||
foreach (var ci in (IEnumerable<CircleBase>) ViewData["Circles"]) { lc++; %>
|
foreach (var ci in (IEnumerable<CircleBase>) 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 cid="<%=ci.Id%>" style="cursor: pointer;" class="btnselcircle" >
|
<td cid="<%=ci.Id%>" class="btnselcircle"><%=ci.Title%></td>
|
||||||
<%=ci.Title%></td>
|
<td><input type="button" value="<%=Html.Translate("Remove")%>"
|
||||||
<td>
|
|
||||||
<input type="button" value="<%=Html.Translate("Remove")%>"
|
|
||||||
class="btnremovecircle actionlink" cid="<%=ci.Id%>"/>
|
class="btnremovecircle actionlink" cid="<%=ci.Id%>"/>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
@ -48,9 +49,6 @@ $("#tbc").stupidtable();
|
||||||
<input type="text" id="title" name="title" class="inputtext" onchange="onCircleChanged"/>
|
<input type="text" id="title" name="title" class="inputtext" onchange="onCircleChanged"/>
|
||||||
<span id="Err_cr_title" class="field-validation-valid error"></span>
|
<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"
|
<input type="button" id="btnnewcircle"
|
||||||
value="<%=Html.Translate("Create")%>" class="actionlink rowbtnct" />
|
value="<%=Html.Translate("Create")%>" class="actionlink rowbtnct" />
|
||||||
<input type="button" id="btneditcircle"
|
<input type="button" id="btneditcircle"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue