Skip to content

Commit

Permalink
Allow to have mutliple buttons on the filepicker
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen authored and rullzer committed Dec 9, 2019
1 parent e35a31f commit aa790a3
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 18 deletions.
2 changes: 1 addition & 1 deletion core/js/dist/login.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/js/dist/login.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/js/dist/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/js/dist/main.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/js/dist/maintenance.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/js/dist/maintenance.js.map

Large diffs are not rendered by default.

37 changes: 25 additions & 12 deletions core/src/OC/dialogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const Dialogs = {
FILEPICKER_TYPE_MOVE: 2,
FILEPICKER_TYPE_COPY: 3,
FILEPICKER_TYPE_COPY_MOVE: 4,
FILEPICKER_TYPE_CUSTOM: 5,

// used to name each dialog
dialogsCounter: 0,
Expand Down Expand Up @@ -446,6 +447,16 @@ const Dialogs = {
click: chooseCallback,
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 {
if (type === Dialogs.FILEPICKER_TYPE_COPY || type === Dialogs.FILEPICKER_TYPE_COPY_MOVE) {
buttonlist.push({
Expand Down Expand Up @@ -1253,18 +1264,20 @@ const Dialogs = {
var moveText = dir === '' ? t('core', 'Move') : t('core', 'Move to {folder}', { folder: dir })
var buttons = $('.oc-dialog-buttonrow button')
switch (type) {
case this.FILEPICKER_TYPE_CHOOSE:
break
case this.FILEPICKER_TYPE_COPY:
buttons.text(copyText)
break
case this.FILEPICKER_TYPE_MOVE:
buttons.text(moveText)
break
case this.FILEPICKER_TYPE_COPY_MOVE:
buttons.eq(0).text(copyText)
buttons.eq(1).text(moveText)
break
case this.FILEPICKER_TYPE_CHOOSE:
break
case this.FILEPICKER_TYPE_CUSTOM:
break
case this.FILEPICKER_TYPE_COPY:
buttons.text(copyText)
break
case this.FILEPICKER_TYPE_MOVE:
buttons.text(moveText)
break
case this.FILEPICKER_TYPE_COPY_MOVE:
buttons.eq(0).text(copyText)
buttons.eq(1).text(moveText)
break
}
}
}
Expand Down

0 comments on commit aa790a3

Please sign in to comment.