From e620317996ffd6600a702c30e74f475eafc26bd7 Mon Sep 17 00:00:00 2001 From: Scott Baker Date: Wed, 17 Dec 2014 16:29:59 -0800 Subject: [PATCH] syphonall support for picker --- .../core/xoslib/static/js/xoslib/xosHelper.js | 16 +++++++++++++++- planetstack/core/xoslib/templates/xosAdmin.html | 4 ++-- 2 files changed, 17 insertions(+), 3 deletions(-) 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 @@ XOSRouter = Marionette.AppRouter.extend({ }, }); - +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 @@ XOSDetailView = Marionette.ItemView.extend({ 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 @@ <%= readOnly %>> <% } else if (inputType[fieldName] == "picker") { %> <% lookupFunc = makeIdToName(model.m2mFields[fieldName], "humanReadableName"); %> - <%= xosPickerTemplate({pickedItems: model.attributes[fieldName], unpickedItems: model.getChoices(fieldName,true), id: "picker_" + fieldName, detailView: detailView, lookupFunc: lookupFunc}) %> + <%= xosPickerTemplate({pickedItems: model.attributes[fieldName], unpickedItems: model.getChoices(fieldName,true), id: "picker_" + fieldName, fieldName: fieldName, detailView: detailView, lookupFunc: lookupFunc}) %> <% } else if (fieldName=="backend_status") { %> <%= xosBackendStatusTextTemplate.apply(this, args) %> <% } else { %> @@ -239,7 +239,7 @@
Selected
- class="select-picker-to syphonall" multiple size="5"> <% _.each(pickedItems, function(item) { %> <% }); %> -- 2.43.0