Skip to content

Instantly share code, notes, and snippets.

@lsmith
Created November 10, 2011 21:51
Show Gist options
  • Save lsmith/1356355 to your computer and use it in GitHub Desktop.
Save lsmith/1356355 to your computer and use it in GitHub Desktop.

Revisions

  1. lsmith revised this gist Nov 11, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    DataTable design overview
    =========================

    This is my early thoughts on how to structure DataTable in 3.5.0. Feedback is welcome in the comments.
    These are my early thoughts on how to structure DataTable in 3.5.0. Feedback is welcome in the comments.

    ## Instantiable classes out of the box
    ```
  2. lsmith revised this gist Nov 11, 2011. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,8 @@
    DataTable design overview
    =========================

    This is my early thoughts on how to structure DataTable in 3.5.0. Feedback is welcome in the comments.

    ## Instantiable classes out of the box
    ```
    new Y.DataTable({...});
    @@ -11,7 +13,7 @@ new Y.DataTable.Base({...});
    ```
    Y.DataTable.Base = Y.Base.create('datatable', Y.Widget, [Y.DataTable.Core]);
    Y.DataTable = Y.mix(
    Y.Base.create('datatable', Y.Widget, [Y.DataTable.Core]),
    Y.Base.create('datatable', Y.DataTable.Base, []),
    Y.DataTable, true);
    ```

  3. lsmith revised this gist Nov 10, 2011. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -36,6 +36,10 @@ new Y.DataTable({
    recordType: (optional) ModelClass
    headerView: (optional) ViewClass
    bodyView: (optional) ViewClass
    footerView: (optional) ViewClass
    summary: (optional) 'string'
    caption: (optional) 'string'
    });
  4. lsmith revised this gist Nov 10, 2011. 1 changed file with 34 additions and 34 deletions.
    68 changes: 34 additions & 34 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -7,40 +7,6 @@ new Y.DataTable({...});
    new Y.DataTable.Base({...});
    ```

    ## Component classes

    * `Y.DataTable.Core`

    Everything added to Y.Widget to make DataTable.Base

    * `Y.DataTable.HeaderView`
    * `Y.DataTable.BodyView`
    * `Y.DataTable.FooterView`

    Used by DataTable(.Base) to render the table contents.

    Referenced via configuration, not composition.

    * `Y.DataTable.Source`

    Optional class extension.

    Adds support `data` config to generate ML with DataSource load.

    * `Y.DataTable.Scrollable`

    Optional class extension.

    Adds support for scrolling table. May be used to create a third instantiable class.

    * `Y.DataTable.ScrollingBodyView`

    Used in place of DataTable.BodyView to render the scrolling table. May not be necessary?

    * `Y.DataTable.Sortable`

    Adds support for sorting headers and sortable config.

    ## Class generation
    ```
    Y.DataTable.Base = Y.Base.create('datatable', Y.Widget, [Y.DataTable.Core]);
    @@ -85,6 +51,40 @@ instance
    .foot = viewInstance
    ```

    ## Component classes

    * `Y.DataTable.Core`

    Everything added to Y.Widget to make DataTable.Base

    * `Y.DataTable.HeaderView`
    * `Y.DataTable.BodyView`
    * `Y.DataTable.FooterView`

    Used by DataTable(.Base) to render the table contents.

    Referenced via configuration, not composition.

    * `Y.DataTable.Source`

    Optional class extension.

    Adds support `data` config to generate ML with DataSource load.

    * `Y.DataTable.Scrollable`

    Optional class extension.

    Adds support for scrolling table. May be used to create a third instantiable class.

    * `Y.DataTable.ScrollingBodyView`

    Used in place of DataTable.BodyView to render the scrolling table. May not be necessary?

    * `Y.DataTable.Sortable`

    Adds support for sorting headers and sortable config.

    ## Render lifecycle
    `instance.render(...)`

  5. lsmith revised this gist Nov 10, 2011. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -50,6 +50,7 @@ Y.DataTable = Y.mix(
    ```

    Class extensions CAN (if non-invasive by default)

    ```
    Y.Base.mix(Y.DataTable, [ Y.DataTable.Sortable ]);
    ```
  6. lsmith revised this gist Nov 10, 2011. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -10,6 +10,7 @@ new Y.DataTable.Base({...});
    ## Component classes

    * `Y.DataTable.Core`

    Everything added to Y.Widget to make DataTable.Base

    * `Y.DataTable.HeaderView`
    @@ -24,7 +25,7 @@ new Y.DataTable.Base({...});

    Optional class extension.

    Adds support data config to generate ML with DataSource load.
    Adds support `data` config to generate ML with DataSource load.

    * `Y.DataTable.Scrollable`

  7. lsmith revised this gist Nov 10, 2011. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -15,21 +15,29 @@ new Y.DataTable.Base({...});
    * `Y.DataTable.HeaderView`
    * `Y.DataTable.BodyView`
    * `Y.DataTable.FooterView`

    Used by DataTable(.Base) to render the table contents.

    Referenced via configuration, not composition.

    * `Y.DataTable.Source`

    Optional class extension.

    Adds support data config to generate ML with DataSource load.

    * `Y.DataTable.Scrollable`

    Optional class extension.

    Adds support for scrolling table. May be used to create a third instantiable class.

    * `Y.DataTable.ScrollingBodyView`

    Used in place of DataTable.BodyView to render the scrolling table. May not be necessary?

    * `Y.DataTable.Sortable`

    Adds support for sorting headers and sortable config.

    ## Class generation
  8. lsmith revised this gist Nov 10, 2011. 1 changed file with 28 additions and 1 deletion.
    29 changes: 28 additions & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -73,4 +73,31 @@ instance
    .head = viewInstance
    .body = viewInstance
    .foot = viewInstance
    ```
    ```

    ## Render lifecycle
    `instance.render(...)`

    1. build <table> (markup only or off DOM node?)
    2. instantiate header, body, footer views passing
    1. the DT instance
    2. the created table?
    3. the `data` ModelList?
    3. call each view's render()

    Logic for reacting to user input is moved to the View classes

    _Concern: string based rendering would have viewX.render() return a string or populate a property, but it has requirements of the DT renderer_

    ## Load lifecycle
    `instance.load(...)`

    Pass through to this.data.load(...). Let the ModelList be responsible for data interaction.

    ## Default Model generation

    * No ModelList is provided in `data` configuration AND
    * No `recordType` is provided in configuration

    1. Use the first item in the data array to build ATTRS and Y.Base.create(...)
    2. If data is empty, use columns?
  9. lsmith revised this gist Nov 10, 2011. 1 changed file with 51 additions and 12 deletions.
    63 changes: 51 additions & 12 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -7,31 +7,70 @@ new Y.DataTable({...});
    new Y.DataTable.Base({...});
    ```

    // Component classes
    Y.DataTable.Core
    ## Component classes

    Y.DataTable.HeaderView
    Y.DataTable.BodyView
    Y.DataTable.FooterView
    * `Y.DataTable.Core`
    Everything added to Y.Widget to make DataTable.Base

    Y.DataTable.Source
    * `Y.DataTable.HeaderView`
    * `Y.DataTable.BodyView`
    * `Y.DataTable.FooterView`
    Used by DataTable(.Base) to render the table contents.
    Referenced via configuration, not composition.

    Y.DataTable.Scrollable
    Y.DataTable.ScrollingBodyView
    * `Y.DataTable.Source`
    Optional class extension.
    Adds support data config to generate ML with DataSource load.

    Y.DataTable.Sortable
    * `Y.DataTable.Scrollable`
    Optional class extension.
    Adds support for scrolling table. May be used to create a third instantiable class.

    * `Y.DataTable.ScrollingBodyView`
    Used in place of DataTable.BodyView to render the scrolling table. May not be necessary?

    * `Y.DataTable.Sortable`
    Adds support for sorting headers and sortable config.

    ## Class generation
    ```
    Y.DataTable.Base = Y.Base.create('datatable', Y.Widget, [Y.DataTable.Core]);
    Y.DataTable = Y.mix(
    Y.Base.create('datatable', Y.Widget, [Y.DataTable.Core]),
    Y.DataTable, true);
    ```

    Y.Base.mix(Y.DataTable, [ Y.DataTable.Scrollable, Y.DataTable.Sortable ]);

    Class extensions CAN (if non-invasive by default)
    ```
    Y.Base.mix(Y.DataTable, [ Y.DataTable.Sortable ]);
    ```

    ## Primary configuration
    ```
    new Y.DataTable({
    data: [{ ... }, { ... }, ... ]
    data: modelList
    data: {
    source: url, function, xml
    }
    type: 'json'
    schema: { ... }
    }
    columns: (optional) [ key, key, { key: key, config: stuff, ... }, ... ]
    recordType: (optional) ModelClass
    summary: (optional) 'string'
    caption: (optional) 'string'
    });
    ```

    ## Instance structure
    ```
    instance
    .data = modelListInstance
    .head = viewInstance
    .body = viewInstance
    .foot = viewInstance
    ```
  10. lsmith revised this gist Nov 10, 2011. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,11 @@
    DataTable design overview
    -------------------------
    =========================

    ## Instantiable classes out of the box
    ```
    new Y.DataTable({...});
    new Y.DataTable.Base({...});
    ```

    // Component classes
    Y.DataTable.Core
  11. lsmith revised this gist Nov 10, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    DataTable design overview
    =========================
    -------------------------

    ## Instantiable classes out of the box
    new Y.DataTable({...});
  12. lsmith created this gist Nov 10, 2011.
    35 changes: 35 additions & 0 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    DataTable design overview
    =========================

    ## Instantiable classes out of the box
    new Y.DataTable({...});
    new Y.DataTable.Base({...});

    // Component classes
    Y.DataTable.Core

    Y.DataTable.HeaderView
    Y.DataTable.BodyView
    Y.DataTable.FooterView

    Y.DataTable.Source

    Y.DataTable.Scrollable
    Y.DataTable.ScrollingBodyView

    Y.DataTable.Sortable

    Y.DataTable.Base = Y.Base.create('datatable', Y.Widget, [Y.DataTable.Core]);
    Y.DataTable = Y.mix(
    Y.Base.create('datatable', Y.Widget, [Y.DataTable.Core]),
    Y.DataTable, true);

    Y.Base.mix(Y.DataTable, [ Y.DataTable.Scrollable, Y.DataTable.Sortable ]);


    new Y.DataTable({
    data: [{ ... }, { ... }, ... ]
    data: modelList
    data: {
    source: url, function, xml
    }