Let users pick folders on projectstags/v17.0.0beta3
!function(e){var n={};function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var i in e)t.d(r,i,function(n){return e[n]}.bind(null,i));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="/js/",t(t.s=0)}([function(e,n,r){r.p=OC.linkTo("files_sharing","js/dist/"),r.nc=btoa(OC.requestToken),window.OCP.Collaboration.registerType("file",{action:function(){return new Promise(function(e,n){OC.dialogs.filepicker(t("files_sharing","Link to a file"),function(t){OC.Files.getClient().getFileInfo(t).then(function(n,t){e(t.id)},function(){n()})},!1)})},typeString:t("files_sharing","Link to a file"),typeIconClass:"icon-files-dark"})}]); | |||||
!function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(r,o,function(n){return e[n]}.bind(null,o));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="/js/",t(t.s=0)}([function(e,n,r){r.p=OC.linkTo("files_sharing","js/dist/"),r.nc=btoa(OC.requestToken),window.OCP.Collaboration.registerType("file",{action:function(){return new Promise(function(e,n){OC.dialogs.filepicker(t("files_sharing","Link to a file"),function(t){OC.Files.getClient().getFileInfo(t).then(function(n,t){e(t.id)}).fail(function(){n()})},!1,null,!1,OC.dialogs.FILEPICKER_TYPE_CHOOSE,"",{allowDirectoryChooser:!0})})},typeString:t("files_sharing","Link to a file"),typeIconClass:"icon-files-dark"})}]); | |||||
//# sourceMappingURL=collaboration.js.map | //# sourceMappingURL=collaboration.js.map |
const client = OC.Files.getClient(); | const client = OC.Files.getClient(); | ||||
client.getFileInfo(f).then((status, fileInfo) => { | client.getFileInfo(f).then((status, fileInfo) => { | ||||
resolve(fileInfo.id); | resolve(fileInfo.id); | ||||
}, () => { | |||||
}).fail(() => { | |||||
reject(); | reject(); | ||||
}); | }); | ||||
}, false); | |||||
}, false, null, false, OC.dialogs.FILEPICKER_TYPE_CHOOSE, '', { allowDirectoryChooser: true }); | |||||
}); | }); | ||||
}, | }, | ||||
typeString: t('files_sharing', 'Link to a file'), | typeString: t('files_sharing', 'Link to a file'), |
* @param modal make the dialog modal | * @param modal make the dialog modal | ||||
* @param type Type of file picker : Choose, copy, move, copy and move | * @param type Type of file picker : Choose, copy, move, copy and move | ||||
* @param path path to the folder that the the file can be picket from | * @param path path to the folder that the the file can be picket from | ||||
* @param options additonal options that need to be set | |||||
*/ | */ | ||||
filepicker: function (title, callback, multiselect, mimetypeFilter, modal, type, path) { | |||||
filepicker: function (title, callback, multiselect, mimetypeFilter, modal, type, path, options) { | |||||
var self = this; | var self = this; | ||||
this.filepicker.sortField = 'name'; | this.filepicker.sortField = 'name'; | ||||
this.filelist = null; | this.filelist = null; | ||||
path = path || ''; | path = path || ''; | ||||
options = Object.assign({ | |||||
allowDirectoryChooser: false | |||||
}, options) | |||||
$.when(this._getFilePickerTemplate()).then(function ($tmpl) { | $.when(this._getFilePickerTemplate()).then(function ($tmpl) { | ||||
self.filepicker.loading = false; | self.filepicker.loading = false; | ||||
nameCol: t('core', 'Name'), | nameCol: t('core', 'Name'), | ||||
sizeCol: t('core', 'Size'), | sizeCol: t('core', 'Size'), | ||||
modifiedCol: t('core', 'Modified') | modifiedCol: t('core', 'Modified') | ||||
}).data('path', path).data('multiselect', multiselect).data('mimetype', mimetypeFilter); | |||||
}).data('path', path).data('multiselect', multiselect).data('mimetype', mimetypeFilter).data('allowDirectoryChooser', options.allowDirectoryChooser) | |||||
if (modal === undefined) { | if (modal === undefined) { | ||||
modal = false; | modal = false; | ||||
// Hence this is one of the approach to get the choose button. | // Hence this is one of the approach to get the choose button. | ||||
var getOcDialog = self.$filePicker.closest('.oc-dialog'); | var getOcDialog = self.$filePicker.closest('.oc-dialog'); | ||||
var buttonEnableDisable = getOcDialog.find('.primary'); | var buttonEnableDisable = getOcDialog.find('.primary'); | ||||
if (self.$filePicker.data('mimetype').indexOf("httpd/unix-directory") !== -1) { | |||||
if (self.$filePicker.data('mimetype').indexOf("httpd/unix-directory") !== -1 && !self.$filePicker.data('.allowDirectoryChooser')) { | |||||
buttonEnableDisable.prop("disabled", false); | buttonEnableDisable.prop("disabled", false); | ||||
} else { | } else { | ||||
buttonEnableDisable.prop("disabled", true); | buttonEnableDisable.prop("disabled", true); | ||||
} else if ($element.data('type') === 'dir') { | } else if ($element.data('type') === 'dir') { | ||||
this._fillFilePicker(this.$filePicker.data('path') + '/' + $element.data('entryname')); | this._fillFilePicker(this.$filePicker.data('path') + '/' + $element.data('entryname')); | ||||
this._changeButtonsText(type, $element.data('entryname')); | this._changeButtonsText(type, $element.data('entryname')); | ||||
if (this.$filePicker.data('mimetype').indexOf("httpd/unix-directory") !== -1) { | |||||
if (this.$filePicker.data('mimetype').indexOf("httpd/unix-directory") !== -1 || this.$filePicker.data('allowDirectoryChooser')) { | |||||
buttonEnableDisable.prop("disabled", false); | buttonEnableDisable.prop("disabled", false); | ||||
} else { | } else { | ||||
buttonEnableDisable.prop("disabled", true); | buttonEnableDisable.prop("disabled", true); |