Add roadmap and fix some bugs on delte

This commit is contained in:
antifaz 2013-11-25 00:29:24 +01:00
parent 83f0c79564
commit beba17e871
6 changed files with 40 additions and 30 deletions

View file

@ -2,6 +2,8 @@
techrec
==========================================
BUG and roadmap
See roadmap for details
--------
Client
@ -56,6 +58,5 @@ JSON = {
'op': 'delete'
}
BUG
Da Salva button lo stato non va. Per il resto sembra funzionare.

View file

@ -129,14 +129,14 @@ function rec_new( )
// Bind the Delete Links
$("#"+rs_dellink(recid)).click(function(){
console.log("Remove " + rs_trxarea(recid) + "[ID"+recid+"]");
$("#"+rs_trxarea(recid)).remove();
alert("Premuto del link. Invio al server ?");
// $("#"+rs_trxarea(recid)).remove();
recDelete (recid,rs_trxarea(recid));
});
// FORM SUBMIT: THE REC IS STOPPEND AND MUST BE PROCESSED
$("#"+formid).submit(function(event){
// Immediately, mark the end time (stop action)
ChangeState(recid, trx_stopbut(recid) , trx_downbut(recid));
ChangeState(recid, trx_downbut(recid) , trx_endbut(recid));
// Force a Name
while (true) {
@ -180,6 +180,32 @@ function rec_new( )
console.log("New form has been built.");
}
/* Delete Record */
function recDelete ( recid, targetarea ) {
var formid = rs_formid( recid );
var dataString = "recid="+recid
console.log("Del rec: "+dataString);
var req_del = RecAjax("delete", dataString);
req_del.done (function(data) {
$.each(data, function(del_key, del_val) {
console.log("K:V " + del_key +":"+del_val );
if (del_key == "message") {
$("#"+targetarea).fadeOut( 200, function() { $(this).remove(); });
console.log("delete area "+rs_trxarea(key));
}
if (del_key == "error") {
alert("Impossibile cancellare elemento:\n" + del_val );
}
});
});
}
/* New Record */
function recNew ( recid ) {
var formid = rs_formid( recid );
@ -187,7 +213,6 @@ function recNew ( recid ) {
console.log("New rec: "+dataString);
var request = RecAjax("create", dataString);
request.done( function(data) {
@ -309,3 +334,5 @@ function ChangeState(recid, from, to) {
console.log("ChangeState: set '"+rs_inputend(recid)+ "' to "+ displayDate );
}
} // End function ChangeState

View file

@ -42,26 +42,8 @@ $(document).ready(function(){
$("#"+rs_trxarea(key)).html(str);
$("#delete-"+val.id).click(function(evt) {
evt.preventDefault();
console.log("Delete request for ID "+ val.id);
var dataString = "id="+val.id
var req_del = RecAjax("delete", dataString);
recDelete(val.recid, rs_trxarea(key) );
req_del.done (function(data) {
$.each(data, function(del_key, del_val) {
console.log("K:V " + del_key +":"+del_val );
if (del_key == "message") {
$("#"+rs_trxarea(key)).fadeOut( 500, function() { $(this).remove(); });
console.log("delete area "+rs_trxarea(key));
}
if (del_key == "error") {
alert("Impossibile cancellare elemento");
}
});
});
}
); // End of delete link handler

View file

@ -85,11 +85,11 @@ class RecServer:
def delete( self, recid = None ):
self.enable_cors()
req = dict( request.POST.allitems() )
if not req.has_key( "id" ):
logging.info("Server: request delete %s " % ( req ) )
if not req.has_key( "recid" ):
return self.rec_err("No valid ID")
print "Server request delete for id %s " % ( req["id"] )
if self.db.delete( req["id"] ):
if self.db.delete( req["recid"] ):
return self.rec_msg("DELETE OK")
else:
return self.rec_err("DELETE error: %s" % (self.db.get_err()))

Binary file not shown.

View file

@ -151,9 +151,9 @@ class RecDB:
""""
DELETE RECORD
"""
def delete(self,_id):
def delete(self,recid):
_rlist = self._search(_id=_id)
_rlist = self._search(recid=recid)
if len(_rlist) == 0:
logging.info("DB: Delete: no record found!")