Commit 5dd562c1 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Simplify the proxy Direct.js by using request.jsonData.

parent a280c1ce
......@@ -472,7 +472,8 @@ class DbSvc(BaseSvc):
table = db[tablename]
# Abort the transaction is at least one record does not exists
for rec_id in arg[ROOT]:
for record in arg[ROOT]:
rec_id = record[table_id]
if not table[rec_id]:
otd = {"success": False,
"errors": RECORD_NOT_IN_DB % (rec_id, tablename),
......@@ -480,7 +481,8 @@ class DbSvc(BaseSvc):
return otd
# delete records
for rec_id in arg[ROOT]:
for record in arg[ROOT]:
rec_id = record[table_id]
try:
rep = db(table.id == rec_id).delete()
......
......@@ -83,8 +83,7 @@ Ext.define('Dbui.data.proxy.Direct', {
"use strict";
var me = this,
action, api, args, data, fieldId, i, fn, params, records,
request, writer;
action, api, args, fieldId, i, fn, params, request, writer;
if (!me.methodsResolved) {
me.resolveMethods();
......@@ -116,35 +115,18 @@ Ext.define('Dbui.data.proxy.Direct', {
case 'create':
fieldId = Dbui.encodeField(params.tableName, 'id');
params.records = [];
records = request.getRecords();
for (i = 0; i < records.length; i += 1) {
data = records[i].getData();
delete data[fieldId];
params.records.push(data);
params.records = request.getJsonData();
for (i = 0; i < params.records.length; i += 1) {
delete params.records[i][fieldId];
}
break;
case 'update':
params.records = [];
records = request.getRecords();
for (i = 0; i < records.length; i += 1) {
data = records[i].getData();
params.records.push(data);
}
params.records = request.getJsonData();
break;
case 'destroy':
fieldId = Dbui.encodeField(params.tableName, 'id');
params.records = [];
records = request.getRecords();
for (i = 0; i < records.length; i += 1) {
data = records[i].getData();
params.records.push(data[fieldId]);
}
params.records = request.getJsonData();
break;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment