# HG changeset patch # User Daniel Poelzleithner # Date 1286415259 -7200 # Node ID 77260f05fd4bc02e1974c526b75d63086358479c # Parent 90520c9fca445f00fed49c282873203b9de90b53 implement advanced date searches date-date in range since: date age: 10 timestamp diff -r 90520c9fca44 -r 77260f05fd4b app/main/timeline/index.lua --- a/app/main/timeline/index.lua Thu Oct 07 00:35:48 2010 +0200 +++ b/app/main/timeline/index.lua Thu Oct 07 03:34:19 2010 +0200 @@ -138,7 +138,7 @@ } ui.script{ static = "gregor.js/gregor.js" } - util.gregor("timeline_search_date", "document.getElementById('timeline_search_date').form.submit();") + util.gregor("timeline_search_date", true) ui.link{ @@ -337,7 +337,22 @@ if date == "last_24h" then tmp:add_where{ "occurrence > now() - '24 hours'::interval" } else - tmp:add_where{ "occurrence::date = ?::date", date } + local start,stop = string.gmatch(date, "(%d+-%d+-%d+):(%d+-%d+-%d+)")() + if start and stop then + tmp:add_where{ "occurrence::date >= ?::date AND occurrence::date <= ?::date", start, stop } + else + local age = string.gmatch(date, "age:(.+)")() + if age then + tmp:add_where{ "occurrence >= now() - ?::interval", age } + else + local since = string.gmatch(date, "since:%s*(%d+-%d+-%d+)%s*")() + if since then + tmp:add_where{ "occurrence::date >= ?::date", since } + else + tmp:add_where{ "occurrence::date = ?::date", date } + end + end + end end tmp :left_join("draft", nil, "draft.id = timeline.draft_id") diff -r 90520c9fca44 -r 77260f05fd4b env/util/gregor.lua --- a/env/util/gregor.lua Thu Oct 07 00:35:48 2010 +0200 +++ b/env/util/gregor.lua Thu Oct 07 03:34:19 2010 +0200 @@ -1,4 +1,4 @@ -function util.gregor(el_id) +function util.gregor(el_id, relaxed) ui.script{ script = 'gregor_addGui({' .. 'element_id: "' .. el_id .. '",' .. @@ -6,6 +6,7 @@ 'weekday_names: ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],' .. 'week_mode: "iso",' .. 'week_numbers: "left",' .. + (relaxed and 'relaxed: true,' or '') .. '});' } -end \ No newline at end of file +end diff -r 90520c9fca44 -r 77260f05fd4b locale/help/timeline.index.de.txt --- a/locale/help/timeline.index.de.txt Thu Oct 07 00:35:48 2010 +0200 +++ b/locale/help/timeline.index.de.txt Thu Oct 07 03:34:19 2010 +0200 @@ -1,4 +1,9 @@ =Zeitachse= -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. +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. +Du kannst im Datumsfeld spezielle Anfragen benutzen: +- 2010-08-13 -> //Sucht nach einem Tag// +- 2010-08-13:2010-08-16 -> //Ergebnisse die zwischen zwei Tage fallen// +- age:10 days -> //Einem alter von Ereignissen (minutes, hours, days, weeks, months)// +- since:2010-08-13 -> //Seit dem gegebenen Datum// =Filter speichern= 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. diff -r 90520c9fca44 -r 77260f05fd4b locale/help/timeline.index.en.txt --- a/locale/help/timeline.index.en.txt Thu Oct 07 00:35:48 2010 +0200 +++ b/locale/help/timeline.index.en.txt Thu Oct 07 03:34:19 2010 +0200 @@ -1,4 +1,9 @@ =Timeline= 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. +There are special queries in the date field you can use: +- 2010-08-13 -> //events on a specific date// +- 2010-08-13:2010-08-16 -> //searches for all events between those dates// +- age:10 days -> //searches for events in the last 10 days// +- since:2010-08-13 -> //since the date given// =Save filter= 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. diff -r 90520c9fca44 -r 77260f05fd4b static/gregor.js/gregor.js --- a/static/gregor.js/gregor.js Thu Oct 07 00:35:48 2010 +0200 +++ b/static/gregor.js/gregor.js Thu Oct 07 03:34:19 2010 +0200 @@ -86,7 +86,9 @@ // function is always called once with the pre-selected date (or with null, // if no date is initially selected). Whenever the selected date is changed // or unselected later, the callback function is called again with the new -// date (or with null, in case of deselection). +// date (or with null, in case of deselection). When the relaxed argument is set +// the calendar will not normalize the parsed date. Thats usefull if you wan't to +// allow relaxed input. // // EXAMPLE: // @@ -777,7 +779,6 @@ element.value = gregor_formatDate(state.format, date); if (select_callback) select_callback(date); }; - // function to parse text field and update calendar sheet state var updateSheet = function(terminated) { var date = gregor_parseDate( @@ -793,7 +794,9 @@ // Initial synchronization if (state.selected === undefined) updateSheet(true); - element.value = gregor_formatDate(state.format, state.selected); + if (!state.relaxed) + element.value = gregor_formatDate(state.format, state.selected); + if (select_callback) select_callback(state.selected); // variables storing popup status @@ -828,7 +831,8 @@ window.setTimeout(function() { if (visible && !focus && !protection) { updateSheet(true); - element.value = gregor_formatDate(state.format, state.selected); + if(!state.relaxed) + element.value = gregor_formatDate(state.format, state.selected); if (select_callback) select_callback(state.selected); state.element.parentNode.removeChild(state.element); visible = false;