Skip to content

Commit

Permalink
BUILD 2017.05.01-004
Browse files Browse the repository at this point in the history
- Fixed issue with embed select dropdown repopulating with all embed
types after making a selection from a limited list of embed types
  • Loading branch information
rpeterman-gp committed May 1, 2017
1 parent c8a5630 commit f223441
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 15 deletions.
23 changes: 18 additions & 5 deletions dist/js/embed-containers.js
Original file line number Diff line number Diff line change
Expand Up @@ -882,17 +882,22 @@ var EntityEmbed = EntityEmbed || {};

$.fn.openModal = function(addToScope){
var modalCtrl = $.data(this[0], 'ctrl');
var modalScope;

// TODO : decrease cyclomatic complexity
if (!!modalCtrl)
{
if (!!addToScope)
{
var currentScope = modalCtrl.$el.data('scope');
var newScope = $.extend(true, {}, currentScope, addToScope);
modalCtrl.$el.data('scope', newScope);
modalScope = $.extend(true, {}, currentScope, addToScope);
modalCtrl.$el.data('scope', modalScope);
}
else
{
modalScope = modalCtrl.$el.data('scope');
}

var modalScope = modalCtrl.$el.data('scope');
modalCtrl.promise = $.Deferred();

modalCtrl.options.functions.open.before(modalScope);
Expand Down Expand Up @@ -1181,9 +1186,9 @@ var EntityEmbed = EntityEmbed || {};
et = scope.embedTypes[i];

// Only add embed types in scope.embedTypeSelectOptions
if(limitEmbedOptions)
if(scope.selectableEMbedTypes)
{
if(embedType.indexOf(et.options.object_type) !== -1)
if(scope.selectableEMbedTypes.indexOf(et.options.object_type) !== -1)
{
addEmbedTypeOption(et);
}
Expand Down Expand Up @@ -1696,7 +1701,13 @@ var EntityEmbed = EntityEmbed || {};
before: function(scope){
toggleEditorTyping(scope, "false");

delete scope.selectableEMbedTypes;

if (!!scope.embedType){
if(typeof scope.embedType !== 'string')
{
scope.selectableEMbedTypes = scope.embedType;
}
setModalView(scope, scope.embedType);
delete scope.embedType;
}
Expand Down Expand Up @@ -1824,6 +1835,7 @@ var EntityEmbed = EntityEmbed || {};
}
}
// no changes made OR leave already confirmed - okay to close without prompting user
scope.currentEmbedType.$view.hide();
scope.currentEmbedType.clearForm(scope.currentEmbedType.$view);
delete scope.confirmedLeave;
return true;
Expand All @@ -1848,6 +1860,7 @@ var EntityEmbed = EntityEmbed || {};
embedType: scope.currentEmbedType
});

scope.currentEmbedType.$view.hide();
scope.currentEmbedType.clearForm(scope.currentEmbedType.$view);
}
}
Expand Down
10 changes: 5 additions & 5 deletions dist/js/embed-containers.min.js

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions src/js/embedModalDefaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ var EntityEmbed = EntityEmbed || {};
et = scope.embedTypes[i];

// Only add embed types in scope.embedTypeSelectOptions
if(limitEmbedOptions)
if(scope.selectableEMbedTypes)
{
if(embedType.indexOf(et.options.object_type) !== -1)
if(scope.selectableEMbedTypes.indexOf(et.options.object_type) !== -1)
{
addEmbedTypeOption(et);
}
Expand Down Expand Up @@ -639,7 +639,13 @@ var EntityEmbed = EntityEmbed || {};
before: function(scope){
toggleEditorTyping(scope, "false");

delete scope.selectableEMbedTypes;

if (!!scope.embedType){
if(typeof scope.embedType !== 'string')
{
scope.selectableEMbedTypes = scope.embedType;
}
setModalView(scope, scope.embedType);
delete scope.embedType;
}
Expand Down Expand Up @@ -767,6 +773,7 @@ var EntityEmbed = EntityEmbed || {};
}
}
// no changes made OR leave already confirmed - okay to close without prompting user
scope.currentEmbedType.$view.hide();
scope.currentEmbedType.clearForm(scope.currentEmbedType.$view);
delete scope.confirmedLeave;
return true;
Expand All @@ -791,6 +798,7 @@ var EntityEmbed = EntityEmbed || {};
embedType: scope.currentEmbedType
});

scope.currentEmbedType.$view.hide();
scope.currentEmbedType.clearForm(scope.currentEmbedType.$view);
}
}
Expand Down
11 changes: 8 additions & 3 deletions src/js/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,22 @@

$.fn.openModal = function(addToScope){
var modalCtrl = $.data(this[0], 'ctrl');
var modalScope;

// TODO : decrease cyclomatic complexity
if (!!modalCtrl)
{
if (!!addToScope)
{
var currentScope = modalCtrl.$el.data('scope');
var newScope = $.extend(true, {}, currentScope, addToScope);
modalCtrl.$el.data('scope', newScope);
modalScope = $.extend(true, {}, currentScope, addToScope);
modalCtrl.$el.data('scope', modalScope);
}
else
{
modalScope = modalCtrl.$el.data('scope');
}

var modalScope = modalCtrl.$el.data('scope');
modalCtrl.promise = $.Deferred();

modalCtrl.options.functions.open.before(modalScope);
Expand Down

0 comments on commit f223441

Please sign in to comment.