Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
init() {
this._super(...arguments);
// setup child views. be sure to clone the child views array first
// 2.0TODO: Remove Ember.A() here
this.childViews = emberA(this.childViews.slice());
this.ownerView = this.ownerView || this;
},
groupedContent: computed('optionGroupPath', 'content.[]', function() {
var groupPath = get(this, 'optionGroupPath');
var groupedContent = emberA();
var content = get(this, 'content') || [];
content.forEach((item) => {
var label = get(item, groupPath);
if (get(groupedContent, 'lastObject.label') !== label) {
groupedContent.pushObject({
label: label,
content: emberA()
});
}
get(groupedContent, 'lastObject.content').push(item);
});
return groupedContent;
content.forEach((item) => {
var label = get(item, groupPath);
if (get(groupedContent, 'lastObject.label') !== label) {
groupedContent.pushObject({
label: label,
content: emberA()
});
}
get(groupedContent, 'lastObject.content').push(item);
});
replace(idx, removedCount, addedViews) {
var addedCount = addedViews ? get(addedViews, 'length') : 0;
var self = this;
Ember.assert("You can't add a child to a container - the child is already a child of another view", emberA(addedViews).every(function(item) { return !item._parentView || item._parentView === self; }));
this.arrayContentWillChange(idx, removedCount, addedCount);
this.childViewsWillChange(this._childViews, idx, removedCount);
if (addedCount === 0) {
this._childViews.splice(idx, removedCount);
} else {
var args = [idx, removedCount].concat(addedViews);
if (addedViews.length && !this._childViews.length) { this._childViews = this._childViews.slice(); }
this._childViews.splice.apply(this._childViews, args);
}
this.arrayContentDidChange(idx, removedCount, addedCount);
this.childViewsDidChange(this._childViews, idx, removedCount, addedCount);
return this;
replace: function(idx, removedCount, addedViews) {
var addedCount = addedViews ? get(addedViews, 'length') : 0;
var self = this;
Ember.assert("You can't add a child to a container - the child is already a child of another view", emberA(addedViews).every(function(item) { return !get(item, '_parentView') || get(item, '_parentView') === self; }));
this.arrayContentWillChange(idx, removedCount, addedCount);
this.childViewsWillChange(this._childViews, idx, removedCount);
if (addedCount === 0) {
this._childViews.splice(idx, removedCount) ;
} else {
var args = [idx, removedCount].concat(addedViews);
if (addedViews.length && !this._childViews.length) { this._childViews = this._childViews.slice(); }
this._childViews.splice.apply(this._childViews, args);
}
this.arrayContentDidChange(idx, removedCount, addedCount);
this.childViewsDidChange(this._childViews, idx, removedCount, addedCount);
return this;
selectionDidChange: observer('selection.[]', function() {
var selection = get(this, 'selection');
if (get(this, 'multiple')) {
if (!isArray(selection)) {
set(this, 'selection', emberA([selection]));
return;
}
this._selectionDidChangeMultiple();
} else {
this._selectionDidChangeSingle();
}
}),