]> Frank Brehm's Git Trees - books.git/commitdiff
Mit Filter für Bücherliste angefangen
authorFrank Brehm <frank@brehm-online.com>
Sun, 6 Dec 2009 00:13:32 +0000 (00:13 +0000)
committerFrank Brehm <frank@brehm-online.com>
Sun, 6 Dec 2009 00:13:32 +0000 (00:13 +0000)
lib/FrBr/Books/Controller/Books.pm
lib/FrBr/Books/Util/User.pm
root/src/books/filter.tt2 [new file with mode: 0644]

index 9f0e22690bb121d70f419e66569a0f8cee9bc31b..4af0b778d3536a473aee0cf631c64d262b8e4dae 100644 (file)
@@ -56,6 +56,8 @@ sub auto : Private {
 
     $c->stash->{'return_target_action'} = $c->web_path("/books");
 
+       $c->stash->{'booklist_filter'} = $c->session->{'booklist_filter'} if $c->session->{'booklist_filter'};
+
     $c->stash->{'cssfiles'} = [] unless $c->stash->{'cssfiles'};
     push @{$c->stash->{'cssfiles'}}, 'books/styles.css';
 
@@ -182,6 +184,36 @@ sub list : Local {
 
 #-------------------------------------------------------
 
+=head2 filter( )
+
+Stellt ein Formular zu Verfügung, mit dem Filterkriterien
+für die Buchliste definiert werden.
+
+=cut
+
+sub filter : Local {
+
+    my ($self, $c) = @_;
+    my $K = ( caller(0) )[3] . "(): ";
+    $c->log->debug( $K . "aufgerufen." ) if $c->stash->{'debug_level'} > 2;
+
+    $self->add_booklist_menu($c);
+
+    push @{ $c->stash->{'menu_path'} }, {
+        'path' => $c->web_path("/books/filter"),
+        'name' => "Filter"
+    };
+
+    $self->prepare_data_structures($c);
+
+    $c->stash->{'template'} = 'books/filter.tt2';
+
+    return 1;
+
+}
+
+#-------------------------------------------------------
+
 =head2 sorting
 
 Stellt ein Formular zum Ändern der Sortierkriterien der Bücherliste zur Verfügung.
index addb7f36d197a2be1c54db64657c8f848981d0b1..aa890a2ccd0f7485953ba1c008ec5eb110d7c856 100644 (file)
@@ -70,6 +70,9 @@ sub save_user_prefs {
     # Sortierkriterien der Buchliste
     $prefs->{'book_order_criteria'} = $c->session->{'book_order_criteria'} if $c->session->{'book_order_criteria'};
 
+    # Filter für Buchliste speichern
+    $prefs->{'booklist_filter'} = $c->session->{'booklist_filter'} if $c->session->{'booklist_filter'};
+
     # Anzahl der angezeigten zugeordneten Bücher in einer anderen Liste
     $prefs->{'books_in_other_list'} = $c->stash->{'books_in_other_list'};
 
@@ -136,6 +139,10 @@ sub restore_user_prefs {
     # Sortierkriterien der Buchliste
     $c->session->{'book_order_criteria'} = $prefs->{'book_order_criteria'} if $prefs->{'book_order_criteria'};
 
+    # Filter für Buchliste speichern
+    $c->session->{'booklist_filter'} = undef;
+    $c->session->{'booklist_filter'} = $prefs->{'booklist_filter'} if $prefs->{'booklist_filter'};
+
     return 1;
 
 }
diff --git a/root/src/books/filter.tt2 b/root/src/books/filter.tt2
new file mode 100644 (file)
index 0000000..cc397a4
--- /dev/null
@@ -0,0 +1,91 @@
+<!-- [%#
+  ** Template fuer Formular zum Setzen eines Filters in der Büchereliste
+  **
+  ** vim: noai : ts=4 fenc=utf-8 filetype=html expandtab :
+  **
+  ** $Id$
+  ** $URL$
+  ** -%]
+
+  Formular zum Setzen eines Filters in der Büchereliste
+
+-->
+
+<script type="text/javascript">
+
+function set_filter_disabled() {
+    // alert( "Filter wurden deaktiviert." );
+    document.booklist_filter_form.title_name_where.disabled = true;
+    document.booklist_filter_form.title_name.disabled = true;
+    document.booklist_filter_form.autoren_ids.disabled = true;
+}
+
+function set_filter_enabled() {
+    // alert( "Filter wurden aktiviert." );
+    document.booklist_filter_form.title_name_where.disabled = false;
+    document.booklist_filter_form.title_name.disabled = false;
+    document.booklist_filter_form.autoren_ids.disabled = false;
+}
+
+</script>
+
+<form method="post" name="booklist_filter_form" action="[% self_url %]">
+<table class="ftable" cellspacing="0">
+  <tr>
+    <th class="title">Filter für die Buchliste</th>
+  </tr><tr>
+    <td class="empty"></td>
+  </tr><tr>
+    <td><input type="radio" id="filter_disabled" name="filter_enabled" onclick="set_filter_disabled();"
+               value="off"[% IF NOT booklist_filter %] checked[% END %]>&nbsp;<label
+               for="filter_disabled">Filter deaktiviert - es werden alle Bücher angezeigt</label></td>
+  </tr><tr>
+    <td><input type="radio" id="filter_enabled" name="filter_enabled"onclick="set_filter_enabled();"
+               value="on"[% IF booklist_filter %] checked[% END %]>&nbsp;<label
+               for="filter_enabled">Filter aktiviert - es werden die Bücher entsprechend ihrer Auswahl angezeigt</label></td>
+  </tr><tr>
+    <td><fieldset id="filter_fields">
+          <legend><b>Filterkriterien</b></legend>
+          <table class="ftable" cellspacing="0">
+            <tr>
+              <th><label for="title_name">Buchtitel/Untertitel/Originaltitel:</label>&nbsp;</th>
+              <td><select size="1" name="title_name_where">
+                    <option value="is"[% IF booklist_filter.title_name_where != "starts_with" AND booklist_filter.title_name_where != "contains" %] selected[% END %]>ist</option>
+                    <option value="starts_with"[% IF booklist_filter.title_name_where == "starts_with" %] selected[% END %]>beginnt mit</option>
+                    <option value="contains"[% IF booklist_filter.title_name_where == "contains" %] selected[% END %]>enthält</option>
+                  </select>&nbsp;
+                  <input name="title_name" id="title_name" type="text" size="50" value="[% booklist_filter.title_name %]"></td>
+            </tr><tr>
+              <th><label for="autoren_ids">Autor:</label>&nbsp;</th>
+              <td><select name="autoren_ids" id="autoren_ids" size="12" multiple>
+                    <option value="">-- Autor oder Autoren wählen --</option>[% FOR autor_id IN autor_array_sorted %]
+                    <option value="[% autor_id %]"[% IF booklist_filter.autoren AND booklist_filter.autoren.$autor_id %] selected[% END %] >[% autor_list.$autor_id %]</option>
+                  [% END %]</select></td>
+            </tr>
+          </table>
+        </fieldset>
+  </tr><tr>
+    <td class="empty"></td>
+  </tr><tr>
+    <th class="button"><input type="submit" name="do_save" value="  OK  " /></th>
+  </tr>
+</table>
+</form>
+
+<script type="text/javascript">
+
+[% IF booklist_filter %]set_filter_enabled();[% ELSE %]set_filter_disabled();[% END %] 
+
+</script>
+
+[%- IF error_message %]
+<div class="error">
+<span class="bold">Fehler:</span>&nbsp;[% error_message %]
+</div>
+[% END -%]
+
+<br />
+<div class="back">
+<h2><a href="[% path('/books/list') %]">[% 'Zurück' %]</a></h2>
+</div>
+<br />