liquid_feedback_frontend

changeset 146:77260f05fd4b

implement advanced date searches

date-date in range
since: date
age: 10 timestamp
author Daniel Poelzleithner <poelzi@poelzi.org>
date Thu Oct 07 03:34:19 2010 +0200 (2010-10-07)
parents 90520c9fca44
children f5692aafc85b
files app/main/timeline/index.lua env/util/gregor.lua locale/help/timeline.index.de.txt locale/help/timeline.index.en.txt static/gregor.js/gregor.js
line diff
     1.1 --- a/app/main/timeline/index.lua	Thu Oct 07 00:35:48 2010 +0200
     1.2 +++ b/app/main/timeline/index.lua	Thu Oct 07 03:34:19 2010 +0200
     1.3 @@ -138,7 +138,7 @@
     1.4          }
     1.5      
     1.6          ui.script{ static = "gregor.js/gregor.js" }
     1.7 -        util.gregor("timeline_search_date", "document.getElementById('timeline_search_date').form.submit();")
     1.8 +        util.gregor("timeline_search_date", true)
     1.9      
    1.10      
    1.11          ui.link{
    1.12 @@ -337,7 +337,22 @@
    1.13        if date == "last_24h" then
    1.14          tmp:add_where{ "occurrence > now() - '24 hours'::interval" }
    1.15        else
    1.16 -        tmp:add_where{ "occurrence::date = ?::date", date }
    1.17 +        local start,stop = string.gmatch(date, "(%d+-%d+-%d+):(%d+-%d+-%d+)")()
    1.18 +        if start and stop then
    1.19 +          tmp:add_where{ "occurrence::date >= ?::date AND occurrence::date <= ?::date", start, stop }
    1.20 +        else
    1.21 +          local age = string.gmatch(date, "age:(.+)")()
    1.22 +          if age then
    1.23 +            tmp:add_where{ "occurrence >= now() - ?::interval", age }
    1.24 +          else 
    1.25 +            local since = string.gmatch(date, "since:%s*(%d+-%d+-%d+)%s*")()
    1.26 +            if since then
    1.27 +              tmp:add_where{ "occurrence::date >= ?::date", since }
    1.28 +            else
    1.29 +              tmp:add_where{ "occurrence::date = ?::date", date }
    1.30 +            end
    1.31 +          end
    1.32 +        end
    1.33        end
    1.34        tmp
    1.35          :left_join("draft", nil, "draft.id = timeline.draft_id")
     2.1 --- a/env/util/gregor.lua	Thu Oct 07 00:35:48 2010 +0200
     2.2 +++ b/env/util/gregor.lua	Thu Oct 07 03:34:19 2010 +0200
     2.3 @@ -1,4 +1,4 @@
     2.4 -function util.gregor(el_id)
     2.5 +function util.gregor(el_id, relaxed)
     2.6    ui.script{ script =
     2.7         'gregor_addGui({' ..
     2.8            'element_id: "' .. el_id .. '",' ..
     2.9 @@ -6,6 +6,7 @@
    2.10            'weekday_names: ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],' ..
    2.11            'week_mode: "iso",' ..
    2.12            'week_numbers: "left",' ..
    2.13 +          (relaxed and 'relaxed: true,' or '') ..
    2.14          '});'
    2.15    }
    2.16 -end
    2.17 \ No newline at end of file
    2.18 +end
     3.1 --- a/locale/help/timeline.index.de.txt	Thu Oct 07 00:35:48 2010 +0200
     3.2 +++ b/locale/help/timeline.index.de.txt	Thu Oct 07 03:34:19 2010 +0200
     3.3 @@ -1,4 +1,9 @@
     3.4  =Zeitachse=
     3.5 -Hier kannst du dich über Ereignisse im System informieren. Über Filter-Einstellungen kannst du steuern, welche  Ereignisarten dir angezeigt werden sollen. Du kannst die Anzeige für einzelne Ereignisarten auch von weiteren Bedingungen abhängig machen. Um zum Beispiel alle Themen anzuzeigen, die nach Erreichen des Unterstützerquorums in den Status ,,Diskussion'' gelangen, wählst du das Themen-Ereignis ,,Thema akzeptiert'' und kannst zum Beispiel zusätzlich festlegen, dass diese Ereignisse nur dann angezeigt werden sollen, wenn du Mitglied des jeweiligen Themenbereichs bist. 
     3.6 +Hier kannst du dich über Ereignisse im System informieren. Über Filter-Einstellungen kannst du steuern, welche  Ereignisarten dir angezeigt werden sollen. Du kannst die Anzeige für einzelne Ereignisarten auch von weiteren Bedingungen abhängig machen. Um zum Beispiel alle Themen anzuzeigen, die nach Erreichen des Unterstützerquorums in den Status ,,Diskussion'' gelangen, wählst du das Themen-Ereignis ,,Thema akzeptiert'' und kannst zum Beispiel zusätzlich festlegen, dass diese Ereignisse nur dann angezeigt werden sollen, wenn du Mitglied des jeweiligen Themenbereichs bist.
     3.7 +Du kannst im Datumsfeld spezielle Anfragen benutzen:
     3.8 +- 2010-08-13            -> //Sucht nach einem Tag//
     3.9 +- 2010-08-13:2010-08-16 -> //Ergebnisse die zwischen zwei Tage fallen//
    3.10 +- age:10 days           -> //Einem alter von Ereignissen (minutes, hours, days, weeks, months)//
    3.11 +- since:2010-08-13      -> //Seit dem gegebenen Datum//
    3.12  =Filter speichern=
    3.13  Du kannst Filtereinstellungen unter einem Namen abspeichern und die jeweilige Abfrage dann mit einem Klick ausführen. Wenn du kein anderes Datum auswählst, beziehen sich Abfragen standardmäßig auf heute.
     4.1 --- a/locale/help/timeline.index.en.txt	Thu Oct 07 00:35:48 2010 +0200
     4.2 +++ b/locale/help/timeline.index.en.txt	Thu Oct 07 03:34:19 2010 +0200
     4.3 @@ -1,4 +1,9 @@
     4.4  =Timeline=
     4.5  Here you can get information about events in the system. Using filter settings you can control which type of events will be displayed for you. You can also define conditions for displaying individual event types. If you want to display e.g. all issues, that reach the support quorum and are moved to the ,,Discussion'' state, you can select the issue event ,,Issue accepted'' and specify additionally for these events to be displayed only if you are a member of the respective area. 
     4.6 +There are special queries in the date field you can use:
     4.7 +- 2010-08-13            -> //events on a specific date//
     4.8 +- 2010-08-13:2010-08-16 -> //searches for all events between those dates//
     4.9 +- age:10 days           -> //searches for events in the last 10 days//
    4.10 +- since:2010-08-13      -> //since the date given//
    4.11  =Save filter=
    4.12  You can save filter settings under a name and run the respective request with a single click. If you do not specify any date the default date for your requests is today.
     5.1 --- a/static/gregor.js/gregor.js	Thu Oct 07 00:35:48 2010 +0200
     5.2 +++ b/static/gregor.js/gregor.js	Thu Oct 07 03:34:19 2010 +0200
     5.3 @@ -86,7 +86,9 @@
     5.4  // function is always called once with the pre-selected date (or with null,
     5.5  // if no date is initially selected). Whenever the selected date is changed
     5.6  // or unselected later, the callback function is called again with the new
     5.7 -// date (or with null, in case of deselection).
     5.8 +// date (or with null, in case of deselection). When the relaxed argument is set
     5.9 +// the calendar will not normalize the parsed date. Thats usefull if you wan't to
    5.10 +// allow relaxed input.
    5.11  //
    5.12  // EXAMPLE:
    5.13  //
    5.14 @@ -777,7 +779,6 @@
    5.15      element.value = gregor_formatDate(state.format, date);
    5.16      if (select_callback) select_callback(date);
    5.17    };
    5.18 -
    5.19    // function to parse text field and update calendar sheet state
    5.20    var updateSheet = function(terminated) {
    5.21      var date = gregor_parseDate(
    5.22 @@ -793,7 +794,9 @@
    5.23  
    5.24    // Initial synchronization
    5.25    if (state.selected === undefined) updateSheet(true);
    5.26 -  element.value = gregor_formatDate(state.format, state.selected);
    5.27 +  if (!state.relaxed)
    5.28 +    element.value = gregor_formatDate(state.format, state.selected);
    5.29 +
    5.30    if (select_callback) select_callback(state.selected);
    5.31  
    5.32    // variables storing popup status
    5.33 @@ -828,7 +831,8 @@
    5.34      window.setTimeout(function() {
    5.35        if (visible && !focus && !protection) {
    5.36          updateSheet(true);
    5.37 -        element.value = gregor_formatDate(state.format, state.selected);
    5.38 +        if(!state.relaxed)
    5.39 +          element.value = gregor_formatDate(state.format, state.selected);
    5.40          if (select_callback) select_callback(state.selected);
    5.41          state.element.parentNode.removeChild(state.element);
    5.42          visible = false;

Impressum / About Us