var selectedRow = null; var columns = null; var primaryKeyColumn = 'id'; var rowData = null; function deleteRow(data) { var table = $('table'); var tableName = table[table.selectedIndex].value; hakano.util.MessageBroker.queue({type:'remote:seamless.'+tableName+'.delete.request',data:{id:getPrimaryKey(data)}}); selectedRow = null; hakano.util.MessageBroker.queue({type:'local:search.table.nonselected',data:{}}); } function updateFromDelete(data) { var id = data['id']; $$('#search_results_table td.primarykey').each(function(td) { var value = td.innerHTML; if (value == id) { var parent = td.parentNode; Effect.Fade(parent, { afterFinish: function() { var p = parent.parentNode; p.removeChild(parent); $('search_count').innerHTML = parseInt($('search_count').innerHTML) - 1; $('search_total').innerHTML = parseInt($('search_total').innerHTML) - 1; } }); throw $break; } }); } function getPrimaryKey() { var idx = selectedRow.getAttribute('idx'); var datarow = rowData[parseInt(idx)]; return datarow[primaryKeyColumn||'id'] || ''; } function loadModels (data) { var models = data['models']; if (models.length > 0) { $('table_name').innerHTML = models[0].name; loadTableAssembly(models[0].model); } } function loadTableAssembly (tableName) { var request = 'remote:seamless.'+tableName+'.assembly.request'; hakano.util.MessageBroker.queue({type:request,data:{}}); } function loadColumns (data) { columns = data['columns']; refreshData(); } function refreshData() { var table = $('table'); var tableName = table[table.selectedIndex].value; hakano.util.MessageBroker.queue({type:'remote:seamless.'+tableName+'.list.request',data:{limit:10}}); } function displayRecord(edit) { var html = ''; var table = $('table'); var tableName = table[table.selectedIndex].value; if (edit) { var req = 'remote:seamless.' + tableName + '.update.request'; var resp = 'remote:seamless.' + tableName + '.update.response'; html+='
"; } $('search_results_table_container').innerHTML = html; Seamless.wire($('search_results_table_container'),window,false,true); } function restoreTable () { if (rowData) { loadTable({rows:rowData}); } } function loadTable (data) { try { var rows = data['rows']; if (!rows) return; var html = "' + ( rows[c][col.name] || '') + ' | '; if (idx >= 5) throw $break; }); html+=''; } html+='