Explorar o código

[home2] Export and import of any documents

Romain Rigaux %!s(int64=10) %!d(string=hai) anos
pai
achega
57e3c48

+ 6 - 0
desktop/core/src/desktop/static/desktop/js/home2.vm.js

@@ -23,6 +23,7 @@ function HomeViewModel(data) {
   self.mkdirFormPath = ko.observable('');
   self.deleteFormPath = ko.observable('');
   self.shareFormDocId = ko.observable('');
+  self.exportFormDocIds = ko.observable('');
 
   self.page = ko.observable(1);
   self.documentsPerPage = ko.observable(50);
@@ -117,4 +118,9 @@ function HomeViewModel(data) {
     });
   };
 
+  self.exportDocuments = function() {
+    $('#export-documents').find('input[name=\'documents\']').val(ko.mapping.toJSON(self.exportFormDocIds().split(",")));
+    $('#export-documents').find('form').submit();
+  };
+
 }

+ 11 - 2
desktop/core/src/desktop/templates/home2.mako

@@ -14,7 +14,7 @@
 ## See the License for the specific language governing permissions and
 ## limitations under the License.
 <%!
-  from desktop.views import commonheader, commonfooter, commonshare2, _ko
+  from desktop.views import commonheader, commonfooter, commonshare2, commonimportexport, _ko
   from django.utils.translation import ugettext as _
 %>
 
@@ -153,6 +153,15 @@ ${ commonheader(_('Welcome Home'), "home", user) | n,unicode }
           <i class="fa fa-users"></i> ${ _('Share') }
         </a>
 
+        <input data-bind="value: exportFormDocIds" placeholder="doc id, e.g. 50491,50492"></input>
+        <a class="share-link btn" data-bind="click: exportDocuments">
+          <i class="fa fa-download"></i> ${ _('Export') }
+        </a>
+
+        <a data-bind="click: function() { $('#import-documents').modal('show'); }" class="btn">
+          <i class="fa fa-upload"></i> ${ _('Import') }
+        </a>
+
         <div class="card-body">
           <p>
           <table id="documents" class="table table-striped table-condensed" data-bind="visible: documents().length > 0">
@@ -203,7 +212,7 @@ ${ commonheader(_('Welcome Home'), "home", user) | n,unicode }
 
 
 ${ commonshare2() | n,unicode }
-
+${ commonimportexport(request) | n,unicode }
 
 <script src="${ static('desktop/ext/js/datatables-paging-0.1.js') }" type="text/javascript" charset="utf-8"></script>
 <script src="${ static('desktop/ext/js/knockout.min.js') }" type="text/javascript" charset="utf-8"></script>