Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added helper that can be used for simple tables #79

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

taras
Copy link
Collaborator

@taras taras commented Jun 25, 2016

This PR adds a helper that makes it possible to render a table without writing any JavaScript. It's very limited in it's functionality but it can be expanded in the future with some secret sauce.

To use,

{{light-table (table columns (get data '[]'))}}

TODO

  • Created table helper
  • Added simple unit test for test helper
  • Added integration test to show helper working
  • Documentation

@offirgolan offirgolan modified the milestone: 1.0.0 Jun 29, 2016
@offirgolan offirgolan modified the milestone: 1.0.0 Jul 6, 2016
@offirgolan
Copy link
Collaborator

@taras I think we can released this now that enableSync has been released.

{{light-table (table columns (get data '[]') enableSync=true)}}

@offirgolan
Copy link
Collaborator

offirgolan commented Dec 24, 2016

I think this is a pretty dangerous route since every time the helper will recompute, it will create a new table instance which will reset the table's entire state. That can be pretty hellish to debug....

Proposed Change

{{light-table (table columns (get data '[]') enableSync=true)}}
export default Ember.Helper.extend({
  table: null,

  compute([columns = [], data = []], hash) {
    let table = this.get('table');
    
    if (!table) { 
      table = new Table(columns, data, hash);
      this.set('table', table);
      return table;
    }
    
    // We still lose the column's state here
    // Maybe we can do a diff here to see what changed? 
    table.setColumns(columns);
    table.setRows(data);

    return table;
  }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants