From: Bill Erickson Date: Thu, 7 May 2015 21:50:56 +0000 (-0400) Subject: web api preso cont. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=6090c7551861ea25135992c90ca2d6361d65d084;p=working%2Frandom.git web api preso cont. Signed-off-by: Bill Erickson --- diff --git a/api_presentation/web_apis.asciidoc b/api_presentation/web_apis.asciidoc index a4a945956..41f23dc5a 100644 --- a/api_presentation/web_apis.asciidoc +++ b/api_presentation/web_apis.asciidoc @@ -221,6 +221,44 @@ Received Data: { srfsh# request open-ils.pcrud open-ils.pcrud.retrieve.aou "ANONYMOUS", 1 --------------------------------------------------------------------------- +== PCRUD JavaScript Interface (pre-browser client) + +[source,js] +--------------------------------------------------------------------------- +var pcrud = new openils.PermaCrud(); + +pcrud.retrieve('aou', 1, {oncomplete : function(org) { ... }}); +pcrud.update(some_org, {oncomplete : function(resp) { ... }}); + +pcrud.search('aou', {parent_ou : 1}, { + oncomplete : function(r) { + var orgs = openils.Util.readResponse(r); + console.log('org units: ' + orgs); + } +}); + +--------------------------------------------------------------------------- + +== PCRUD JavaScript Interface (browser client) + + * Uses promises + * Defaults to streaming searches + +[source,js] +--------------------------------------------------------------------------- +egCore.pcrud.retrieve('aou', 1).then(function(org) { ... }); +egCore.pcrud.update(some_org).then(function(resp) { ... }); + +egCore.pcrud.search('aou', {parent_ou : 1}) +.then( + function() {...}, // oncomplete + function() {...}, // onerror + function(one_org) { // onresponse + console.log('one org unit: ' + one_org); + } +}); +--------------------------------------------------------------------------- + == When Not To Use PCRUD * PCRUD is powerful enough to implement most logic in the client, but @@ -274,6 +312,7 @@ open-ils.fielder.flattened_search --------------------------------------------------------------------------- + == Questions / Comments * Slides