plugins/tasklist

Aleksander Machniak machniak at kolabsys.com
Tue Feb 17 21:13:49 CET 2015


 plugins/tasklist/skins/larry/print.css            |   94 ++++++++++++++++++++++
 plugins/tasklist/skins/larry/templates/print.html |   23 +++++
 plugins/tasklist/tasklist.js                      |   59 +++++++++++++
 plugins/tasklist/tasklist.php                     |   39 +++++++++
 4 files changed, 214 insertions(+), 1 deletion(-)

New commits:
commit 7286971422cbd7a2576365b3f68557f9e4c157bf
Author: Aleksander Machniak <machniak at kolabsys.com>
Date:   Tue Feb 17 11:16:15 2015 -0500

    Implemented tasks list printing (#4344)

diff --git a/plugins/tasklist/skins/larry/print.css b/plugins/tasklist/skins/larry/print.css
new file mode 100644
index 0000000..3117a2b
--- /dev/null
+++ b/plugins/tasklist/skins/larry/print.css
@@ -0,0 +1,94 @@
+/*** Printing styles for Tasklist plugin ***/
+
+body {
+	margin: 0;
+	color: #000;
+	background: #fff;
+}
+
+body, td, th, div, p, h3, select, input, textarea {
+	font-family: "Lucida Grande", Verdana, Arial, Helvetica, sans-serif;
+	font-size: 8pt;
+}
+
+#tasks {
+	position: relative;
+	top: 0;
+	left: 0;
+	height: auto;
+	margin: 5em auto 0 auto;
+	overflow: visible;
+}
+
+#printconfig {
+	position: fixed;
+	top: 0;
+	left: 0;
+	width: 100%;
+	z-index: 10000;
+	padding: 0.5em;
+	background: #ebebeb;
+	border-bottom: 1px solid #999;
+	box-shadow: 0 3px 4px #ccc;
+	-moz-box-shadow: 0 3px 4px #ccc;
+	-webkit-box-shadow: 0 3px 4px #ccc;
+}
+
+#printconfig .prop {
+	padding-right: 2em;
+}
+
+#message {
+	position: absolute;
+	top: 5.5em;
+	left: 1em;
+}
+
+#message div.loading {
+	color: #666;
+	font-style: italic;
+}
+
+#tasklist {
+	margin: 0;
+	padding: 0 10px;
+}
+
+.pagewidth {
+	width: 700px;
+	margin: 0 auto;
+}
+
+.rightalign {
+	float: right;
+	padding-top: 0.3em;
+}
+
+ at media print {
+	.noprint,
+	.fc-header-right span {
+		display: none;
+	}
+	
+	#tasks {
+		margin-top: 0;
+	}
+}
+
+#tasklist .description {
+	display: block;
+	white-space: pre;
+}
+
+#tasklist .title {
+	font-weight: bold;
+}
+
+.taskhead {
+	border-radius: 0;
+	border: 0;
+	border-bottom: 1px solid #bbb;
+	box-shadow: none;
+	-webkit-box-shadow: none;
+	-moz-box-shadow: none;
+}
diff --git a/plugins/tasklist/skins/larry/templates/print.html b/plugins/tasklist/skins/larry/templates/print.html
new file mode 100644
index 0000000..c9620fa
--- /dev/null
+++ b/plugins/tasklist/skins/larry/templates/print.html
@@ -0,0 +1,23 @@
+<roundcube:object name="doctype" value="html5" />
+<html>
+<head>
+<title><roundcube:object name="pagetitle" /></title>
+</head>
+<body class="taskprint">
+
+<div id="printconfig" class="noprint">
+	<div class="pagewidth">
+		<a href="#close" onclick="window.close()" class="rightalign"><roundcube:label name="close" /></a>
+		<span class="prop"><input type="button" id="printme" value="<roundcube:label name='print' />" onclick="window.print()"></span>
+		<span class="prop"><label><input type="checkbox" id="propdescription" checked="checked" onclick="$('#tasklist .description')[this.checked ? 'show' : 'hide']()" /> <roundcube:label name="tasklist.printdescriptions" /></label></span>
+	</div>
+</div>
+
+<roundcube:object name="message" id="message" class="noprint" />
+
+<div id="tasks" class="pagewidth">
+	<roundcube:object name="plugin.tasklist_print" id="tasklist" />
+</div>
+
+</body>
+</html>
diff --git a/plugins/tasklist/tasklist.js b/plugins/tasklist/tasklist.js
index 34cd97c..9d92f25 100644
--- a/plugins/tasklist/tasklist.js
+++ b/plugins/tasklist/tasklist.js
@@ -112,6 +112,7 @@ function rcube_tasklist_ui(settings)
     /*  public methods  */
     this.init = init;
     this.edit_task = task_edit_dialog;
+    this.print_tasks = print_tasks;
     this.delete_task = delete_task;
     this.add_childtask = add_childtask;
     this.quicksearch = quicksearch;
@@ -136,6 +137,11 @@ function rcube_tasklist_ui(settings)
      */
     function init()
     {
+        if (rcmail.env.action == 'print' && rcmail.task == 'tasks') {
+            data_ready({data: rcmail.env.tasks});
+            return;
+        }
+
         // initialize task list selectors
         for (var id in me.tasklists) {
             if (settings.selected_list && me.tasklists[settings.selected_list] && !me.tasklists[settings.selected_list].active) {
@@ -846,6 +852,11 @@ function rcube_tasklist_ui(settings)
             id = listindex[i];
             rec = listdata[id];
             if (match_filter(rec, cache)) {
+                if (rcmail.env.action == 'print') {
+                    render_task_printmode(rec);
+                    continue;
+                }
+
                 render_task(rec);
                 count++;
 
@@ -859,6 +870,9 @@ function rcube_tasklist_ui(settings)
             }
         }
 
+        if (rcmail.env.action == 'print')
+            return;
+
         fix_tree_toggles();
         update_tagcloud(activetags);
 
@@ -1315,6 +1329,37 @@ function rcube_tasklist_ui(settings)
     }
 
     /**
+     * Render the given task into the tasks list (in print mode)
+     */
+    function render_task_printmode(rec)
+    {
+        var label_id = rcmail.html_identifier(rec.id) + '-title',
+            div = $('<div>').addClass('taskhead')
+                .append($('<span class="title">').attr('id', label_id).text(rec.title)),
+            parent = rec.parent_id ? $('li[rel="'+rec.parent_id+'"] > ul.childtasks', rcmail.gui_objects.resultlist) : null,
+            li = $('<li role="treeitem">').attr('rel', rec.id).addClass('taskitem')
+                .append(div)
+                .append('<ul class="childtasks" role="group"></ul>');
+
+        if (rec.description)
+            div.append($('<span class="description">').text(rec.description));
+/*
+        if (is_complete(rec))
+            div.addClass('complete');
+        if (rec.flagged)
+            div.addClass('flagged');
+        if (!rec.date)
+            div.addClass('nodate');
+        if (rec.mask & FILTER_MASK_OVERDUE)
+            div.addClass('overdue');
+*/
+        if (!parent || !parent.length)
+            li.appendTo(rcmail.gui_objects.resultlist);
+        else
+            li.appendTo(parent);
+    }
+
+    /**
      * Move the given task item to the right place in the list
      */
     function resort_task(rec, li, animated)
@@ -2835,6 +2880,18 @@ function rcube_tasklist_ui(settings)
     }
 
 
+    // method to show the print dialog.
+    function print_tasks()
+    {
+        var param = {}, active = active_lists();
+
+        if (active.length) {
+            param = {filter: filtermask, lists: active.join(','), q: search_query};
+            rcmail.open_window(rcmail.url('print', param), true, true);
+        }
+    };
+
+
     /**** Utility functions ****/
 
     // same as str.split(delimiter) but it ignores delimiters within quoted strings
@@ -3010,7 +3067,7 @@ window.rcmail && rcmail.addEventListener('init', function(evt) {
 
   // register button commands
   rcmail.register_command('newtask', function(){ rctasks.edit_task(null, 'new', {}); }, true);
-  //rcmail.register_command('print', function(){ rctasks.print_list(); }, true);
+  rcmail.register_command('print', function(){ rctasks.print_tasks(); }, true);
 
   rcmail.register_command('list-create', function(){ rctasks.list_edit_dialog(null); }, true);
   rcmail.register_command('list-edit', function(){ rctasks.list_edit_dialog(rctasks.selected_list); }, false);
diff --git a/plugins/tasklist/tasklist.php b/plugins/tasklist/tasklist.php
index b260714..06fad64 100644
--- a/plugins/tasklist/tasklist.php
+++ b/plugins/tasklist/tasklist.php
@@ -112,6 +112,7 @@ class tasklist extends rcube_plugin
             $this->register_action('tasklist', array($this, 'tasklist_action'));
             $this->register_action('counts', array($this, 'fetch_counts'));
             $this->register_action('fetch', array($this, 'fetch_tasks'));
+            $this->register_action('print', array($this, 'print_tasks'));
             $this->register_action('inlineui', array($this, 'get_inline_ui'));
             $this->register_action('mail2task', array($this, 'mail_message2task'));
             $this->register_action('get-attachment', array($this, 'attachment_get'));
@@ -1010,6 +1011,44 @@ class tasklist extends rcube_plugin
     }
 
     /**
+     * Handler for printing calendars
+     */
+    public function print_tasks()
+    {
+        // Add CSS stylesheets to the page header
+        $skin_path = $this->local_skin_path();
+
+        $this->include_stylesheet($skin_path . '/print.css');
+        $this->include_script('tasklist.js');
+
+        $this->rc->output->add_handlers(array(
+            'plugin.tasklist_print' => array($this, 'print_tasks_list'),
+        ));
+
+        $this->rc->output->set_pagetitle($this->gettext('print'));
+        $this->rc->output->send('tasklist.print');
+    }
+
+    /**
+     * Handler for printing calendars
+     */
+    public function print_tasks_list($attrib)
+    {
+        $f      = intval(rcube_utils::get_input_value('filter', rcube_utils::INPUT_GPC));
+        $search = rcube_utils::get_input_value('q', rcube_utils::INPUT_GPC);
+        $lists  = rcube_utils::get_input_value('lists', rcube_utils::INPUT_GPC);
+        $filter = array('mask' => $f, 'search' => $search);
+
+        $data = $this->tasks_data($this->driver->list_tasks($filter, $lists), $f);
+
+        // we'll build the tasks table in javascript on page load
+        // where we have sorting methods, etc.
+        $this->rc->output->set_env('tasks', $data);
+
+        return $this->ui->tasks_resultview($attrib);
+    }
+
+    /**
      * Prepare and sort the given task records to be sent to the client
      */
     private function tasks_data($records, $f)




More information about the commits mailing list