mirror of
https://github.com/zhigang1992/deployd.git
synced 2026-05-25 08:06:23 +08:00
Fixed schema creation/edit to nullify empty fields before submitting.
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -6,3 +6,6 @@ bin/test
|
||||
|
||||
.DS_Store
|
||||
.sass-cache/
|
||||
node_modules/
|
||||
|
||||
public/npm-debug.log
|
||||
|
||||
@@ -11,7 +11,7 @@ window.App = Backbone.Model.extend({
|
||||
});
|
||||
|
||||
//Iterate through each plugin
|
||||
_.each(_pluginsFromResponse, function (objectsArray, pluginName, list){
|
||||
_.each(_pluginsFromResponse, function (objectsArray, pluginName, list) {
|
||||
|
||||
if (pluginName !== "undefined") {
|
||||
var _pluginObjects = new Backbone.Collection(objectsArray, {
|
||||
@@ -22,7 +22,7 @@ window.App = Backbone.Model.extend({
|
||||
name: pluginName,
|
||||
plugin: pluginName,
|
||||
objects: _pluginObjects
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -40,6 +40,13 @@ window.ItemEditView = Backbone.View.extend({
|
||||
|
||||
var _values = this._formObjectFromArray($('form', this.el).serializeArray());
|
||||
$.each(_values, function(i, field){
|
||||
//Convert values to null if they are empty
|
||||
if (_values[i].replace(/ /g,'') === '') {
|
||||
console.log('value was empty, '+i);
|
||||
_values[i] = null;
|
||||
return;
|
||||
}
|
||||
//Convert strings to objects, if they should be objects
|
||||
if (_self.model.get('description')[i].type === 'object') {
|
||||
try {
|
||||
_values[i] = JSON.parse(field);
|
||||
|
||||
@@ -5,17 +5,13 @@ window.PluginView = Backbone.View.extend({
|
||||
template: 'plugin-detail-template',
|
||||
|
||||
render: function () {
|
||||
console.log('render() in PluginView');
|
||||
var _self = this;
|
||||
$(this.el).empty();
|
||||
$(this.tabsEl).empty();
|
||||
|
||||
this.model.get("objects").each(function(obj){
|
||||
console.log('object:');
|
||||
console.log(obj);
|
||||
var tabContent = _self.addTab(obj.get("name"), obj.get("_id"));
|
||||
if (obj.get("description")) {
|
||||
|
||||
var _schemaModel = new SchemaModel(obj);
|
||||
var _schemaEl = $("<div />").attr("id", "id-"+obj.get('_id'));
|
||||
$(tabContent).append(_schemaEl);
|
||||
|
||||
Reference in New Issue
Block a user