File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 203203 })
204204 };
205205
206+ /**
207+ * Retrieve a single <?php echo $ tableName ; ?> with attributes matching the current <?php echo $ tableName ; ?> .
208+ *
209+ * @returns {*}
210+ */
211+ var findOne = function()
212+ {
213+ var findAttributes = attributes;
214+
215+ findAttributes['limit'] = 1;
216+
217+ return doAJAX(
218+ 'GET',
219+ '<?php echo $ tablePlurals [$ tableName ]; ?> /?' + $.param(findAttributes)
220+ ).then(function(result) {
221+
222+ if (result.data.length > 0) {
223+ var <?php echo $ tableName ; ?> = <?php echo $ tablePhpNames [$ tableName ]; ?> (result.data[i].Id);
224+
225+ for (var name in result.data[i]) {
226+ if (result.data[i].hasOwnProperty(name)) {
227+ var setter = "set" + name;
228+
229+ if (<?php echo $ tableName ; ?> .hasOwnProperty(setter)) {
230+ <?php echo $ tableName ; ?> [setter](result.data[i][name]);
231+ }
232+ }
233+ }
234+
235+ return <?php echo $ tableName ; ?> ;
236+ } else {
237+ return undefined;
238+ }
239+
240+ })
241+ };
242+
206243 /**
207244 * Perform the update or the create action for this <?php echo $ tableName ; ?> .
208245 *
You can’t perform that action at this time.
0 commit comments