couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From garrensmith <...@git.apache.org>
Subject [GitHub] couchdb pull request: CouchDB- 2128 Config Section dropdown
Date Fri, 14 Mar 2014 14:45:04 GMT
Github user garrensmith commented on a diff in the pull request:

    https://github.com/apache/couchdb/pull/178#discussion_r10609856
  
    --- Diff: src/fauxton/app/addons/config/views.js ---
    @@ -111,34 +163,58 @@ function (app, FauxtonAPI, Config) {
             });
           }
     
    -      this.$("#add-section-modal").modal('hide');
    -      this.render();
    -    },
    +      this.hide();
    +      Views.Events.trigger("newSection");
     
    -    addSection: function (event) {
    +    },
    +    isNew: function(collection){
    +      var sectionName = this.$('input[name="section"]').val(),
    +          name = this.$('input[name="name"]').val();
    +          var section = _.findWhere(collection.toJSON(), {"section":sectionName});
    +          var options = _.findWhere(section.options, {name: name});
    +          
    +          return options;
    +    },
    +    isSection: function(){
    +      var section = this.$('input[name="section"]').val();
    +      return _.find(this.sourceArray, function(item){ return item === section; });
    +    },
    +    validate: function (event){
           event.preventDefault();
    -      this.$("#add-section-modal").modal({show:true});
    +      var section = this.$('input[name="section"]').val(),
    +          name = this.$('input[name="name"]').val(),
    +          value = this.$('input[name="value"]').val(),
    +          collection = this.collection;
    +
    +      if(!this.isSection()){
    +         this.errorMessage("You need to use an existing section");
    +      } else if (!name) {
    +        this.errorMessage("Add a name");
    +      } else if (!value) {
    +        this.errorMessage("Add a value");
    +      } else if (this.isNew(collection)){
    +        this.errorMessage("Must have a unique name");
    +      } else {
    +        this.submitForm();
    +      }
         },
    -
    -    beforeRender: function() {
    -      this.collection.each(function(config) {
    -        _.each(config.get("options"), function (option, index) {
    -          this.insertView("table.config tbody", new Views.TableRow({
    -            model: new Config.OptionModel({
    -              section: config.get("section"),
    -              name: option.name,
    -              value: option.value,
    -              index: index
    -            })
    -          }));
    -        }, this);
    -      }, this);
    +    errorMessage: function(msg){
    +      this.error = FauxtonAPI.addNotification({
    +          msg: msg,
    +          type: "error",
    +          clear: true,
    +          selector: ".form-error-config"
    +      });
         },
    -
    -    establish: function() {
    -      return [this.collection.fetch()];
    +    show: function(){
    +      $(this.el).modal({show:true});
    --- End diff --
    
    this can be redone to `this.$el`


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