summaryrefslogtreecommitdiffstats
path: root/core/js
diff options
context:
space:
mode:
Diffstat (limited to 'core/js')
-rw-r--r--core/js/js.js1
-rw-r--r--core/js/mimetypelist.js57
-rw-r--r--core/js/oc-dialogs.js5
-rw-r--r--core/js/share.js2
-rw-r--r--core/js/sharedialogview.js3
-rw-r--r--core/js/shareitemmodel.js46
-rw-r--r--core/js/tests/specs/shareitemmodelSpec.js111
7 files changed, 179 insertions, 46 deletions
diff --git a/core/js/js.js b/core/js/js.js
index de773dc1221..b5971bfc579 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -1972,4 +1972,5 @@ jQuery.fn.tipsy = function(argument) {
this.tooltip(argument);
jQuery.fn.tooltip.call(this, argument);
}
+ return this;
}
diff --git a/core/js/mimetypelist.js b/core/js/mimetypelist.js
index e49ace6df73..af2ad73c51b 100644
--- a/core/js/mimetypelist.js
+++ b/core/js/mimetypelist.js
@@ -9,26 +9,23 @@
OC.MimeTypeList={
aliases: {
"application/coreldraw": "image",
- "application/epub+zip": "text",
- "application/font-sfnt": "image",
- "application/font-woff": "image",
- "application/illustrator": "image",
- "application/javascript": "text/code",
+ "application/font-sfnt": "font",
+ "application/font-woff": "font",
+ "application/illustrator": "image/vector",
"application/json": "text/code",
- "application/msaccess": "file",
+ "application/msaccess": "database",
"application/msexcel": "x-office/spreadsheet",
"application/mspowerpoint": "x-office/presentation",
"application/msword": "x-office/document",
"application/octet-stream": "file",
- "application/postscript": "image",
- "application/rss+xml": "text/code",
+ "application/postscript": "image/vector",
"application/vnd.android.package-archive": "package/x-generic",
"application/vnd.ms-excel": "x-office/spreadsheet",
"application/vnd.ms-excel.addin.macroEnabled.12": "x-office/spreadsheet",
"application/vnd.ms-excel.sheet.binary.macroEnabled.12": "x-office/spreadsheet",
"application/vnd.ms-excel.sheet.macroEnabled.12": "x-office/spreadsheet",
"application/vnd.ms-excel.template.macroEnabled.12": "x-office/spreadsheet",
- "application/vnd.ms-fontobject": "image",
+ "application/vnd.ms-fontobject": "font",
"application/vnd.ms-powerpoint": "x-office/presentation",
"application/vnd.ms-powerpoint.addin.macroEnabled.12": "x-office/presentation",
"application/vnd.ms-powerpoint.presentation.macroEnabled.12": "x-office/presentation",
@@ -52,56 +49,48 @@ OC.MimeTypeList={
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "x-office/document",
"application/vnd.openxmlformats-officedocument.wordprocessingml.template": "x-office/document",
"application/x-7z-compressed": "package/x-generic",
- "application/x-cbr": "text",
"application/x-compressed": "package/x-generic",
"application/x-dcraw": "image",
"application/x-deb": "package/x-generic",
- "application/x-font": "image",
+ "application/x-font": "font",
"application/x-gimp": "image",
"application/x-gzip": "package/x-generic",
"application/x-perl": "text/code",
"application/x-photoshop": "image",
"application/x-php": "text/code",
"application/x-rar-compressed": "package/x-generic",
- "application/x-shockwave-flash": "application",
"application/x-tar": "package/x-generic",
"application/x-tex": "text",
"application/xml": "text/html",
"application/yaml": "text/code",
"application/zip": "package/x-generic",
- "database": "file",
"httpd/unix-directory": "dir",
- "image/svg+xml": "image",
- "image/vector": "image",
+ "image/svg+xml": "image/vector",
"text/css": "text/code",
"text/csv": "x-office/spreadsheet",
- "text/html": "text/code",
- "text/x-c": "text/code",
- "text/x-h": "text/code",
- "text/x-python": "text/code",
- "text/x-shellscript": "text/code",
- "web": "text/code"
+ "text/x-shellscript": "text/code"
},
files: [
- "video",
+ "application-pdf",
+ "application",
+ "audio",
+ "file",
"folder-drag-accept",
+ "folder-external",
"folder-public",
+ "folder-shared",
+ "folder-starred",
+ "folder",
+ "image",
"package-x-generic",
- "folder-external",
- "text-vcard",
- "application",
+ "text-calendar",
"text-code",
- "x-office-spreadsheet",
- "application-pdf",
- "folder",
+ "text-vcard",
+ "text",
+ "video",
"x-office-document",
- "text-calendar",
"x-office-presentation",
- "file",
- "text",
- "folder-shared",
- "image",
- "audio"
+ "x-office-spreadsheet"
],
themes: []
};
diff --git a/core/js/oc-dialogs.js b/core/js/oc-dialogs.js
index 361cf2dff67..38b91be9d2e 100644
--- a/core/js/oc-dialogs.js
+++ b/core/js/oc-dialogs.js
@@ -400,6 +400,11 @@ var OCdialogs = {
$replacementDiv.find('.icon').css('background-image','url(' + path + ')');
}
);
+ // connect checkboxes with labels
+ var checkboxId = $conflicts.find('.conflict').length;
+ $originalDiv.find('input:checkbox').attr('id', 'checkbox_original_'+checkboxId);
+ $replacementDiv.find('input:checkbox').attr('id', 'checkbox_replacement_'+checkboxId);
+
$conflicts.append($conflict);
//set more recent mtime bold
diff --git a/core/js/share.js b/core/js/share.js
index a2e6e6af0fc..1131ae8f112 100644
--- a/core/js/share.js
+++ b/core/js/share.js
@@ -395,7 +395,7 @@ OC.Share = _.extend(OC.Share || {}, {
attributes: {
'data-item-source-name': filename,
'data-item-type': itemType,
- 'data-item-soruce': itemSource
+ 'data-item-source': itemSource
}
});
dialogView.setShowLink(link);
diff --git a/core/js/sharedialogview.js b/core/js/sharedialogview.js
index 2b61dab3ceb..57743118f28 100644
--- a/core/js/sharedialogview.js
+++ b/core/js/sharedialogview.js
@@ -176,6 +176,9 @@
$shareField.autocomplete({
minLength: 2,
delay: 750,
+ focus: function(event) {
+ event.preventDefault();
+ },
source: this.autocompleteHandler,
select: this._onSelectRecipient
}).data('ui-autocomplete')._renderItem = this.autocompleteRenderItem;
diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js
index ff0d3a6d800..13396670aae 100644
--- a/core/js/shareitemmodel.js
+++ b/core/js/shareitemmodel.js
@@ -50,7 +50,7 @@
* @property {string} token
* @property {string} share_with
* @property {string} share_with_displayname
- * @property {string} share_mail_send
+ * @property {string} mail_send
* @property {OC.Share.Types.Collection|undefined} collection
* @property {Date} expiration optional?
* @property {number} stime optional?
@@ -64,6 +64,15 @@
*/
/**
+ * These properties are sometimes returned by the server as strings instead
+ * of integers, so we need to convert them accordingly...
+ */
+ var SHARE_RESPONSE_INT_PROPS = [
+ 'id', 'file_parent', 'mail_send', 'file_source', 'item_source', 'permissions',
+ 'storage', 'share_type', 'parent', 'stime'
+ ];
+
+ /**
* @class OCA.Share.ShareItemModel
* @classdesc
*
@@ -288,8 +297,7 @@
* @returns {boolean}
*/
hasUserShares: function() {
- var shares = this.get('shares');
- return _.isArray(shares) && shares.length > 0;
+ return this.getSharesWithCurrentItem().length > 0;
},
/**
@@ -399,6 +407,20 @@
},
/**
+ * Returns all share entries that only apply to the current item
+ * (file/folder)
+ *
+ * @return {Array.<OC.Share.Types.ShareInfo>}
+ */
+ getSharesWithCurrentItem: function() {
+ var shares = this.get('shares') || [];
+ var fileId = this.fileInfoModel.get('id');
+ return _.filter(shares, function(share) {
+ return share.item_source === fileId;
+ });
+ },
+
+ /**
* @param shareIndex
* @returns {string}
*/
@@ -462,7 +484,7 @@
if(!_.isObject(share)) {
throw "Unknown Share";
}
- return share.share_mail_send === '1';
+ return share.mail_send === 1;
},
/**
@@ -618,6 +640,8 @@
var fileId = this.fileInfoModel.get('id');
if (!shares || !shares.length) {
delete OC.Share.statuses[fileId];
+ OC.Share.currentShares = {};
+ OC.Share.itemShares = [];
return;
}
@@ -671,7 +695,19 @@
}
/** @type {OC.Share.Types.ShareInfo[]} **/
- var shares = _.toArray(data.shares);
+ var shares = _.map(data.shares, function(share) {
+ // properly parse some values because sometimes the server
+ // returns integers as string...
+ var i;
+ for (i = 0; i < SHARE_RESPONSE_INT_PROPS.length; i++) {
+ var prop = SHARE_RESPONSE_INT_PROPS[i];
+ if (!_.isUndefined(share[prop])) {
+ share[prop] = parseInt(share[prop], 10);
+ }
+ }
+ return share;
+ });
+
this._legacyFillCurrentShares(shares);
var linkShare = { isLinkShare: false };
diff --git a/core/js/tests/specs/shareitemmodelSpec.js b/core/js/tests/specs/shareitemmodelSpec.js
index c1d820052e2..b4403e28475 100644
--- a/core/js/tests/specs/shareitemmodelSpec.js
+++ b/core/js/tests/specs/shareitemmodelSpec.js
@@ -169,7 +169,7 @@ describe('OC.Share.ShareItemModel', function() {
/* jshint camelcase: false */
shares: [{
displayname_owner: 'root',
- expiration: 1111,
+ expiration: '2015-10-12 00:00:00',
file_source: 123,
file_target: '/folder',
id: 20,
@@ -187,7 +187,7 @@ describe('OC.Share.ShareItemModel', function() {
uid_owner: 'root'
}, {
displayname_owner: 'root',
- expiration: 2222,
+ expiration: '2015-10-15 00:00:00',
file_source: 456,
file_target: '/file_in_folder.txt',
id: 21,
@@ -249,10 +249,7 @@ describe('OC.Share.ShareItemModel', function() {
it('allows owner to share their own share when they are also the recipient', function() {
OC.currentUser = 'user1';
loadItemStub.yields({
- reshare: {
- permissions: OC.PERMISSION_READ,
- uid_owner: 'user1'
- },
+ reshare: {},
shares: []
});
@@ -261,6 +258,108 @@ describe('OC.Share.ShareItemModel', function() {
// sharing still allowed
expect(model.get('permissions') & OC.PERMISSION_SHARE).toEqual(OC.PERMISSION_SHARE);
});
+ it('properly parses integer values when the server is in the mood of returning ints as string', function() {
+ loadItemStub.yields({
+ reshare: {},
+ shares: [{
+ displayname_owner: 'root',
+ expiration: '2015-10-12 00:00:00',
+ file_source: '123',
+ file_target: '/folder',
+ id: '20',
+ item_source: '123',
+ item_type: 'file',
+ mail_send: '0',
+ parent: '999',
+ path: '/folder',
+ permissions: '' + OC.PERMISSION_READ,
+ share_type: '' + OC.Share.SHARE_TYPE_USER,
+ share_with: 'user1',
+ stime: '1403884258',
+ storage: '1',
+ token: 'tehtoken',
+ uid_owner: 'root'
+ }]
+ });
+
+ model.fetch();
+
+ var shares = model.get('shares');
+ expect(shares.length).toEqual(1);
+
+ var share = shares[0];
+ expect(share.id).toEqual(20);
+ expect(share.file_source).toEqual(123);
+ expect(share.file_target).toEqual('/folder');
+ expect(share.item_source).toEqual(123);
+ expect(share.item_type).toEqual('file');
+ expect(share.displayname_owner).toEqual('root');
+ expect(share.mail_send).toEqual(0);
+ expect(share.parent).toEqual(999);
+ expect(share.path).toEqual('/folder');
+ expect(share.permissions).toEqual(OC.PERMISSION_READ);
+ expect(share.share_type).toEqual(OC.Share.SHARE_TYPE_USER);
+ expect(share.share_with).toEqual('user1');
+ expect(share.stime).toEqual(1403884258);
+ expect(share.expiration).toEqual('2015-10-12 00:00:00');
+ });
+ });
+ describe('hasUserShares', function() {
+ it('returns false when no user shares exist', function() {
+ loadItemStub.yields({
+ reshare: {},
+ shares: []
+ });
+
+ model.fetch();
+
+ expect(model.hasUserShares()).toEqual(false);
+ });
+ it('returns true when user shares exist on the current item', function() {
+ loadItemStub.yields({
+ reshare: {},
+ shares: [{
+ id: 1,
+ share_type: OC.Share.SHARE_TYPE_USER,
+ share_with: 'user1',
+ item_source: '123'
+ }]
+ });
+
+ model.fetch();
+
+ expect(model.hasUserShares()).toEqual(true);
+ });
+ it('returns true when group shares exist on the current item', function() {
+ loadItemStub.yields({
+ reshare: {},
+ shares: [{
+ id: 1,
+ share_type: OC.Share.SHARE_TYPE_GROUP,
+ share_with: 'group1',
+ item_source: '123'
+ }]
+ });
+
+ model.fetch();
+
+ expect(model.hasUserShares()).toEqual(true);
+ });
+ it('returns false when share exist on parent item', function() {
+ loadItemStub.yields({
+ reshare: {},
+ shares: [{
+ id: 1,
+ share_type: OC.Share.SHARE_TYPE_GROUP,
+ share_with: 'group1',
+ item_source: '111'
+ }]
+ });
+
+ model.fetch();
+
+ expect(model.hasUserShares()).toEqual(false);
+ });
});
describe('Util', function() {