/[SQLSession]/trunk/share/web/templates/fragments/enter_query
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/share/web/templates/fragments/enter_query

Parent Directory Parent Directory | Revision Log Revision Log


Revision 84 - (hide annotations)
Tue Jan 30 14:08:47 2007 UTC (17 years, 4 months ago) by dpavlin
File size: 1858 byte(s)
use on_database parameter for database id throughout all code,
implement save query using tangents and continuations
1 dpavlin 78 <%args>
2     $sth => undef
3     $q => undef
4     $max_rows => 100
5 dpavlin 84
6     $sql_query => undef
7     $on_database => undef
8 dpavlin 78 </%args>
9     <%init>
10    
11 dpavlin 84 $sql_query = $q->sql_query if ($q && $q->can('sql_query'));
12     $on_database = $q->on_database->id if ($q && $q->can('on_database'));
13    
14 dpavlin 78 my $query = Jifty->web->new_action(
15     class => 'DoSQL',
16     moniker => 'query',
17     );
18    
19     my $result = Jifty->web->response->result('query');
20     $sth = $result->content('sth') if $result and !defined $sth;
21    
22     my $edit = Jifty->web->current_user->role('edit');
23     warn $edit ? 'edit mode for SQL' : 'student mode';
24    
25     </%init>
26    
27     % if ($q && $q->can('note')) {
28     <div class="sql-note"><% $q->note %></div>
29     % }
30    
31     <% Jifty->web->form->start() %>
32     % if ( Jifty->web->current_user->id ) {
33     <% $query->form_field('sql_query',
34 dpavlin 84 default_value => $sql_query,
35 dpavlin 78 cols => 80,
36     rows => 12,
37     ) %>
38     % } else {
39 dpavlin 84 <% $query->hidden('sql_query', $sql_query ) %>
40     <% $query->form_value('sql_query', default_value => $sql_query ) %>
41 dpavlin 78 % }
42    
43     <div class="database-schema">
44     <%perl>
45     my $db = SQLSession::Model::Database->new();
46 dpavlin 84 $db->load_by_cols( id => $on_database );
47 dpavlin 78 my $name = $db->dsn;
48     $name =~ s/^.*dbname=//;
49     $m->out("<a href=\"/static/spy/$name/index.html\" target=\"_spy\">$name shema</a>");
50     </%perl>
51     </div>
52    
53     % if ( $edit ) {
54 dpavlin 84 <% $query->form_field('on_database', default_value => $on_database ) %>
55 dpavlin 78 % } else {
56    
57     <!-- hidden database -->
58 dpavlin 84 <% $query->hidden('on_database', $on_database ) %>
59     <% $query->form_value('on_database', default_value => $on_database ) %>
60 dpavlin 78
61     % }
62    
63     <div class="submit_button">
64     <% $query->button( label => 'Try it!' ) %>
65    
66 dpavlin 84 % if ($sth && $edit) {
67     <% Jifty->web->tangent(
68     label => 'Save query',
69     onclick => {
70     region => 'query',
71     replace_with => '/fragments/save_query',
72     args => {
73     sql_query => $query->argument_value('sql_query'),
74     on_database => $query->argument_value('on_database'),
75     },
76     #toggle => 1,
77     },
78     as_button => 1,
79     ) %>
80     % }
81 dpavlin 78
82 dpavlin 84 </div>

  ViewVC Help
Powered by ViewVC 1.1.26