diff options
author | Vincent Petry <pvince81@owncloud.com> | 2015-09-14 17:20:51 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2015-09-16 07:23:28 +0200 |
commit | e90065881d47a64b6c376208ece208932711c765 (patch) | |
tree | 7bbd578263150f5d64f11fdc74da6bb838763c0c /core/js/shareitemmodel.js | |
parent | 8194d092e71b1c44a441dddc64b7e7533adbbfb9 (diff) | |
download | nextcloud-server-e90065881d47a64b6c376208ece208932711c765.tar.gz nextcloud-server-e90065881d47a64b6c376208ece208932711c765.zip |
Bring back the share icon and update its status
Display share icon in file list row.
Update share icon status when the sharing state changed.
Diffstat (limited to 'core/js/shareitemmodel.js')
-rw-r--r-- | core/js/shareitemmodel.js | 65 |
1 files changed, 46 insertions, 19 deletions
diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js index 2a97bc8abd5..949c86599bc 100644 --- a/core/js/shareitemmodel.js +++ b/core/js/shareitemmodel.js @@ -149,8 +149,6 @@ options.error(model); } } - //FIXME: updateIcon belongs to view - OC.Share.updateIcon(itemType, itemSource); }, function(result) { var msg = t('core', 'Error'); @@ -236,8 +234,6 @@ var itemSource = this.get('itemSource'); OC.Share.share(itemType, itemSource, shareType, shareWith, permissions, fileName, options.expiration, function() { model.fetch(); - //FIXME: updateIcon belongs to view - OC.Share.updateIcon(itemType, itemSource); }); }, @@ -255,8 +251,6 @@ OC.Share.unshare(itemType, itemSource, shareType, shareWith, function() { model.fetch(); - //FIXME: updateIcon belongs to view - OC.Share.updateIcon(itemType, itemSource); }); }, @@ -291,12 +285,25 @@ }, /** - * whether this item has share information + * whether this item has user share information * @returns {boolean} */ - hasShares: function() { + hasUserShares: function() { var shares = this.get('shares'); - return _.isArray(this.get('shares')); + return _.isArray(shares) && shares.length > 0; + }, + + /** + * Returns whether this item has a link share + * + * @return {bool} true if a link share exists, false otherwise + */ + hasLinkShare: function() { + var linkShare = this.get('linkShare'); + if (linkShare && linkShare.isLinkShare) { + return true; + } + return false; }, /** @@ -544,7 +551,27 @@ }); }, - legacyFillCurrentShares: function(shares) { + /** + * Updates OC.Share.itemShares and OC.Share.statuses. + * + * This is required in case the user navigates away and comes back, + * the share statuses from the old arrays are still used to fill in the icons + * in the file list. + */ + _legacyFillCurrentShares: function(shares) { + var fileId = this.fileInfoModel.get('id'); + if (!shares || !shares.length) { + delete OC.Share.statuses[fileId]; + return; + } + + var currentShareStatus = OC.Share.statuses[fileId]; + if (!currentShareStatus) { + currentShareStatus = {link: false}; + OC.Share.statuses[fileId] = currentShareStatus; + } + currentShareStatus.link = false; + OC.Share.currentShares = {}; OC.Share.itemShares = []; _.each(shares, @@ -552,15 +579,15 @@ * @param {OC.Share.Types.ShareInfo} share */ function(share) { - if (!OC.Share.currentShares[share.share_type]) { - OC.Share.currentShares[share.share_type] = []; - } - OC.Share.currentShares[share.share_type].push(share); - - if (!OC.Share.itemShares[share.share_type]) { - OC.Share.itemShares[share.share_type] = []; + if (share.share_type === OC.Share.SHARE_TYPE_LINK) { + OC.Share.itemShares[share.share_type] = true; + currentShareStatus.link = true; + } else { + if (!OC.Share.itemShares[share.share_type]) { + OC.Share.itemShares[share.share_type] = []; + } + OC.Share.itemShares[share.share_type].push(share.share_with); } - OC.Share.itemShares[share.share_type].push(share.share_with); } ); }, @@ -589,7 +616,7 @@ /** @type {OC.Share.Types.ShareInfo[]} **/ var shares = _.toArray(data.shares); - this.legacyFillCurrentShares(shares); + this._legacyFillCurrentShares(shares); var linkShare = { isLinkShare: false }; // filter out the share by link |