Skip to content

Commit

Permalink
Item11871: small cleanups
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/SqlGridPlugin@14845 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
KipLubliner authored and KipLubliner committed May 18, 2012
1 parent e01f15e commit 9a18ef7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 23 deletions.
18 changes: 6 additions & 12 deletions lib/Foswiki/Plugins/SqlGridPlugin.pm
Expand Up @@ -92,7 +92,7 @@ sub initPlugin {

sub loadSql {
my $sql = $_[0];
Foswiki::Plugins::SqlGridPlugin::SqlParser::parse($sql);
return Foswiki::Plugins::SqlGridPlugin::SqlParser::parse($sql);
}

sub SQLGRID {
Expand All @@ -118,17 +118,15 @@ sub SQLGRID {
$params->{fromwhere_params_connectorparam} = $params->remove('sqlparams') || '';

my $theSqlQuery = $params->{sql} || '';
my $h = loadSql($theSqlQuery);
while( my ($k,$v) = each %$h) {
$params->{$k} = $v;
if ($theSqlQuery) {
my $h = loadSql($theSqlQuery);
while( my ($k,$v) = each %$h) {
$params->{$k} = $v;
}
}

# SMELL Think that this is dead code.
my $ondblClickRow = $params->remove('ondblClickRow');

my $table = $params->remove('table');
my $dbconn = $params->{'dbconn_connectorparam'};
# my $idcol = $params->{'_conn_idcol'};

my $editform = $params->{'editform'} || '';
my $addform = $params->{'addform'} || '';
Expand All @@ -148,10 +146,6 @@ EOQ
## # TODO also check in %MAINWEB% first
# my $prefix = "%SCRIPTURL{view}%/%SYSTEMWEB%/SqlGridPluginDialogs?skin=text";

# my $addArgs;
# my $editArgs = "requireSelection: true, gridId: '$id', form: 'http://127.0.0.1:8080/fwdev/Sandbox/GothamsPlayerForms?skin=text&section=edit_dialog'";
# my $delArgs = "requireSelection: true, gridId: '$id', form: '${prefix};section=confirm_dialog;title=Delete;message=Not%20Implemented'";

my $editScript = '';
if ($editform) {
my %editArgs = ( requireSelection => "true", gridId => "'$id'" );
Expand Down
10 changes: 10 additions & 0 deletions lib/Foswiki/Plugins/SqlGridPlugin/SqlParser.pm
Expand Up @@ -6,6 +6,16 @@ use HOP::Lexer 'string_lexer';

#use constant DEBUG => 1; # toggle me

=begin TML
---+++ parse($sql)
Parses an SQL expression and returns a hashtable that contains:
* fromwhere_connectorparam - the part of the SQL query after 'from'.
* columns - a comma-separated list of columns.
* col_${col}_expr_connectorparam - for each column, the sql expression for that column.
=cut

sub parse {
my $sql = $_[0];
#print "PARSING: $sql\n"
Expand Down
11 changes: 0 additions & 11 deletions pub/System/SqlGridPlugin/gridfuncs.js
Expand Up @@ -20,15 +20,13 @@ function sqlgrid_showForm(args) {
}

var rowData = selrow ? $('#' + gridId).jqGrid('getRowData', selrow) : [];
// alert ('selrow ' + selrow);

href += ';_grid_id=' + gridId;
href += ';_selected_row=' + selrow;
href += ';formAction=' + formAction;
for (var k in rowData) {
href += ';col_' + k + '=' + encodeURIComponent(rowData[k]);
}
// alert(href);

$.get(href, function(content) {
var $content = $(content);
Expand All @@ -38,27 +36,18 @@ function sqlgrid_showForm(args) {
$content.data("autoOpen", true);

});

}

function sqlgrid_runFormAction(popup, gridId, formAction) {

// alert('update time for' + gridId);
// debugger;
// var href = sqlPluginObjs[gridId].updateHref;
var href = formAction;
// alert(href);
var $inputs = $(popup).find(':input');
$inputs.each(function() {
if (this.name) {
href += ";" + this.name + "=" + encodeURIComponent(this.value);
}
});
// alert(href);
$.get(href, function(content) {
debugger;
$(popup).dialog("close");
// $('#'+gridId)[0].clearToolbar();
$('#'+gridId).trigger("reloadGrid");
});
}

0 comments on commit 9a18ef7

Please sign in to comment.