Skip to content
This repository was archived by the owner on Apr 5, 2023. It is now read-only.

Commit ebcc0e2

Browse files
authored
[DEPRECATIONS] Remove deprecations raised with Ember 1.13 (#311)
Add `ember-cli-deprecation-workflow` to silence known deprecations. Also update default to Ember 1.13. The remaining deprecations are mostly linked to `Ember.View`.
1 parent 607f175 commit ebcc0e2

30 files changed

Lines changed: 183 additions & 155 deletions

addon/components/color-picker-dropdown.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default Ember.Component.extend(BodyEventListenerMixin, ColorPickerMixin,
3535
colorRows: Ember.computed(function() {
3636
return Ember.A();
3737
}),
38-
setCustomColorObserver: Ember.on('init', Ember.observer(function() {
38+
setCustomColorObserver: Ember.on('init', Ember.observer('selectedColor', 'colorRows', function() {
3939
var selectedColor;
4040
selectedColor = this.get('selectedColor');
4141
selectedColor = this.colorToHex(selectedColor);
@@ -45,7 +45,7 @@ export default Ember.Component.extend(BodyEventListenerMixin, ColorPickerMixin,
4545
return this.set('customColor', '');
4646
}
4747
return this.set('customColor', selectedColor);
48-
}, 'selectedColor', 'colorRows')),
48+
})),
4949
/**
5050
* This is the formatted string of the input color, for which a hashtag "#"
5151
* is automatically added if it is not present.

addon/components/multi-select-component.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ export default SelectComponent.extend({
2222
// the input field, which is always visible. This helps reducing one tab
2323
// step to navigate back to the previous component
2424
tabindex: -1,
25-
values: Ember.computed(function(key, value) {
26-
var selections, valuePath;
27-
if (arguments.length === 2) {
25+
values: Ember.computed('selections.[]', {
26+
set(key, value) {
27+
var selections, valuePath;
2828
if (!value) {
2929
return;
3030
}
@@ -33,7 +33,9 @@ export default SelectComponent.extend({
3333
return value.contains(Ember.get(item, valuePath));
3434
})));
3535
return value;
36-
} else {
36+
},
37+
get() {
38+
var selections, valuePath;
3739
valuePath = this.get('optionValuePath');
3840
selections = this.get('selections');
3941
if (valuePath) {
@@ -42,7 +44,7 @@ export default SelectComponent.extend({
4244
return selections;
4345
}
4446
}
45-
}).property('selections.[]'),
47+
}),
4648
selectionItemView: MultiSelectOptionView,
4749

4850
// Invisible span used to make sure there is a good amount of room for either
@@ -98,7 +100,7 @@ export default SelectComponent.extend({
98100

99101
// uses single select's "selection" value - adds it to selections and
100102
// then clears the selection value so that it can be re-selected
101-
selectionDidChange: Ember.observer(function() {
103+
selectionDidChange: Ember.observer('selection', 'selections.[]', function() {
102104
var selection, selections;
103105
selections = this.get('selections');
104106
selection = this.get('selection');
@@ -109,7 +111,7 @@ export default SelectComponent.extend({
109111
if (!Ember.isEmpty(selection) && !selections.contains(selection)) {
110112
return selections.pushObject(selection);
111113
}
112-
}, 'selection', 'selections.[]'),
114+
}),
113115
focusTextField: function() {
114116
var ref;
115117
return (ref = this.$('.ember-text-field')) != null ? ref.focus() : void 0;

addon/components/select-component.js

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export default Ember.Component.extend(
162162
}
163163
return this._super();
164164
},
165-
updateDropdownLayout: Ember.observer(function() {
165+
updateDropdownLayout: Ember.observer('showDropdown', function() {
166166
var dropdownButton, dropdownButtonHeight, dropdownButtonOffset, dropdownMargin, dropdownMenu, dropdownMenuBottom, dropdownMenuHeight, dropdownMenuOffset, dropdownMenuWidth, dropupMenuTop;
167167
if ((this.get('_state') || this.get('state')) !== 'inDOM' || this.get('showDropdown') === false) {
168168
return;
@@ -202,7 +202,7 @@ export default Ember.Component.extend(
202202
if (highlightedIndex !== -1 && this.get('shouldEnsureVisible')) {
203203
Ember.run.schedule('afterRender', () => this.ensureVisible(highlightedIndex));
204204
}
205-
}, 'showDropdown'),
205+
}),
206206
onResizeEnd: function() {
207207
// We need to put this on the run loop, because the resize event came from
208208
// the window. Otherwise, we get a warning when used in the tests. You have
@@ -242,12 +242,12 @@ export default Ember.Component.extend(
242242
});
243243
}).property('itemView'),
244244

245-
optionLabelPathChanges: Ember.on('init', Ember.observer(function() {
245+
optionLabelPathChanges: Ember.on('init', Ember.observer('selection', 'optionLabelPath', function() {
246246
var labelPath, path;
247247
labelPath = this.get('optionLabelPath');
248248
path = labelPath ? "selection." + labelPath : 'selection';
249249
return Ember.defineProperty(this, 'selectedLabel', Ember.computed.alias(path));
250-
}, 'selection', 'optionLabelPath')),
250+
})),
251251

252252
searchView: DebouncedTextComponent.extend({
253253
placeholder: Ember.computed.alias('selectComponent.placeholder'),
@@ -256,7 +256,7 @@ export default Ember.Component.extend(
256256
// this in a run loop to wait for the event that triggers the showDropdown
257257
// to finishes before trying to focus the input. Otherwise, focus when be
258258
// "stolen" from us.
259-
showDropdownDidChange: Ember.observer(function() {
259+
showDropdownDidChange: Ember.observer('selectComponent.showDropdown', function() {
260260
// when closing, don't need to focus the now-hidden search box
261261
if (this.get('selectComponent.showDropdown')) {
262262
return Ember.run.schedule('afterRender', this, function() {
@@ -269,7 +269,7 @@ export default Ember.Component.extend(
269269
this.set('value', '');
270270
this.get('selectComponent').send('valueChanged', '');
271271
}
272-
}, 'selectComponent.showDropdown'),
272+
}),
273273

274274
/**
275275
Delegates to parent view (The select component) to propagate this data up.
@@ -394,22 +394,25 @@ export default Ember.Component.extend(
394394
contentIsEmpty: Ember.computed.empty('content'),
395395
hasNoResults: Ember.computed.and('isLoaded', 'filteredContentIsEmpty'),
396396

397-
value: Ember.computed(function(key, value) {
398-
var selection, valuePath, content;
399-
if (arguments.length === 2) {
397+
value: Ember.computed('selection', {
398+
set(key, value) {
399+
var selection, valuePath, content;
400400
valuePath = this.get('optionValuePath');
401401
selection = value;
402402
content = this.get('content');
403403
if (valuePath && content) {
404-
if (typeof content.findProperty === 'function') {
405-
selection = content.findProperty(valuePath, value);
404+
if (typeof content.findBy === 'function') {
405+
selection = content.findBy(valuePath, value);
406406
} else {
407407
selection = find(content, matchesProperty(valuePath, value));
408408
}
409409
}
410410
this.set('selection', selection);
411411
return value;
412-
} else {
412+
413+
},
414+
get() {
415+
var selection, valuePath;
413416
valuePath = this.get('optionValuePath');
414417
selection = this.get('selection');
415418
if (valuePath) {
@@ -418,7 +421,7 @@ export default Ember.Component.extend(
418421
return selection;
419422
}
420423
}
421-
}).property('selection'),
424+
}),
422425

423426
didInsertElement: function() {
424427
this._super();
@@ -463,7 +466,7 @@ export default Ember.Component.extend(
463466
customFilter: null,
464467

465468
// TODO(Peter): This needs to be rethought
466-
setDefaultSelection: Ember.observer(function() {
469+
setDefaultSelection: Ember.observer('content.[]', function() {
467470
var content, defaultPath;
468471

469472
// do not set default selection if selection is defined
@@ -475,10 +478,10 @@ export default Ember.Component.extend(
475478
if (!(content && defaultPath)) {
476479
return;
477480
}
478-
return this.set('selection', content.findProperty(defaultPath));
479-
}, 'content.[]'),
481+
return this.set('selection', content.findBy(defaultPath));
482+
}),
480483

481-
selectableOptionsDidChange: Ember.observer(function() {
484+
selectableOptionsDidChange: Ember.observer('selectableOptions.[]', 'showDropdown', function() {
482485
/*
483486
* If the dropdown is visible and the selected option is no longer
484487
* contained in the list of selectableOptions, then force the first
@@ -491,7 +494,7 @@ export default Ember.Component.extend(
491494
this.set('highlighted', selectableOptions.get('firstObject'));
492495
}
493496
}
494-
}, 'selectableOptions.[]', 'showDropdown'),
497+
}),
495498

496499
/*
497500
* SELECTION RELATED
@@ -520,23 +523,22 @@ export default Ember.Component.extend(
520523
shouldEnsureVisible: true,
521524

522525
// The option that is currently highlighted.
523-
highlighted: Ember.computed(function(key, value) {
524-
let content = this.get('selectableOptions') || Ember.A();
526+
highlighted: Ember.computed('selectableOptions.[]', 'highlightedIndex', 'shouldEnsureVisible', {
527+
set(key, value) {
528+
let content = this.get('selectableOptions') || Ember.A();
529+
let index = value ? content.indexOf(value) : -1;
530+
this.setHighlightedIndex(
531+
index,
532+
this.get('shouldEnsureVisible')
533+
);
534+
return value || [];
525535

526-
if (arguments.length === 1) {
527-
// Getter
536+
},
537+
get() {
538+
let content = this.get('selectableOptions') || Ember.A();
528539
return content.objectAt(this.get('highlightedIndex'));
529540
}
530-
531-
// Setter
532-
let index = value ? content.indexOf(value) : -1;
533-
this.setHighlightedIndex(
534-
index,
535-
this.get('shouldEnsureVisible')
536-
);
537-
return value || [];
538-
539-
}).property('selectableOptions.[]', 'highlightedIndex', 'shouldEnsureVisible'),
541+
}),
540542

541543
setFocus: function() {
542544
var activeElem, selectComponent;

addon/mixins/popover.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ export default Ember.Mixin.create(StyleBindingsMixin, BodyEventListener, {
4242
}).property('contentViewClass'),
4343
didInsertElement: function() {
4444
this._super();
45-
this.snapToPosition();
46-
this.set('visibility', 'visible');
47-
return this.set('isShowing', true);
45+
Ember.run.schedule('afterRender', this, () => {
46+
this.snapToPosition();
47+
this.set('visibility', 'visible');
48+
this.set('isShowing', true);
49+
});
4850
},
4951
willDestroyElement: function() {
5052
this.$().off($.support.transition.end);

addon/views/multi-select-option.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ export default Ember.View.extend({
66
classNames: 'ember-select-search-choice',
77
didInsertElement: function() {
88
this._super();
9-
return this.labelPathDidChange();
9+
this.labelPathDidChange();
1010
},
11-
labelPathDidChange: Ember.observer(function() {
11+
labelPathDidChange: Ember.observer('content', 'labelPath', function() {
1212
var labelPath, path;
1313
labelPath = this.get('labelPath');
1414
path = labelPath ? "content." + labelPath : 'content';
1515
Ember.defineProperty(this, 'label', Ember.computed.alias(path));
16-
return this.notifyPropertyChange('label');
17-
}, 'content', 'labelPath')
16+
this.notifyPropertyChange('label');
17+
})
1818
});

addon/views/select-option.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default Ember.View.extend({
1414
isHighlighted: Ember.computed(function() {
1515
return this.get('highlighted') === this.get('content');
1616
}).property('highlighted', 'content'),
17-
labelPathDidChange: Ember.on('init', Ember.observer(function() {
17+
labelPathDidChange: Ember.on('init', Ember.observer('content', 'labelPath', function() {
1818
var labelPath, path;
1919
labelPath = this.get('labelPath');
2020

@@ -26,7 +26,7 @@ export default Ember.View.extend({
2626
// 'context.#{labelPath}'
2727
Ember.defineProperty(this, 'label', Ember.computed.alias(path));
2828
return this.notifyPropertyChange('label');
29-
}, 'content', 'labelPath')),
29+
})),
3030
processDropDownShown: function() {
3131
return this.get('selectComponent').send('hideDropdown');
3232
},

app/templates/color-picker-dropdown.hbs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div class="dropdown open">
2-
<div {{bind-attr class=":dropdown-menu :color-picker-dropdown dropdownClass"}}
2+
<div class="dropdown-menu color-picker-dropdown {{dropdownClass}}"
33
role="menu" aria-labelledby="dLabel">
44
{{#each row in colorRows}}
55
<div class="color-row clearfix">
@@ -14,11 +14,11 @@
1414
<hr>
1515
{{/each}}
1616
<form {{action "setCustomColor" on="submit"}}
17-
{{bind-attr class=":color-picker-custom-form isCustomColorValid:valid:invalid"}}>
17+
class="color-picker-custom-form {{if isCustomColorValid 'valid' 'invalid'}}">
1818
<div class="input-group">
19-
<span {{bind-attr class=":input-group-addon
20-
:color-picker-custom-preview isCustomColor:active"
21-
style="customColorCSS"}} {{action "setCustomColor"}}>
19+
<span class="input-group-addon
20+
color-picker-custom-preview {{if isCustomColor 'active'}}"
21+
style={{customColorCSS}} {{action "setCustomColor"}}>
2222
</span>
2323
{{input valueBinding="customColor"
2424
class="form-control input-sm"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<div {{bind-attr style="view.style"}}>
1+
<div style={{view.style}}>
22
{{view.label}}
33
</div>

app/templates/modal-footer.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{{#if confirmText}}
22
<button type="button"
3-
{{bind-attr class=":btn :btn-primary :btn-confirm isDisabled:disabled" disabled="isDisabled"}}
3+
class="btn btn-primary btn-confirm {{if isDisabled 'disabled'}}" disabled={{isDisabled}}
44
{{action 'sendConfirm'}}>{{confirmText}}
55
</button>
66
{{/if}}

app/templates/modal.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div {{bind-attr class=":modal-dialog sizeClass"}} tabindex="-1">
1+
<div class="modal-dialog {{sizeClass}}" tabindex="-1">
22
<div class="modal-content">
33
<div class="modal-header {{headerClass}}">
44
{{view _headerViewClass}}

0 commit comments

Comments
 (0)