couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robertkowalski <...@git.apache.org>
Subject [GitHub] couchdb pull request: New document sidebar
Date Thu, 19 Jun 2014 21:07:18 GMT
Github user robertkowalski commented on a diff in the pull request:

    https://github.com/apache/couchdb/pull/248#discussion_r13993876
  
    --- Diff: src/fauxton/app/addons/documents/sidebarviews.js ---
    @@ -0,0 +1,251 @@
    +// Licensed under the Apache License, Version 2.0 (the "License"); you may not
    +// use this file except in compliance with the License. You may obtain a copy of
    +// the License at
    +//
    +//   http://www.apache.org/licenses/LICENSE-2.0
    +//
    +// Unless required by applicable law or agreed to in writing, software
    +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
    +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
    +// License for the specific language governing permissions and limitations under
    +// the License.
    +
    +define([
    +       "app",
    +
    +       "api",
    +       "addons/fauxton/components",
    +
    +       "addons/documents/resources",
    +       "addons/databases/resources"
    +],
    +
    +function(app, FauxtonAPI, Components, Documents, Databases) {
    +  var Views = {};
    +
    +  Views.Sidebar = FauxtonAPI.View.extend({
    +    template: "addons/documents/templates/sidebar",
    +    className: "sidenav",
    +    tagName: "nav",
    +    events: {
    +      "click button#delete-database": "showDeleteDatabaseModal"
    +    },
    +
    +    initialize: function(options) {
    +      this.database = options.database;
    +      if (options.ddocInfo) {
    +        this.ddocID = options.ddocInfo.id;
    +        this.currView = options.ddocInfo.currView;
    +      }
    +    },
    +    showDeleteDatabaseModal: function(event){
    +      this.deleteDBModal.showModal();
    +    },
    +
    +    serialize: function() {
    +      var docLinks = FauxtonAPI.getExtensions('docLinks'),
    +          newLinks = FauxtonAPI.getExtensions('sidebar:newLinks'),
    +          addLinks = FauxtonAPI.getExtensions('sidebar:links'),
    +          extensionList = FauxtonAPI.getExtensions('sidebar:list');
    +      return {
    +        changes_url: '#' + this.database.url('changes'),
    +        permissions_url: '#' + this.database.url('app') + '/permissions',
    +        db_url: '#' + this.database.url('index'),
    +        database: this.collection.database,
    +        database_url: '#' + this.database.url('app'),
    +        docLinks: docLinks,
    +        addLinks: addLinks,
    +        newLinks: newLinks,
    +        extensionList: extensionList > 0
    +      };
    +    },
    +
    +
    +    beforeRender: function(manage) {
    +      this.deleteDBModal = this.setView(
    +        '#delete-db-modal',
    +        new Views.DeleteDBModal({database: this.database})
    +      );
    +
    +      var database = this.collection.database,
    +          newurl = "#" + database.url('app') + '/new';
    +
    +      var newLinks = [{
    +        title: 'Add new',
    +        links: [{
    +          title: 'New Doc',
    +          url: newurl,
    +          icon: 'fonticon-plus-circled'
    +        },{
    +          title: 'New Design Doc',
    +          url: newurl,
    +          icon: 'fonticon-plus-circled'
    +        }]
    +      }];
    +
    +      this.insertView("#new-all-docs-button", new Components.MenuDropDown({
    +        links: newLinks,
    +      }));
    +
    +      this.insertView("#new-design-docs-button", new Components.MenuDropDown({
    +        links: newLinks,
    +      }));
    +
    +      this.collection.each(function(design) {
    +        if (design.has('doc')){
    +          this.insertView(new Views.DdocSidenav({
    +            model: design,
    +            collection: this.collection
    +          }));
    +        }
    +      },this);
    +    },
    +
    +    afterRender: function () {
    +      if (this.selectedTab) {
    +        this.setSelectedTab(this.selectedTab);
    +      }
    +    },
    +
    +    setSelectedTab: function (selectedTab) {
    +      this.selectedTab = selectedTab;
    +      var $selectedTab = this.$('#' + selectedTab);
    +
    +      this.$('li').removeClass('active');
    +      $selectedTab.parent().addClass('active');
    +
    +      if ($selectedTab.parents(".accordion-body").length !== 0){
    +        $selectedTab
    +        .parents(".accordion-body")
    +        .addClass("in")
    +        .parents(".nav-header")
    +        .find(">.js-collapse-toggle").addClass("down");
    +
    +        this.$('.js-toggle-' + $selectedTab.data('ddoctype')).addClass("down");
    +      }
    +    }
    +  });
    +
    +  Views.DdocSidenav = FauxtonAPI.View.extend({
    +    tagName: "ul",
    +    className:  "nav nav-list",
    +    template: "addons/documents/templates/design_doc_menu",
    +    events: {
    +      "click .js-collapse-toggle": "toggleArrow"
    +    },
    +
    +    toggleArrow:  function(e){
    +      this.$(e.currentTarget).toggleClass("down");
    +    },
    +    buildIndexList: function(collection, selector, ddocType){
    +      var design = this.model.id.replace(/^_design\//,"");
    +
    +      this.insertView(".accordion-body", new Views.IndexItem({
    +        selector: selector,
    +        ddoc: design,
    +        collection: collection[selector],
    +        ddocType: ddocType,
    +        database: this.model.collection.database.id
    +      }));
    +    },
    +
    +    serialize: function(){
    +      var ddocName = this.model.id.replace(/^_design\//,"");
    +      return{
    +        database: this.collection.database,
    +        designDoc: ddocName,
    +        ddoc_clean: app.utils.removeSpecialCharacters(ddocName),
    +        ddoc_encoded: app.utils.safeURLName(ddocName),
    +        database_encoded: app.utils.safeURLName(this.model.collection.database.id),
    +      };
    +    },
    +    beforeRender: function(manage) {
    +      var ddocDocs = this.model.get("doc"),
    +          ddocName = this.model.id.replace(/^_design\//,""),
    +          sideBarMenuLinks = [];
    +
    +      var sidebarListTypes = FauxtonAPI.getExtensions('sidebar:list');
    +          if (ddocDocs){
    +            //Views
    +            this.buildIndexList(ddocDocs, "views", "view");
    +            //lists
    +            // this.buildIndexList(ddocDocs, "lists");
    --- End diff --
    
    is this needed?


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

Mime
View raw message