Skip to content

Commit

Permalink
refactor: migrate to RFC 176 style ES6 module imports
Browse files Browse the repository at this point in the history
Fixes #469
  • Loading branch information
RobbieTheWagner authored and buschtoens committed Aug 3, 2017
1 parent a60647a commit 6ee0592
Show file tree
Hide file tree
Showing 54 changed files with 229 additions and 313 deletions.
5 changes: 2 additions & 3 deletions addon/-private/global-options.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import Ember from 'ember';
import { merge } from '@ember/polyfills';
import config from 'ember-get-config';

// eslint-disable-next-line ember-suave/no-direct-property-access
const assign = Ember.assign || Ember.merge;
const globalOptions = config['ember-light-table'] || {};

export default globalOptions;

export function mergeOptionsWithGlobals(options) {
return assign(assign({}, globalOptions), options);
return merge(merge({}, globalOptions), options);
}
10 changes: 3 additions & 7 deletions addon/-private/sync-array-proxy.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import Ember from 'ember';

const {
ArrayProxy,
assert,
isArray
} = Ember;
import ArrayProxy from '@ember/array/proxy';
import { assert } from '@ember/debug';
import { isArray } from '@ember/array';

const EMPTY_ARRAY = [];

Expand Down
14 changes: 4 additions & 10 deletions addon/classes/Column.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import Ember from 'ember';
import { A as emberArray, makeArray } from '@ember/array';
import EmberObject, { computed } from '@ember/object';
import { isEmpty } from '@ember/utils';
import { guidFor } from '@ember/object/internals';
import fixProto from 'ember-light-table/utils/fix-proto';

const {
guidFor,
isEmpty,
makeArray,
computed,
A: emberArray,
Object: EmberObject
} = Ember;

/**
* @module Table
* @class Column
Expand Down
10 changes: 3 additions & 7 deletions addon/classes/Row.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import Ember from 'ember';
import ObjectProxy from '@ember/object/proxy';
import { computed } from '@ember/object';
import { guidFor } from '@ember/object/internals';
import fixProto from 'ember-light-table/utils/fix-proto';

const {
computed,
guidFor,
ObjectProxy
} = Ember;

/**
* @module Table
* @extends Ember.ObjectProxy
Expand Down
12 changes: 3 additions & 9 deletions addon/classes/Table.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import Ember from 'ember';
import { A as emberArray } from '@ember/array';
import EmberObject, { computed, get } from '@ember/object';
import Row from 'ember-light-table/classes/Row';
import Column from 'ember-light-table/classes/Column';
import SyncArrayProxy from 'ember-light-table/-private/sync-array-proxy';
import { mergeOptionsWithGlobals } from 'ember-light-table/-private/global-options';
import fixProto from 'ember-light-table/utils/fix-proto';

const {
get,
computed,
isNone,
A: emberArray,
Object: EmberObject
} = Ember;
import { isNone } from '@ember/utils';

const RowSyncArrayProxy = SyncArrayProxy.extend({
serializeContentObjects(objects) {
Expand Down
8 changes: 2 additions & 6 deletions addon/components/cells/base.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import Ember from 'ember';
import Component from '@ember/component';
import { computed } from '@ember/object';
import layout from 'ember-light-table/templates/components/cells/base';
import cssStyleify from 'ember-light-table/utils/css-styleify';

const {
Component,
computed
} = Ember;

/**
* @module Light Table
* @submodule Cell Types
Expand Down
10 changes: 3 additions & 7 deletions addon/components/columns/base.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import Ember from 'ember';
import Component from '@ember/component';
import { computed } from '@ember/object';
import { isEmpty } from '@ember/utils';
import layout from 'ember-light-table/templates/components/columns/base';
import DraggableColumnMixin from 'ember-light-table/mixins/draggable-column';
import cssStyleify from 'ember-light-table/utils/css-styleify';

const {
Component,
computed,
isEmpty
} = Ember;

/**
* @module Light Table
* @submodule Column Types
Expand Down
26 changes: 10 additions & 16 deletions addon/components/light-table.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
import Ember from 'ember';
import { A as emberArray } from '@ember/array';
import Component from '@ember/component';
import { computed, observer } from '@ember/object';
import { isEmpty, isNone } from '@ember/utils';
import { assert } from '@ember/debug';
import { on } from '@ember/object/evented';
import { inject as service } from '@ember/service';
import layout from 'ember-light-table/templates/components/light-table';
import Table from 'ember-light-table/classes/Table';
import cssStyleify from 'ember-light-table/utils/css-styleify';

const {
assert,
Component,
computed,
inject,
observer,
on,
isNone,
isEmpty,
A: emberArray
} = Ember;

function intersections(array1, array2) {
return array1.filter((n) => {
return array2.indexOf(n) > -1;
Expand Down Expand Up @@ -47,7 +41,7 @@ const LightTable = Component.extend({
classNameBindings: [':ember-light-table'],
attributeBindings: ['style'],

media: inject.service(),
media: service(),

/**
* @property table
Expand Down Expand Up @@ -208,8 +202,8 @@ const LightTable = Component.extend({
unit = unit[0];

/*
1. Check if all widths are present
2. Check if all widths are the same unit
1. Check if all widths are present
2. Check if all widths are the same unit
*/
for (let i = 0; i < widths.length; i++) {
let width = widths[i];
Expand Down
11 changes: 3 additions & 8 deletions addon/components/lt-body.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import Ember from 'ember';
import Component from '@ember/component';
import { computed, observer } from '@ember/object';
import layout from 'ember-light-table/templates/components/lt-body';
import { run } from '@ember/runloop';
import Row from 'ember-light-table/classes/Row';

const {
Component,
computed,
run,
observer
} = Ember;

/**
* @module Light Table
*/
Expand Down
10 changes: 3 additions & 7 deletions addon/components/lt-column-resizer.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import Ember from 'ember';
import $ from 'jquery';
import Component from '@ember/component';
import { computed } from '@ember/object';
import layout from '../templates/components/lt-column-resizer';

const {
$,
Component,
computed
} = Ember;

const TOP_LEVEL_CLASS = '.ember-light-table';

export default Component.extend({
Expand Down
9 changes: 2 additions & 7 deletions addon/components/lt-foot.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import Ember from 'ember';
import Component from '@ember/component';
import { get, trySet } from '@ember/object';
import layout from 'ember-light-table/templates/components/lt-foot';
import TableHeaderMixin from 'ember-light-table/mixins/table-header';

const {
Component,
get,
trySet
} = Ember;

/**
* @module Light Table
*/
Expand Down
9 changes: 2 additions & 7 deletions addon/components/lt-head.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import Ember from 'ember';
import Component from '@ember/component';
import { get, trySet } from '@ember/object';
import layout from 'ember-light-table/templates/components/lt-head';
import TableHeaderMixin from 'ember-light-table/mixins/table-header';

const {
Component,
get,
trySet
} = Ember;

/**
* @module Light Table
*/
Expand Down
16 changes: 6 additions & 10 deletions addon/components/lt-infinity.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import Ember from 'ember';
import Component from '@ember/component';
import { observer } from '@ember/object';
import { run } from '@ember/runloop';
import layout from '../templates/components/lt-infinity';
import InViewportMixin from 'ember-in-viewport';

const {
Component,
observer,
run
} = Ember;

export default Component.extend(InViewportMixin, {
classNames: ['lt-infinity'],
classNameBindings: ['viewportEntered:in-viewport'],
Expand Down Expand Up @@ -49,7 +45,7 @@ export default Component.extend(InViewportMixin, {
scheduleScrolledToBottom: observer('rows.[]', 'viewportEntered', function() {
if (this.get('viewportEntered')) {
/*
Continue scheduling onScrolledToBottom until no longer in viewport
Continue scheduling onScrolledToBottom until no longer in viewport
*/
this._scheduleScrolledToBottom();
}
Expand All @@ -61,8 +57,8 @@ export default Component.extend(InViewportMixin, {

_debounceScrolledToBottom(delay = 100) {
/*
This debounce is needed when there is not enough delay between onScrolledToBottom calls.
Without this debounce, all rows will be rendered causing immense performance problems
This debounce is needed when there is not enough delay between onScrolledToBottom calls.
Without this debounce, all rows will be rendered causing immense performance problems
*/
this._debounceTimer = run.debounce(this, this.sendAction, 'onScrolledToBottom', delay);
},
Expand Down
8 changes: 2 additions & 6 deletions addon/components/lt-row.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import Ember from 'ember';
import Component from '@ember/component';
import { computed } from '@ember/object';
import layout from 'ember-light-table/templates/components/lt-row';

const {
Component,
computed
} = Ember;

const Row = Component.extend({
layout,
tagName: 'tr',
Expand Down
6 changes: 1 addition & 5 deletions addon/components/lt-scrollable.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import Ember from 'ember';
import Component from '@ember/component';
import layout from '../templates/components/lt-scrollable';

const {
Component
} = Ember;

export default Component.extend({
layout,
tagName: '',
Expand Down
6 changes: 1 addition & 5 deletions addon/components/lt-spanned-row.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import Ember from 'ember';
import Component from '@ember/component';
import layout from 'ember-light-table/templates/components/lt-spanned-row';

const {
Component
} = Ember;

export default Component.extend({
layout,
colspan: 1,
Expand Down
4 changes: 1 addition & 3 deletions addon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@ import Row from './classes/Row';
*
* ```javascript
* // components/my-table.js
* import Ember from 'ember';
* import { computed } from '@ember/object';
* import Table from 'ember-light-table';
*
* const { computed } = Ember;
*
* export default Ember.Component.extend({
* model: null,
*
Expand Down
24 changes: 10 additions & 14 deletions addon/mixins/draggable-column.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import Ember from 'ember';

const {
run,
computed,
Mixin
} = Ember;
import Mixin from '@ember/object/mixin';
import { computed } from '@ember/object';
import { run } from '@ember/runloop';

let sourceColumn;

Expand Down Expand Up @@ -43,7 +39,7 @@ export default Mixin.create({
isDropTarget: computed(function() {
let column = this.get('column');
/*
A column is a valid drop target only if its in the same group
A column is a valid drop target only if its in the same group
*/
return column.get('droppable') && column.get('parent') === sourceColumn.get('parent');
}).volatile().readOnly(),
Expand All @@ -54,7 +50,7 @@ export default Mixin.create({
let column = this.get('column');

/*
NOTE: IE requires setData type to be 'text'
NOTE: IE requires setData type to be 'text'
*/
e.dataTransfer.setData('text', column.get('columnId'));
e.dataTransfer.effectAllowed = 'move';
Expand All @@ -64,8 +60,8 @@ export default Mixin.create({
this.sendAction('onColumnDrag', sourceColumn, ...arguments);

/*
NOTE: This is a fix for Firefox to prevent the click event
from being triggered after a drop.
NOTE: This is a fix for Firefox to prevent the click event
from being triggered after a drop.
*/
this.__click__ = this.click;
this.click = undefined;
Expand Down Expand Up @@ -99,16 +95,16 @@ export default Mixin.create({
this.setProperties({ isDragTarget: false, isDragging: false });

/*
If sourceColumn still references a column, it means that a successful
drop did not happen.
If sourceColumn still references a column, it means that a successful
drop did not happen.
*/
if (sourceColumn) {
this.sendAction('onColumnDrop', sourceColumn, false, ...arguments);
sourceColumn = null;
}

/*
Restore click event
Restore click event
*/
this._clickResetTimer = run.next(this, () => this.click = this.__click__);
},
Expand Down
12 changes: 4 additions & 8 deletions addon/mixins/table-header.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import Ember from 'ember';

const {
computed,
isEmpty,
Mixin,
warn
} = Ember;
import Mixin from '@ember/object/mixin';
import { computed } from '@ember/object';
import { isEmpty } from '@ember/utils';
import { warn } from '@ember/debug';

/**
* @module Light Table
Expand Down
Loading

0 comments on commit 6ee0592

Please sign in to comment.