Github user garrensmith commented on a diff in the pull request:

    https://github.com/apache/couchdb/pull/203#discussion_r11425987
  
    --- Diff: src/fauxton/app/addons/activetasks/views.js ---
    @@ -28,23 +28,105 @@ function (app, FauxtonAPI, activetasks) {
     
       Views.Events = _.extend(Events, Backbone.Events);
     
    +  Views.View = FauxtonAPI.View.extend({
    +    tagName: "table",
    +
    +    className: "table table-bordered table-striped active-tasks",
    +
    +    template: "addons/activetasks/templates/table",
    +
    +    events: {
    +      "click th": "sortByType"
    +    },
    +
    +    filter: "all",
    +
    +    initialize: function (options) {
    +      ActiveTasks.events.on("tasks:filter", this.filterAndRender, this);
    +      this.collection.bind("reset", _.bind(this.render, this));
    +    },
    +
    +    beforeRender: function () {
    +      this.filterAndRender(this.filter);
    +    },
    +
    +    filterAndRender: function (view) {
    +      var self = this;
    +      this.filter = view;
    +      this.removeView("#tasks_go_here");
    +
    +      this.collection.forEach(function (item) {
    +        if (self.filter !== "all" && item.get("type") !== self.filter) {
    +          return;
    +        }
    +        var view = new Views.TableDetail({
    +          model: item
    +        });
    +        this.insertView("#tasks_go_here", view).render();
    +      }, this);
    +    },
    +
    +    afterRender: function () {
    +      Events.bind("update:poll", this.setPolling, this);
    +      this.setPolling();
    +    },
    +
    +    establish: function () {
    +      return [this.collection.fetch()];
    +    },
    +
    +    serialize: function () {
    +      return {
    +        currentView: this.currentView,
    +        collection: this.collection
    +      };
    +    },
    +
    +    sortByType: function (e) {
    +      var currentTarget = e.currentTarget,
    +          datatype = $(currentTarget).attr("data-type");
    +
    +      this.collection.sortByColumn(datatype);
    +      this.render();
    +    },
    +
    +    setPolling: function () {
    +      var self = this;
    --- End diff --
    
    I think you could rewrite this whole function to not use `self` aka `that`. 
We try to use `that` as our last case if there is no other way of doing it. So 
this function could be:
        
        setPolling: function () {
          var collection = this.collection;
    
          clearInterval(pollingInfo.intervalId);
          pollingInfo.intervalId = setInterval(function () {
            collection.fetch({reset: true});
         }, pollingInfo.rate * 1000);
       }


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to