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

    https://github.com/apache/couchdb-fauxton/pull/78#discussion_r18429574
  
    --- Diff: app/addons/documents/views.js ---
    @@ -45,118 +45,88 @@ function(app, FauxtonAPI, Components, Documents, 
Databases, Views, QueryOptions,
           'click .toggle-select-menu': 'selectAllMenu'
         },
     
    -    initialize: function(options){
    -      //adding the database to the object
    +    initialize: function(options) {
           this.database = options.database;
    +      this.params = options.params;
    +
           _.bindAll(this);
           this.selectVisible = false;
    -      FauxtonAPI.Events.on('advancedOptions:updateView', 
this.updateAllDocs);
           FauxtonAPI.Events.on('success:bulkDelete', this.selectAllMenu);
    -    },
    -
    -    cleanup:function(){
    -      FauxtonAPI.Events.unbind('advancedOptions:updateView');
    -      FauxtonAPI.Events.unbind('success:bulkDelete');
    -    },
    -
    -    selectAllMenu: function(e){
    -      FauxtonAPI.triggerRouteEvent("toggleSelectHeader");
    -      
FauxtonAPI.Events.trigger("documents:showSelectAll",this.selectVisible);
    -    },
     
    -    addAllDocsMenu: function(){
    -      //search docs
    +      // insert the Search Docs field
           this.headerSearch = this.insertView("#header-search", new 
Views.JumpToDoc({
             database: this.database,
             collection: this.database.allDocs
           }));
    -      //insert queryoptions
    -      //that file is included in require() above and the argument is 
QueryOptions
    -      // and it wants all these params:
    -      /* Sooooo I searched this file for where Advanced options was 
originally inserted to see what the hell
    -         is happening.  and it's in AllDocsLayout.  So I'm going to move 
some of those functions over here
    -
    -        These are required:
    -        this.database = options.database;
    -        this.updateViewFn = options.updateViewFn;
    -        this.previewFn = options.previewFn;
    -
    -        these are booleans:
    -        this.showStale = _.isUndefined(options.showStale) ? false : 
options.showStale;
    -        this.hasReduce = _.isUndefined(options.hasReduce) ? true : 
options.hasReduce;
    -
    -        these you only need for view indexes, not all docs because they 
are about
    -        specific views and design docs (ddocs, also views live inside a 
ddoc):
    -        this.viewName = options.viewName;
    -        this.ddocName = options.ddocName;
    -      */
    -
    -      /*this.queryOptions = this.insertView("#query-options", new 
QueryOptions.AdvancedOptions({
    -        database: this.database,
    -        hasReduce: false,
    -        showPreview: false,
    -      }));*/
     
    -      //Moved the apibar view into the components file so you can include 
it in your views
    -      this.apiBar = this.insertView("#header-api-bar", new 
Components.ApiBar({
    -        endpoint: this.apiEndpoints[0],
    -        documentation: this.apiEndpoints[1]
    +      // add the Query Options modal + header link
    +      this.queryOptions = this.insertView("#query-options", new 
QueryOptions.QueryOptionsTray({
    +        hasReduce: false,
    +        showStale: false
           }));
    +
    +      // insert the API Url header link
    +      this.apiBar = this.insertView("#header-api-bar", new 
Components.ApiBar());
         },
     
    -    updateApiUrl: function(api){
    -      //this will update the api bar when the route changes
    -      //you can find the method that updates it in components.js 
Components.ApiBar()
    -      this.apiEndpoints = api;
    -      this.apiBar && this.apiBar.update(api);
    +    afterRender: function() {
    +      this.toggleQueryOptionsHeader(this.isHidden);
         },
     
    -    serialize: function() {
    -      //basically if you want something in a template, You can define it 
here
    -      return {
    -        database: this.database.get('id')
    -      };
    +    cleanup: function() {
    +      FauxtonAPI.Events.unbind('success:bulkDelete');
         },
     
    -    beforeRender:function(){
    -      this.addAllDocsMenu();
    +    selectAllMenu: function(e) {
    +      FauxtonAPI.triggerRouteEvent("toggleSelectHeader");
    +      
FauxtonAPI.Events.trigger("documents:showSelectAll",this.selectVisible);
         },
     
    -    //moved from alldocs layout
    -    updateAllDocs: function (event, paramInfo) {
    -      event.preventDefault();
    +    // updates the API bar when the route changes
    +    updateApiUrl: function(api) {
    +      this.apiBar && this.apiBar.update(api);
    +    },
     
    -      var errorParams = paramInfo.errorParams,
    -          params = paramInfo.params;
    +    // these are similar, but different! resetQueryOptions() completely 
resets the settings then overlays the new ones;
    +    // updateQueryOptions() just updates the existing settings with 
whatever is specified. Between them, the
    +    resetQueryOptions: function(options) {
    +      this.queryOptions.resetQueryOptions(options);
    +    },
     
    -      if (_.any(errorParams)) {
    -        _.map(errorParams, function(param) {
    -          return FauxtonAPI.addNotification({
    -            msg: "JSON Parse Error on field: "+param.name,
    -            type: "error",
    -            clear:  true
    -          });
    -        });
    -        FauxtonAPI.addNotification({
    -          msg: "Make sure that strings are properly quoted and any other 
values are valid JSON structures",
    -          type: "warning",
    -          clear:  true
    -        });
    +    updateQueryOptions: function(options) {
    +      this.queryOptions.updateQueryOptions(options);
    +    },
     
    -        return false;
    +    hideQueryOptions: function() {
    +      this.isHidden = true; // TODO should this be here...? move to 
subview?
    --- End diff --
    
    You can use `$("my-element").is(":visible")` so you don't have to maintain 
that state additionally


---
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