Skip to content

Commit

Permalink
Rename table (Addepar#422)
Browse files Browse the repository at this point in the history
  • Loading branch information
billy-addepar authored Sep 22, 2017
1 parent ec99f1e commit e7ce993
Show file tree
Hide file tree
Showing 33 changed files with 89 additions and 50 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ cache:
env:
# we recommend new addons test the current and previous LTS
# as well as latest stable release (bonus points to beta/canary)
- EMBER_TRY_SCENARIO=ember-lts-2.8
- EMBER_TRY_SCENARIO=ember-lts-2.12
- EMBER_TRY_SCENARIO=ember-1.11
- EMBER_TRY_SCENARIO=ember-1.13
- EMBER_TRY_SCENARIO=ember-2.8
- EMBER_TRY_SCENARIO=ember-release
- EMBER_TRY_SCENARIO=ember-beta
- EMBER_TRY_SCENARIO=ember-canary
Expand Down
26 changes: 21 additions & 5 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
The MIT License (MIT)
Copyright © 2017 Addepar, Inc. All Rights Reserved.

Copyright (c) 2017
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3. "Addepar" or "Addepar, Inc." may not be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY ADDEPAR, INC. "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# ember-table-2
# ember-table

This README outlines the details of collaborating on this Ember addon.

## Installation

* `git clone <repository-url>` this repository
* `cd ember-table-2`
* `cd ember-table`
* `npm install`

## Running
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/* global ResizeSensor */
import { action, computed } from 'ember-decorators/object';
import { property } from '../utils/class';
import layout from '../templates/components/ember-table-2';
import layout from '../templates/components/ember-table';
import { htmlSafe } from '@ember/string';
import { run } from '@ember/runloop';
import Component from '@ember/component';
import CellProxy from '../utils/cell-proxy';
import { move } from '../utils/array';

const HEAD_ALIGN_BAR_WIDTH = 5;

Expand Down Expand Up @@ -468,15 +469,7 @@ export default class EmberTable2 extends Component {
@action
onColumnReorderEnds(columnIndex) {
if (this._currentColumnIndex != columnIndex) {
const direction = this._currentColumnIndex > columnIndex ? 1 : -1;

const columns = this.get('columns');
const temp = columns[columnIndex];

for (let i = columnIndex; i !== this._currentColumnIndex; i += direction) {
columns.replace(i, 1, columns[i + direction]);
}
columns.replace(this._currentColumnIndex, 1, temp);
move(this, 'columns', columnIndex, this._currentColumnIndex);
}

this._currentColumnIndex = -1;
Expand Down
4 changes: 2 additions & 2 deletions addon/components/tree-table.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import layout from '../templates/components/ember-table-2';
import EmberTable2 from './ember-table-2';
import layout from '../templates/components/ember-table';
import EmberTable2 from './ember-table';
import { property } from '../utils/class';
import { action } from 'ember-decorators/object';
import { readOnly } from '@ember/object/computed';
Expand Down
File renamed without changes.
27 changes: 27 additions & 0 deletions addon/utils/array.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Cycle shift an internal [start..end] to [start + 1...end, start].
*/
export function move(context, arrayName, start, end) {
const items = context.get(arrayName);
let destItem, sourceItem;
const direction = start < end ? 1 : 0;

if (items.objectAt && items.removeObject && items.insertAt) {
// Ember Array
sourceItem = items.objectAt(start);
destItem = items.objectAt(end);
items.removeObject(sourceItem);
end = items.indexOf(destItem) + direction;
items.insertAt(end, sourceItem);
} else {
// native array
destItem = items[end];
sourceItem = items[start];
items.splice(start, 1);
end = items.indexOf(destItem) + direction;
items.splice(end, 0, sourceItem);
// if we are not using Ember Arrays we need to set `items` to a new array
// instance to trigger new change
context.set(arrayName, [].concat(items));
}
}
1 change: 0 additions & 1 deletion app/components/ember-table-2.js

This file was deleted.

2 changes: 1 addition & 1 deletion app/components/ember-table-cell.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from 'ember-table-2/components/ember-table-cell';
export { default } from 'ember-table/components/ember-table-cell';
2 changes: 1 addition & 1 deletion app/components/ember-table-footer.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from 'ember-table-2/components/ember-table-footer';
export { default } from 'ember-table/components/ember-table-footer';
2 changes: 1 addition & 1 deletion app/components/ember-table-header.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from 'ember-table-2/components/ember-table-header';
export { default } from 'ember-table/components/ember-table-header';
2 changes: 1 addition & 1 deletion app/components/ember-table-row.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from 'ember-table-2/components/ember-table-row';
export { default } from 'ember-table/components/ember-table-row';
1 change: 1 addition & 0 deletions app/components/ember-table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from 'ember-table/components/ember-table';
2 changes: 1 addition & 1 deletion app/components/tree-table-cell.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from 'ember-table-2/components/tree-table-cell';
export { default } from 'ember-table/components/tree-table-cell';
2 changes: 1 addition & 1 deletion app/components/tree-table-row.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from 'ember-table-2/components/tree-table-row';
export { default } from 'ember-table/components/tree-table-row';
2 changes: 1 addition & 1 deletion app/components/tree-table.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from 'ember-table-2/components/tree-table';
export { default } from 'ember-table/components/tree-table';
2 changes: 1 addition & 1 deletion app/helpers/get-path.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default, getPath } from 'ember-table-2/helpers/get-path';
export { default, getPath } from 'ember-table/helpers/get-path';
2 changes: 1 addition & 1 deletion app/helpers/table-hash.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default, tableHash } from 'ember-table-2/helpers/table-hash';
export { default, tableHash } from 'ember-table/helpers/table-hash';
2 changes: 1 addition & 1 deletion app/models/column-definition.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from 'ember-table-2/models/column-definition';
export { default } from 'ember-table/models/column-definition';
2 changes: 1 addition & 1 deletion app/routes/test.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from 'ember-table-2/routes/test';
export { default } from 'ember-table/routes/test';
2 changes: 1 addition & 1 deletion app/templates/test.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from 'ember-table-2/templates/test';
export { default } from 'ember-table/templates/test';
2 changes: 1 addition & 1 deletion app/utils/column-definition.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from 'ember-table-2/utils/column-definition';
export { default } from 'ember-table/utils/column-definition';
2 changes: 1 addition & 1 deletion app/utils/linked-list-tree.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from 'ember-table-2/utils/linked-list-tree';
export { default } from 'ember-table/utils/linked-list-tree';
2 changes: 1 addition & 1 deletion app/utils/tree-node.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from 'ember-table-2/utils/tree-node';
export { default } from 'ember-table/utils/tree-node';
2 changes: 1 addition & 1 deletion ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const EmberAddon = require('ember-cli/lib/broccoli/ember-addon');

module.exports = function(defaults) {
let app = new EmberAddon(defaults, {
babel: {
'ember-cli-babel': {
includePolyfill: true
},
});
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use strict';

module.exports = {
name: 'ember-table-2',
name: 'ember-table',

options: {
nodeAssets: {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "ember-table-2",
"name": "ember-table",
"version": "0.0.0",
"description": "The default blueprint for ember-cli addons.",
"keywords": [
Expand Down
3 changes: 2 additions & 1 deletion tests/dummy/app/components/custom-row.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import EmberTableRow from '../components/ember-table-row';
import { property } from '../utils/class';

export default class CustomRow extends EmberTableRow {
classNames = ['et-tr', 'custom-row']
@property classNames = ['et-tr', 'custom-row'];
}
2 changes: 1 addition & 1 deletion tests/dummy/app/controllers/addepar.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Controller from '@ember/controller';
import { computed } from '@ember/object';
import ColumnDefinition from 'ember-table-2/models/column-definition';
import ColumnDefinition from 'ember-table/models/column-definition';

export default Controller.extend({

Expand Down
4 changes: 2 additions & 2 deletions tests/dummy/app/templates/custom-component.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="custom-component-container">
{{#ember-table-2
{{#ember-table
rows=rows
columns=columns
rowComponent="custom-row"
Expand All @@ -12,5 +12,5 @@
{{cell.value}}
{{/if}}

{{/ember-table-2}}
{{/ember-table}}
</div>
10 changes: 5 additions & 5 deletions tests/helpers/test-scenarios.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import hbs from 'htmlbars-inline-precompile';
import { A as emberA } from '@ember/array';
import waitForRender from 'dummy/tests/helpers/wait-for-render';
import ColumnDefinition from 'ember-table-2/models/column-definition';
import ColumnDefinition from 'ember-table/models/column-definition';

export const DEFAULT_TABLE_OPTIONS = {
numFixedColumns: 1,
Expand Down Expand Up @@ -64,7 +64,7 @@ export function generateColumns(columnCount, columnOptions) {

export const simpleTable = hbs`
<div style="height: 500px;">
{{#ember-table-2
{{#ember-table
columns=tableColumns
rows=tableRows
estimateRowHeight=13
Expand All @@ -78,14 +78,14 @@ export const simpleTable = hbs`
}}
{{cell.value}}
{{/ember-table-row}}
{{/ember-table-2}}
{{/ember-table}}
</div>
`;

// Table with fixed column, column resizing, column grouping enabled
export const fullTable = hbs`
<div style="height: 500px;">
{{#ember-table-2
{{#ember-table
columns=tableColumns
rows=tableRows
numFixedColumns=numFixedColumns
Expand All @@ -101,7 +101,7 @@ export const fullTable = hbs`
}}
{{cell.value}}
{{/component}}
{{/ember-table-2}}
{{/ember-table}}
</div>
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const {
merge
} = Ember;

moduleForComponent('ember-table-2', 'Integration | Component | ember table 2', {
moduleForComponent('ember-table', 'Integration | Component | ember table', {
integration: true
});

Expand Down
1 change: 1 addition & 0 deletions tests/test-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
setResolver
} from 'ember-qunit';
import { start } from 'ember-cli-qunit';
import 'dummy/app';

setResolver(resolver);
start();

0 comments on commit e7ce993

Please sign in to comment.