add disableAdd option
diff --git a/xos/core/xoslib/static/js/xoslib/xos-backbone.js b/xos/core/xoslib/static/js/xoslib/xos-backbone.js
index f22a2e2..a8061ed 100644
--- a/xos/core/xoslib/static/js/xoslib/xos-backbone.js
+++ b/xos/core/xoslib/static/js/xoslib/xos-backbone.js
@@ -383,11 +383,11 @@
for (key in attrs) {
value = attrs[key];
- if ($.inArray(key, ["urlRoot", "modelName", "collectionName", "listFields", "addFields", "detailFields", "detailLinkFields", "foreignFields", "inputType", "relatedCollections", "foreignCollections", "defaults"])>=0) {
+ if ($.inArray(key, ["urlRoot", "modelName", "collectionName", "listFields", "addFields", "detailFields", "detailLinkFields", "foreignFields", "inputType", "relatedCollections", "foreignCollections", "defaults", "disableAdd"])>=0) {
modelAttrs[key] = value;
collectionAttrs[key] = value;
}
- if ($.inArray(key, ["validate", "preSave", "readOnlyFields"])) {
+ if ($.inArray(key, ["validate", "preSave", "readOnlyFields"]) >= 0) {
modelAttrs[key] = value;
}
}
@@ -396,6 +396,8 @@
modelAttrs.defaults = get_defaults(modelName);
}
+ console.log(collectionAttrs);
+
// if ((typeof xosdefaults !== "undefined") && xosdefaults[modelName]) {
// modelAttrs["defaults"] = xosdefaults[modelName];
// }
@@ -734,6 +736,7 @@
inputType: {"firewall_enable": "checkbox",
"url_filter_enable": "checkbox",
"cdn_enable": "checkbox"},
+ disableAdd: true,
});
/* by default, have slicePlus only fetch the slices the user can see */
diff --git a/xos/core/xoslib/static/js/xoslib/xosHelper.js b/xos/core/xoslib/static/js/xoslib/xosHelper.js
index 2a1d43b..d2c75c7 100644
--- a/xos/core/xoslib/static/js/xoslib/xosHelper.js
+++ b/xos/core/xoslib/static/js/xoslib/xosHelper.js
@@ -465,8 +465,11 @@
refreshClicked: function(e) {
this.options.linkedView.refreshClicked.call(this.options.linkedView, e);
},
+
+ templateHelpers: function() { return {disableAdd: this.options.linkedView.disableAdd }; },
});
+
XOSDetailButtonView = XOSButtonView.extend({ template: "#xos-savebuttons-template" });
XOSListButtonView = XOSButtonView.extend({ template: "#xos-listbuttons-template" });
@@ -692,6 +695,8 @@
choices: this.options.choices || this.choices || this.model.choices || {},
helpText: this.options.helpText || this.helpText || this.model.helpText || {},
}},
+
+ disableAdd: function() { return this.disableAdd || this.options.disableAdd || this.model.disableAdd; },
});
XOSDetailView_sliver = XOSDetailView.extend( {
@@ -860,6 +865,8 @@
listFields: this.collection.listFields,
detailLinkFields: this.collection.detailLinkFields, };
},
+
+ disableAdd: function() { return this.disableAdd || this.options.disableAdd || this.collection.disableAdd; }
});
XOSDataTableView = Marionette.View.extend( {
@@ -1077,6 +1084,8 @@
}
},
+ disableAdd: function() { return this.disableAdd || this.options.disableAdd || this.collection.disableAdd; },
+
});
idToName = function(id, collectionName, fieldName) {
diff --git a/xos/core/xoslib/templates/xosAdmin.html b/xos/core/xoslib/templates/xosAdmin.html
index 9760390..41997f6 100644
--- a/xos/core/xoslib/templates/xosAdmin.html
+++ b/xos/core/xoslib/templates/xosAdmin.html
@@ -217,7 +217,9 @@
<div class="box save-box">
<button class="btn btn-high btn-info btn-xos-contentButtonPanel btn-xos-save-leave">Save</button>
<button class="btn btn-high btn-xos-contentButtonPanel btn-xos-save-continue">Save and continue editing</button>
+ <% if (!disableAdd) { %>
<button class="btn btn-high btn-xos-contentButtonPanel btn-xos-save-another">Save and add another</button>
+ <% }; %>
<button class="btn btn-danger btn-xos-contentButtonPanel btn-xos-delete">Delete</button>
</div>
</script>
@@ -225,7 +227,9 @@
<script type="text/template" id="xos-listbuttons-template">
<div class="box save-box">
<button class="btn btn-high btn-primary btn-xos-contentButtonPanel btn-xos-refresh">Refresh</button>
+ <% if (!disableAdd) { %>
<button class="btn btn-high btn-success btn-xos-contentButtonPanel btn-xos-add">Add</button>
+ <% }; %>
</div>
</script>