Merge pull request #17260 from nextcloud/feature/noid/filepicker-allow-multiple-buttons

Allow to have mutliple buttons on the filepicker
This commit is contained in:
Roeland Jago Douma 2019-12-10 09:05:48 +01:00 committed by GitHub
commit b78a141b0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 31 additions and 18 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -41,6 +41,7 @@ const Dialogs = {
FILEPICKER_TYPE_MOVE: 2, FILEPICKER_TYPE_MOVE: 2,
FILEPICKER_TYPE_COPY: 3, FILEPICKER_TYPE_COPY: 3,
FILEPICKER_TYPE_COPY_MOVE: 4, FILEPICKER_TYPE_COPY_MOVE: 4,
FILEPICKER_TYPE_CUSTOM: 5,
// used to name each dialog // used to name each dialog
dialogsCounter: 0, dialogsCounter: 0,
@ -446,6 +447,16 @@ const Dialogs = {
click: chooseCallback, click: chooseCallback,
defaultButton: true defaultButton: true
}) })
} else if (type === Dialogs.FILEPICKER_TYPE_CUSTOM) {
options.buttons.forEach(function(button) {
buttonlist.push({
text: button.text,
click: function() {
functionToCall(button.type)
},
defaultButton: button.defaultButton
})
})
} else { } else {
if (type === Dialogs.FILEPICKER_TYPE_COPY || type === Dialogs.FILEPICKER_TYPE_COPY_MOVE) { if (type === Dialogs.FILEPICKER_TYPE_COPY || type === Dialogs.FILEPICKER_TYPE_COPY_MOVE) {
buttonlist.push({ buttonlist.push({
@ -1253,18 +1264,20 @@ const Dialogs = {
var moveText = dir === '' ? t('core', 'Move') : t('core', 'Move to {folder}', { folder: dir }) var moveText = dir === '' ? t('core', 'Move') : t('core', 'Move to {folder}', { folder: dir })
var buttons = $('.oc-dialog-buttonrow button') var buttons = $('.oc-dialog-buttonrow button')
switch (type) { switch (type) {
case this.FILEPICKER_TYPE_CHOOSE: case this.FILEPICKER_TYPE_CHOOSE:
break break
case this.FILEPICKER_TYPE_COPY: case this.FILEPICKER_TYPE_CUSTOM:
buttons.text(copyText) break
break case this.FILEPICKER_TYPE_COPY:
case this.FILEPICKER_TYPE_MOVE: buttons.text(copyText)
buttons.text(moveText) break
break case this.FILEPICKER_TYPE_MOVE:
case this.FILEPICKER_TYPE_COPY_MOVE: buttons.text(moveText)
buttons.eq(0).text(copyText) break
buttons.eq(1).text(moveText) case this.FILEPICKER_TYPE_COPY_MOVE:
break buttons.eq(0).text(copyText)
buttons.eq(1).text(moveText)
break
} }
} }
} }