Skip to content

Commit

Permalink
Permant Buttons and Lists can now be configured to disable once the c…
Browse files Browse the repository at this point in the history
…onversation moves on
  • Loading branch information
jolzee committed Nov 6, 2020
1 parent 28910e9 commit a4f85cd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/components/ChatTeneoResponse.vue
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@
min-height="25"
class="option-btn mr-2 mt-2"
x-small
:disabled="hasPermanentOptions && !isLastItem && shouldDisable ? true : false"
:color="option.color || `success ${textColor('success')}`"
:aria-label="option.aria ? option.aria : option.name"
@click="optionClicked(option)"
Expand Down Expand Up @@ -766,6 +767,19 @@ export default {
// history in session storage
return this.getLatestDialogHistory ? this.getLatestDialogHistory : [];
},
shouldDisable() {
const extensions = this.itemExtensions(this.item);
let shouldDisable = false;
extensions.forEach(extension => {
if (String(extension.name).startsWith("displayCollection")) {
logger.info(`Buttons are going to be disabled when not last`, extension);
if (extension.disabled !== "undefined") {
shouldDisable = extension.disabled;
}
}
});
return shouldDisable;
},
hasPermanentOptions() {
const extensions = this.itemExtensions(this.item);
let hasPermanentOptions = false;
Expand Down
6 changes: 5 additions & 1 deletion src/teneo-assets/ExtensionHelper.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,18 @@ class ExtensionHelper {

static String displayClickableList(Map config) {
Map attachment = ['name' : 'displayCollection', 'hasLongOptions': config.get('hasLongOptions', false),
'permanent': config.get('permanent', false), 'parameters': ['content': config.content]]
'permanent': config.get('permanent', false), 'disabled': config.get('disabled', false), 'parameters': ['content': config.content]]
JsonOutput.toJson(attachment)
}

static String displayPermanentClickableList(def content, def channel, boolean hasLongOptions = false) {
return displayClickableList(['content': content, hasLongOptions: hasLongOptions, 'permanent': true] as Map)
}

static String displayPermanentDisabledClickableList(def content, def channel, boolean hasLongOptions = false) {
return displayClickableList(['content': content, hasLongOptions: hasLongOptions, 'permanent': true, 'disabled': true] as Map)
}

static String displayClickableList(def content, def channel, def hasLongOptions = false) {
return displayClickableList(['content': content, hasLongOptions: hasLongOptions, 'permanent': false] as Map)
}
Expand Down

0 comments on commit a4f85cd

Please sign in to comment.