Return-Path: X-Original-To: apmail-couchdb-dev-archive@www.apache.org Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 329E6175E6 for ; Sat, 4 Oct 2014 14:52:39 +0000 (UTC) Received: (qmail 99874 invoked by uid 500); 4 Oct 2014 14:52:38 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 99808 invoked by uid 500); 4 Oct 2014 14:52:38 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 99797 invoked by uid 99); 4 Oct 2014 14:52:38 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 04 Oct 2014 14:52:38 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 51E449C5E23; Sat, 4 Oct 2014 14:52:38 +0000 (UTC) From: robertkowalski To: dev@couchdb.apache.org Reply-To: dev@couchdb.apache.org References: In-Reply-To: Subject: [GitHub] couchdb-fauxton pull request: New Query Options tray added Content-Type: text/plain Message-Id: <20141004145238.51E449C5E23@tyr.zones.apache.org> Date: Sat, 4 Oct 2014 14:52:38 +0000 (UTC) Github user robertkowalski commented on a diff in the pull request: https://github.com/apache/couchdb-fauxton/pull/78#discussion_r18429735 --- 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? + if (this.hasRendered) { + this.toggleQueryOptionsHeader(this.isHidden); } + }, - var fragment = window.location.hash.replace(/\?.*$/, ''); + showQueryOptions: function() { + this.isHidden = false; + if (this.hasRendered) { + this.toggleQueryOptionsHeader(this.isHidden); + } + }, - if (!_.isEmpty(params)) { - fragment = fragment + '?' + $.param(params); + toggleQueryOptionsHeader: function(hide) { + if (hide) { + $("#header-query-options").addClass("hide"); + } else { + $("#header-query-options").removeClass("hide"); } --- End diff -- You can use `this.$("#header-query-options")` here --- 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 infrastructure@apache.org or file a JIRA ticket with INFRA. ---