Skip to content

Instantly share code, notes, and snippets.

@aaronj1335
Created October 24, 2012 18:46
Show Gist options
  • Select an option

  • Save aaronj1335/3948012 to your computer and use it in GitHub Desktop.

Select an option

Save aaronj1335/3948012 to your computer and use it in GitHub Desktop.
gloss framework stuff

powergrid

todos

  • make Column.prototype.columnClass correctly handle names containing '.'

  • column methods for getting/formatting a table cell's value (see below)

  • add an Grid.prototype._isFiltered method that is used to determine whether the grid adds a filtered class. default behavior should be something like:

     _isFiltered: function() {
         var collection = this.get('collection');
         return collection && collection.query.params.query != null;
     }
    
  • integrate spinner into grid so that it just shows up when grid is disabled

  • add a PowerGrid.prototype.selected method that returns the currently selected model or an array of selected models

column values

current Column implementation just provides getValue, which glosses over a number of different use cases. first of all, the Column class is responsible for a number of things, including:

  • getting the correct value from a model
  • providing the appropriate value for sorting
  • providing the appropriate value for displaying to the user (a.k.a. formatting the value)

am i forgetting anything? so what set of methods do we need here? here's my take, let me know if you think we should do something else:

// this just gets the property from the model, similar to `modelProperty`
// in the old grid
getValue: function(model) {
    return model.get(this.get('name'));
}

// for sorting -- should we even include this as a hook? or just make the
// sorting use `getValue`?
getSortValue: function(model) {
    return this.getValue(model);
}

// for display/formatting
//
// could also be something like `getDisplayValue: function(model) {` to
// follow the convention above, but i think the function below conveys
// intent more clearly, and as @mmuzamil points out, allows more brevity
formatValue: function(value, model) {
    return value;
}

let me know what you guys think.

powergrid bugs

  • duplicate <th> class names
  • undefined css class on <thead>

other things

  • we need a .propaget() on View. it should propagate the call both to other View instances and Widget instances
  • BoundWidgetGroup is causing everyone headaches. let's refactor it:
    • first we modularize a bunch of stuff (note these dont inherit from View or Widget, they're just utility classes):
      • binding: the first pass at this is mostly done
      • widgetizing: basically just copy the code from WidgetGroup
      • processing errors from API calls: currently the only place we do this (or more accurately, something like this), is in BoundWidgetGroup, but we need something more general that probably uses a Binding instance to match errors to UI fields
    • then we have some class called like Form or something*, which inherits from View and ties all this stuff together, while hopefully not sacrificing too much either in flexibility or power

* note that in following with the javascript community conventions, we'd want to choose some hipster name for this like Formality or Formr

@aaronj1335
Copy link
Copy Markdown
Author

the first 3 and last of the powergrid 'todos' are donezo.

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