Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MONUI-107: Fix callflow preview for branched flows and missing captions #109

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1000,24 +1000,25 @@ define(function(require) {
},

// Callflow JS code
buildFlow: function(json, parent, id, key) {
buildFlow: function(json, parent, id, key, caption_map) {
var self = this,
branch = self.branch(self.construct_action(json));
branch = self.branch(self.construct_action(json)),
_caption_map = caption_map || self.flow.caption_map || {}; // Normal render stores the caption_map in self.flow instead of passing it in.

branch.data.data = _.get(json, 'data', {});
branch.id = ++id;
branch.key = key;
branch.disabled = _.get(json, 'data.skip_module');

branch.caption = self.actions.hasOwnProperty(branch.actionName) ? self.actions[branch.actionName].caption(branch, self.flow.caption_map) : '';
branch.caption = self.actions.hasOwnProperty(branch.actionName) ? self.actions[branch.actionName].caption(branch, _caption_map) : '';

if (self.actions.hasOwnProperty(parent.actionName) && self.actions[parent.actionName].hasOwnProperty('key_caption')) {
branch.key_caption = self.actions[parent.actionName].key_caption(branch, self.flow.caption_map);
branch.key_caption = self.actions[parent.actionName].key_caption(branch, _caption_map);
}

if (json.hasOwnProperty('children')) {
$.each(json.children, function(key, child) {
branch = self.buildFlow(child, branch, id, key);
branch = self.buildFlow(child, branch, id, key, _caption_map);
});
}

Expand Down Expand Up @@ -1342,9 +1343,10 @@ define(function(require) {
flow.caption_map = callflow.metadata;

if (callflow.flow.module !== undefined) {
flow.root = self.buildFlow(callflow.flow, flow.root, 0, '_');
flow.root = self.buildFlow(callflow.flow, flow.root, 0, '_', flow.caption_map);
}

flow.root.index(0); // Re-index nodes to handle branched flows
flow.nodes = flow.root.nodes();
flow.numbers = callflow.numbers || [];

Expand Down Expand Up @@ -1392,6 +1394,11 @@ define(function(require) {
}));
}
$(this).append(node_html);

// Remove click handler bound to key-captions in renderBranch()
// because we don't want to be able to edit anything here
$('.div_option', layout).off('click');

});
}
});
Expand Down
1 change: 1 addition & 0 deletions style/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@

#ws_callflow .module,
.callflow-preview .module {
position: relative;
font-size: 13px;
height: 59px;
margin-top: 25px;
Expand Down