syphonall support for picker
diff --git a/planetstack/core/xoslib/static/js/xoslib/xosHelper.js b/planetstack/core/xoslib/static/js/xoslib/xosHelper.js
index fe975aa..6c0c2f3 100644
--- a/planetstack/core/xoslib/static/js/xoslib/xosHelper.js
+++ b/planetstack/core/xoslib/static/js/xoslib/xosHelper.js
@@ -48,7 +48,19 @@
},
});
-
+Backbone.Syphon.InputReaders.register('select', function(el) {
+ // Modify syphon so that if a select has "syphonall" in the class, then
+ // the value of every option will be returned, regardless of whether of
+ // not it is selected.
+ if (el.hasClass("syphonall")) {
+ result = [];
+ _.each(el.find("option"), function(option) {
+ result.push($(option).val());
+ });
+ return result;
+ }
+ return el.val();
+});
XOSApplication = Marionette.Application.extend({
detailBoxId: "#detailBox",
@@ -474,6 +486,8 @@
var that = this;
var isNew = !this.model.id;
+ console.log(data);
+
this.$el.find(".help-inline").remove();
/* although model.validate() is called automatically by
diff --git a/planetstack/core/xoslib/templates/xosAdmin.html b/planetstack/core/xoslib/templates/xosAdmin.html
index 92b5046..4ad198a 100644
--- a/planetstack/core/xoslib/templates/xosAdmin.html
+++ b/planetstack/core/xoslib/templates/xosAdmin.html
@@ -161,7 +161,7 @@
<td><input type="checkbox" name="<%= fieldName %>" <% if (model.attributes[fieldName]) print("checked"); %><%= readOnly %>></td>
<% } else if (inputType[fieldName] == "picker") { %>
<% lookupFunc = makeIdToName(model.m2mFields[fieldName], "humanReadableName"); %>
- <td><%= xosPickerTemplate({pickedItems: model.attributes[fieldName], unpickedItems: model.getChoices(fieldName,true), id: "picker_" + fieldName, detailView: detailView, lookupFunc: lookupFunc}) %></td>
+ <td><%= xosPickerTemplate({pickedItems: model.attributes[fieldName], unpickedItems: model.getChoices(fieldName,true), id: "picker_" + fieldName, fieldName: fieldName, detailView: detailView, lookupFunc: lookupFunc}) %></td>
<% } else if (fieldName=="backend_status") { %>
<td><%= xosBackendStatusTextTemplate.apply(this, args) %></td>
<% } else { %>
@@ -239,7 +239,7 @@
</div>
<div class="picker_column">
<div>Selected</div>
- <select name="pickerto" class="select-picker-to" multiple size="5">
+ <select name=<%= fieldName %> class="select-picker-to syphonall" multiple size="5">
<% _.each(pickedItems, function(item) { %>
<option value="<%= item %>"><%= lookupFunc ? lookupFunc(item) : item %></option>
<% }); %>