2 commits - plugins/kolab_files

Aleksander Machniak machniak at kolabsys.com
Thu Feb 21 15:06:33 CET 2013


 plugins/kolab_files/kolab_files.js                            |   71 +++++++++-
 plugins/kolab_files/lib/kolab_files_engine.php                |   68 +++++++++
 plugins/kolab_files/skins/larry/style.css                     |   33 ++++
 plugins/kolab_files/skins/larry/templates/compose_plugin.html |    8 +
 plugins/kolab_files/skins/larry/templates/message_plugin.html |    9 +
 plugins/kolab_files/skins/larry/ui.js                         |   41 +++++
 6 files changed, 221 insertions(+), 9 deletions(-)

New commits:
commit 5e9256e8563ae16a16667d470fc6a259e49ba9d3
Author: Aleksander Machniak <machniak at kolabsys.com>
Date:   Thu Feb 21 15:05:57 2013 +0100

    Implemented searching in file selector dialog

diff --git a/plugins/kolab_files/kolab_files.js b/plugins/kolab_files/kolab_files.js
index 01a1986..3198802 100644
--- a/plugins/kolab_files/kolab_files.js
+++ b/plugins/kolab_files/kolab_files.js
@@ -6,7 +6,7 @@
  */
 
 window.rcmail && rcmail.addEventListener('init', function() {
-  if (rcmail.env.task == 'mail') {
+  if (rcmail.task == 'mail') {
     // mail compose
     if (rcmail.env.action == 'compose') {
       var elem = $('#compose-attachments > div'),
@@ -175,6 +175,18 @@ function kolab_files_ui()
     rcmail.http_error(request, status, err);
   };
 
+  this.file_list = function(params)
+  {
+    if (rcmail.task != 'kolab_files')
+      this.file_selector(params);
+  };
+
+  this.folder_list = function(params)
+  {
+    if (rcmail.task != 'kolab_files')
+      this.folder_selector(params);
+  };
+
   this.folder_selector = function()
   {
     this.req = this.set_busy(true, 'loading');
@@ -244,6 +256,9 @@ function kolab_files_ui()
 
   this.file_selector = function(params)
   {
+    if (!this.env.folder)
+      return;
+
     if (!params)
       params = {};
 
@@ -315,4 +330,25 @@ function kolab_files_ui()
       this.folder_selector();
   };
 
+  this.search = function()
+  {
+    var value = $(rcmail.gui_objects.filesearchbox).val();
+
+    if (value) {
+      this.env.search = {name: value};
+      this.file_list({search: this.env.search});
+    }
+    else
+      this.search_reset();
+  };
+
+  this.search_reset = function()
+  {
+    $(rcmail.gui_objects.filesearchbox).val('');
+
+    if (this.env.search) {
+      this.env.search = null;
+      this.file_list();
+    }
+  };
 };
diff --git a/plugins/kolab_files/lib/kolab_files_engine.php b/plugins/kolab_files/lib/kolab_files_engine.php
index 84d34e8..addd9d9 100644
--- a/plugins/kolab_files/lib/kolab_files_engine.php
+++ b/plugins/kolab_files/lib/kolab_files_engine.php
@@ -66,6 +66,7 @@ class kolab_files_engine
             // register template objects
             $this->rc->output->add_handlers(array(
                 'folder-create-form' => array($this, 'folder_create_form'),
+                'file-search-form' => array($this, 'file_search_form'),
             ));
             // add dialog content at the end of page body
             $this->rc->output->add_footer(
@@ -90,7 +91,7 @@ class kolab_files_engine
     /**
      * Template object for folder creation form in "Save as" dialog
      */
-    public function folder_create_form($attr)
+    public function folder_create_form($attrib)
     {
         $attrib['name'] = 'folder-create-form';
         if (empty($attrib['id'])) {
@@ -114,6 +115,40 @@ class kolab_files_engine
     }
 
     /**
+     * Template object for file search form in "From cloud" dialog
+     */
+    public function file_search_form($attrib)
+    {
+        $attrib['name'] = '_q';
+
+        if (empty($attrib['id'])) {
+            $attrib['id'] = 'filesearchbox';
+        }
+        if ($attrib['type'] == 'search' && !$this->rc->output->browser->khtml) {
+            unset($attrib['type'], $attrib['results']);
+        }
+
+        $input_q = new html_inputfield($attrib);
+        $out = $input_q->show();
+
+        // add some labels to client
+        $this->rc->output->add_label('searching');
+        $this->rc->output->add_gui_object('filesearchbox', $attrib['id']);
+
+        // add form tag around text field
+        if (empty($attrib['form'])) {
+            $out = $this->rc->output->form_tag(array(
+                'name' => "filesearchform",
+                'onsubmit' => "file_api.search(); return false",
+                'style' => "display:inline"),
+                $out);
+        }
+
+        return $out;
+    }
+
+
+    /**
      * Get API token for current user session, authenticate if needed
      */
     protected function get_api_token()
diff --git a/plugins/kolab_files/skins/larry/style.css b/plugins/kolab_files/skins/larry/style.css
index a983767..463c220 100644
--- a/plugins/kolab_files/skins/larry/style.css
+++ b/plugins/kolab_files/skins/larry/style.css
@@ -17,6 +17,7 @@
 #files-compose-dialog #files-folder-selector {
   right: auto;
   width: 190px;
+  top: 45px;
 }
 
 #files-dialog #files-folder-selector {
@@ -25,7 +26,7 @@
 
 #files-file-selector {
   position: absolute;
-  top: 5px;
+  top: 45px;
   bottom: 5px;
   left: 200px;
   right: 0;
@@ -66,6 +67,19 @@
   cursor: default;
 }
 
+#files-compose-dialog #searchmenulink {
+  width: 15px;
+}
+
+#files-compose-dialog #quicksearchbar {
+  top: 10px;
+  right: 5px;
+}
+
+#files-compose-dialog #searchreset {
+  cursor: pointer;
+}
+
 #filelist table {
   width: 100%;
   border-spacing: 0;
diff --git a/plugins/kolab_files/skins/larry/templates/compose_plugin.html b/plugins/kolab_files/skins/larry/templates/compose_plugin.html
index 2a71e57..a94418f 100644
--- a/plugins/kolab_files/skins/larry/templates/compose_plugin.html
+++ b/plugins/kolab_files/skins/larry/templates/compose_plugin.html
@@ -1,4 +1,12 @@
 <div id="files-compose-dialog" class="uidialog">
+    <div id="quicksearchbar" class="searchbox">
+        <roundcube:object name="file-search-form" id="filesearchbox" />
+<!--
+        <roundcube:button name="searchmenulink" id="searchmenulink" class="iconbutton searchoptions" onclick="UI.show_popup('searchmenu');return false" title="searchmod" content=" " />
+-->
+        <a id="searchmenulink" class="iconbutton searchoptions"> </a>
+        <a id="searchreset" class="iconbutton reset" title="<roundcube:label name="resetsearch"/>" onclick="file_api.search_reset()"> </a>
+    </div>
     <div id="files-folder-selector"></div>
     <div id="files-file-selector">
         <table id="filelist"><tbody></tbody></table>


commit fd3b78960ce0d49144903fb4f23e11e424d7bfa0
Author: Aleksander Machniak <machniak at kolabsys.com>
Date:   Thu Feb 21 13:27:38 2013 +0100

    Add folder creation in Save as dialog

diff --git a/plugins/kolab_files/kolab_files.js b/plugins/kolab_files/kolab_files.js
index eea14c5..01a1986 100644
--- a/plugins/kolab_files/kolab_files.js
+++ b/plugins/kolab_files/kolab_files.js
@@ -74,10 +74,10 @@ function kolab_directory_selector_dialog()
     title: rcmail.gettext('kolab_files.saveall'),
 //    close: function() { rcmail.dialog_close(); },
     buttons: buttons,
-    minWidth: 300,
+    minWidth: 400,
     minHeight: 300,
-    height: 250,
-    width: 250
+    height: 300,
+    width: 350
     }).show();
 
   file_api.folder_selector();
@@ -220,9 +220,9 @@ function kolab_files_ui()
         first = i;
     });
 
-   // select first folder
-   if (first)
-     this.selector_select(first);
+   // select first folder?
+//   if (first)
+//     this.selector_select(first);
 
     // add tree icons
     this.folder_list_tree(this.env.folders);
@@ -294,4 +294,25 @@ function kolab_files_ui()
 //    $('tr.selected', table).removeClass('selected');
     $(row).addClass('selected');
   };
+
+  // folder create request
+  this.folder_create = function(folder)
+  {
+    this.req = this.set_busy(true, 'creating');
+    this.get('folder_create', {folder: folder}, 'folder_create_response');
+  };
+
+  // folder create response handler
+  this.folder_create_response = function(response)
+  {
+    if (!this.response(response))
+      return;
+
+    // refresh folders list
+    if (rcmail.task == 'kolab_files')
+      this.folder_list();
+    else
+      this.folder_selector();
+  };
+
 };
diff --git a/plugins/kolab_files/lib/kolab_files_engine.php b/plugins/kolab_files/lib/kolab_files_engine.php
index 893077d..84d34e8 100644
--- a/plugins/kolab_files/lib/kolab_files_engine.php
+++ b/plugins/kolab_files/lib/kolab_files_engine.php
@@ -63,6 +63,11 @@ class kolab_files_engine
         }
 
         if (!empty($template)) {
+            // register template objects
+            $this->rc->output->add_handlers(array(
+                'folder-create-form' => array($this, 'folder_create_form'),
+            ));
+            // add dialog content at the end of page body
             $this->rc->output->add_footer(
                 $this->rc->output->parse('kolab_files.' . $template, false, false));
         }
@@ -83,6 +88,32 @@ class kolab_files_engine
     }
 
     /**
+     * Template object for folder creation form in "Save as" dialog
+     */
+    public function folder_create_form($attr)
+    {
+        $attrib['name'] = 'folder-create-form';
+        if (empty($attrib['id'])) {
+            $attrib['id'] = 'folder-create-form';
+        }
+
+        $input_name = new html_inputfield(array('name' => 'folder_name'));
+        $out = $input_name->show();
+
+//        $input_parent = new html_checkbox(array('name' => 'folder_parent', 'checked' => true, 'value' => 1));
+//        $out .= html::label(null, $input_parent->show() . $this->plugin->gettext('assubfolder'));
+
+        // add form tag around text field
+        if (empty($attrib['form'])) {
+            $out = $this->rc->output->form_tag($attrib, $out);
+        }
+
+        $this->rc->output->add_gui_object('folder-create-form', $attrib['id']);
+
+        return $out;
+    }
+
+    /**
      * Get API token for current user session, authenticate if needed
      */
     protected function get_api_token()
@@ -263,6 +294,8 @@ class kolab_files_engine
             $this->rc->output->show_message($this->plugin->gettext('saveallerror', array('n' => $count)), 'error');
         }
 
+        // @TODO: update quota indicator, make this optional in case files aren't stored in IMAP
+
         $this->rc->output->send();
     }
 
diff --git a/plugins/kolab_files/skins/larry/style.css b/plugins/kolab_files/skins/larry/style.css
index ffcc8b4..a983767 100644
--- a/plugins/kolab_files/skins/larry/style.css
+++ b/plugins/kolab_files/skins/larry/style.css
@@ -1,5 +1,6 @@
 #files-dialog,
-#files-compose-dialog {
+#files-compose-dialog,
+#files-folder-create {
   display: none;
 }
 
@@ -18,6 +19,10 @@
   width: 190px;
 }
 
+#files-dialog #files-folder-selector {
+  bottom: 40px;
+}
+
 #files-file-selector {
   position: absolute;
   top: 5px;
@@ -29,6 +34,16 @@
   overflow: auto;
 }
 
+#files-dialog #files-folder-footer {
+  position: absolute;
+  height: 30px;
+  bottom: 0;
+}
+
+#files-dialog #files-folder-footer form {
+  display: inline;
+}
+
 #files-folder-selector table {
   width: 100%;
   border-spacing: 0;
diff --git a/plugins/kolab_files/skins/larry/templates/message_plugin.html b/plugins/kolab_files/skins/larry/templates/message_plugin.html
index 5d8b06e..36f8e6f 100644
--- a/plugins/kolab_files/skins/larry/templates/message_plugin.html
+++ b/plugins/kolab_files/skins/larry/templates/message_plugin.html
@@ -1,3 +1,12 @@
 <div id="files-dialog" class="uidialog">
     <div id="files-folder-selector"></div>
+    <div id="files-folder-footer">
+        <input id="folder-create-start-button" onclick="kolab_files_folder_form()" type="button" value="<roundcube:label name="kolab_files.foldercreate" />">
+        <div id="files-folder-create">
+            <roundcube:object name="folder-create-form" />
+            <input id="folder-create-save-button" onclick="kolab_directory_create()" type="button" class="button mainaction" value="<roundcube:label name="create" />">
+            <input id="folder-create-cancel-button" onclick="kolab_directory_cancel()" type="button" class="button" value="<roundcube:label name="cancel" />">
+        </div>
+    </div>
 </div>
+<script src="plugins/kolab_files/skins/larry/ui.js" type="text/javascript"></script>
diff --git a/plugins/kolab_files/skins/larry/ui.js b/plugins/kolab_files/skins/larry/ui.js
new file mode 100644
index 0000000..75d0d92
--- /dev/null
+++ b/plugins/kolab_files/skins/larry/ui.js
@@ -0,0 +1,41 @@
+function kolab_files_folder_form(link)
+{
+  var form = $('#files-folder-create'),
+    link = $('#folder-create-start-button');
+
+  link.hide();
+  form.show();
+
+  $('input[name="folder_name"]', form).val('').focus();
+}
+
+function kolab_directory_create()
+{
+  var folder = '',
+    form = $('#files-folder-create'),
+    name = $('input[name="folder_name"]', form).val(),
+    parent = file_api.env.folder;
+//    parent = $('input[name="folder_parent"]', form).is(':checked');
+
+  if (!name)
+    return;
+
+  if (parent && file_api.env.folder)
+    folder = file_api.env.folder + file_api.env.directory_separator;
+
+  folder += name;
+
+  kolab_directory_cancel();
+  file_api.folder_create(folder);
+
+  // todo: select created folder
+}
+
+function kolab_directory_cancel()
+{
+  var form = $('#files-folder-create'),
+    link = $('#folder-create-start-button');
+
+  link.show();
+  form.hide();
+}





More information about the commits mailing list