app/assets/javascripts/slices/app/helpers/assets.js in slices-1.0.3 vs app/assets/javascripts/slices/app/helpers/assets.js in slices-1.0.4
- old
+ new
@@ -1,15 +1,22 @@
// Create an attachment composer for a collection
//
// Within the attachmentComposer, define the html for the fields the composer
// should display. Here, we’re assuming there’s a field on the slice called
-// `myAttachments`.
+// `slides`.
//
-// {{#attachmentComposer myAttachments}}
+// {{#attachmentComposer field="slides"}}
// <textarea name="caption" class="full-height">{{caption}}</textarea>
// {{/attachmentComposer}}
//
+// By default, attachment composer does not allow the same asset to be added
+// twice. To allow duplicates, set the `allowDupes` option to true:
+//
+// {{#attachmentComposer field="slides" allowDupes=true}}
+// <textarea name="caption" class="full-height">{{caption}}</textarea>
+// {{/attachmentComposer}}
+//
Handlebars.registerHelper('attachmentComposer', function(options) {
if (!options.hash) {
return new Handlebars.SafeString(
'<code style="color: red">' +
'DEPRECATION: Please use the new attachmentComposer syntax: ' +
@@ -21,10 +28,11 @@
// Instantiate an AssetComposerView.
var composer = new slices.AttachmentComposerView({
id : slices.fieldId(this, options.hash.field),
collection : this[options.hash.field],
fields : options.fn,
- autoAttach : true
+ autoAttach : true,
+ allowDupes : options.hash.allowDupes
});
// Return the placeholder. Don’t worry, this is replaced automatically later.
return new Handlebars.SafeString(composer.placeholder());
});