From c5597baf88c3f7bcea9c03a3fa35e1dc81e12bd5 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Tue, 4 Oct 2016 12:56:04 +0200 Subject: show whether the current folder was shared or not Signed-off-by: Christoph Wurst --- apps/files/js/breadcrumb.js | 23 +++++++++++++++++++++++ apps/files/js/filelist.js | 10 ++++++++++ 2 files changed, 33 insertions(+) (limited to 'apps/files/js') diff --git a/apps/files/js/breadcrumb.js b/apps/files/js/breadcrumb.js index 98de7aa374c..ff9700456da 100644 --- a/apps/files/js/breadcrumb.js +++ b/apps/files/js/breadcrumb.js @@ -45,6 +45,7 @@ if (options.getCrumbUrl) { this.getCrumbUrl = options.getCrumbUrl; } + this._detailViews = []; }; /** * @memberof OCA.Files @@ -52,6 +53,7 @@ BreadCrumb.prototype = { $el: null, dir: null, + dirInfo: null, /** * Total width of all breadcrumbs @@ -79,6 +81,20 @@ } }, + setDirectoryInfo: function(dirInfo) { + if (dirInfo !== this.dirInfo) { + this.dirInfo = dirInfo; + this.render(); + } + }, + + /** + * @param {Backbone.View} detailView + */ + addDetailView: function(detailView) { + this._detailViews.push(detailView); + }, + /** * Returns the full URL to the given directory * @@ -122,6 +138,13 @@ } $crumb.addClass('last'); + _.each(this._detailViews, function(view) { + view.render({ + dirInfo: this.dirInfo + }); + $crumb.append(view.$el); + }, this); + // in case svg is not supported by the browser we need to execute the fallback mechanism if (!OC.Util.hasSVGSupport()) { OC.Util.replaceSVG(this.$el); diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 18534db3ee9..8d0e492643f 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -1646,6 +1646,7 @@ // first entry is the root this.dirInfo = result.shift(); + this.breadcrumb.setDirectoryInfo(this.dirInfo); if (this.dirInfo.permissions) { this.setDirectoryPermissions(this.dirInfo.permissions); @@ -2954,6 +2955,15 @@ if (this._detailsView) { this._detailsView.addDetailView(detailView); } + }, + + /** + * Register a view to be added to the breadcrumb view + */ + registerBreadCrumbDetailView: function(detailView) { + if (this.breadcrumb) { + this.breadcrumb.addDetailView(detailView); + } } }; -- cgit v1.2.3 From bc1cb8a6d09d97df93b7914e020759eb7df73df1 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Tue, 4 Oct 2016 19:08:08 +0200 Subject: let users share the curren folder Signed-off-by: Christoph Wurst --- apps/files/js/filelist.js | 11 +++++++---- apps/files_sharing/js/sharebreadcrumbview.js | 12 ++++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 8d0e492643f..5bdb1a8999d 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -518,13 +518,16 @@ OC.Apps.showAppSidebar(this._detailsView.$el); } - var $tr = this.findFileEl(fileName); - var model = this.getModelForFile($tr); + if (_.isObject(fileName)) { + var model = new OCA.Files.FileInfoModel(fileName); + } else { + var $tr = this.findFileEl(fileName); + var model = this.getModelForFile($tr); + $tr.addClass('highlighted'); + } this._currentFileModel = model; - $tr.addClass('highlighted'); - this._detailsView.setFileInfo(model); this._detailsView.$el.scrollTop(0); }, diff --git a/apps/files_sharing/js/sharebreadcrumbview.js b/apps/files_sharing/js/sharebreadcrumbview.js index c469fd252aa..7e659768304 100644 --- a/apps/files_sharing/js/sharebreadcrumbview.js +++ b/apps/files_sharing/js/sharebreadcrumbview.js @@ -33,6 +33,10 @@ var BreadCrumbView = OC.Backbone.View.extend({ tagName: 'span', + events: { + click: '_onClick' + }, + _dirInfo: undefined, _template: undefined, template: function(data) { if (!this._template) { @@ -41,13 +45,21 @@ return this._template(data); }, render: function(data) { + this._dirInfo = data.dirInfo; + var isShared = data.dirInfo && data.dirInfo.shareTypes && data.dirInfo.shareTypes.length > 0; this.$el.html(this.template({ isShared: isShared })); + this.delegateEvents(); return this; + }, + _onClick: function(e) { + e.preventDefault(); + + OCA.Files.App.fileList.showDetailsView(this._dirInfo, 'shareTabView'); } }); -- cgit v1.2.3 From c55718ae5e6eb3ebde519e3a4954e8b339734067 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Mon, 10 Oct 2016 17:35:11 +0200 Subject: update breadcrumb view whenever the share information on the directory info model changes Signed-off-by: Christoph Wurst --- apps/files/js/filelist.js | 10 +++++----- apps/files_sharing/js/sharebreadcrumbview.js | 12 ++++++++++-- 2 files changed, 15 insertions(+), 7 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 5bdb1a8999d..c53fa4f3d66 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -473,7 +473,7 @@ * Displays the details view for the given file and * selects the given tab * - * @param {string} fileName file name for which to show details + * @param {string|OCA.Files.FileInfoModel} fileName file name or FileInfoModel for which to show details * @param {string} [tabId] optional tab id to select */ showDetailsView: function(fileName, tabId) { @@ -487,7 +487,7 @@ /** * Update the details view to display the given file * - * @param {string} fileName file name from the current list + * @param {string|OCA.Files.FileInfoModel} fileName file name from the current list or a FileInfoModel object * @param {boolean} [show=true] whether to open the sidebar if it was closed */ _updateDetailsView: function(fileName, show) { @@ -518,8 +518,8 @@ OC.Apps.showAppSidebar(this._detailsView.$el); } - if (_.isObject(fileName)) { - var model = new OCA.Files.FileInfoModel(fileName); + if (fileName instanceof OCA.Files.FileInfoModel) { + var model = fileName; } else { var $tr = this.findFileEl(fileName); var model = this.getModelForFile($tr); @@ -2025,7 +2025,7 @@ function updateInList(fileInfo) { self.updateRow(tr, fileInfo); - self._updateDetailsView(fileInfo.name, false); + self._updateDetailsView(fileInfo, false); } // TODO: too many nested blocks, move parts into functions diff --git a/apps/files_sharing/js/sharebreadcrumbview.js b/apps/files_sharing/js/sharebreadcrumbview.js index c6bf365ba07..d29ba9d05dc 100644 --- a/apps/files_sharing/js/sharebreadcrumbview.js +++ b/apps/files_sharing/js/sharebreadcrumbview.js @@ -41,7 +41,7 @@ return this._template(data); }, render: function(data) { - this._dirInfo = data.dirInfo; + this._dirInfo = data.dirInfo || null; if (this._dirInfo !== null && (this._dirInfo.path !== '/' || this._dirInfo.name !== '')) { var isShared = data.dirInfo && data.dirInfo.shareTypes && data.dirInfo.shareTypes.length > 0; @@ -60,7 +60,15 @@ _onClick: function(e) { e.preventDefault(); - OCA.Files.App.fileList.showDetailsView(this._dirInfo, 'shareTabView'); + var fileInfoModel = new OCA.Files.FileInfoModel(this._dirInfo); + var self = this; + fileInfoModel.on('change', function() { + console.log('CHANGE'); + self.render({ + dirInfo: self._dirInfo + }); + }); + OCA.Files.App.fileList.showDetailsView(fileInfoModel, 'shareTabView'); } }); -- cgit v1.2.3