diff --git a/scripts/gh-book/app.coffee b/scripts/gh-book/app.coffee index 8991827a..3aca9726 100644 --- a/scripts/gh-book/app.coffee +++ b/scripts/gh-book/app.coffee @@ -95,11 +95,6 @@ define [ mediaTypes.add BinaryFile, {mediaType:'image/png'} mediaTypes.add BinaryFile, {mediaType:'image/jpeg'} - # set which media formats are allowed - # at the toplevel of the content - for type in EpubContainer::accept - mediaTypes.type(type)::toplevel = true - # Views use anchors with hrefs so catch the click and send it to Backbone $(document).on 'click', 'a:not([data-bypass]):not([href="#"])', (e) -> external = new RegExp('^((f|ht)tps?:)?//') diff --git a/scripts/views/layouts/workspace/sidebar.coffee b/scripts/views/layouts/workspace/sidebar.coffee index 8c370c40..8fe831fb 100644 --- a/scripts/views/layouts/workspace/sidebar.coffee +++ b/scripts/views/layouts/workspace/sidebar.coffee @@ -37,7 +37,12 @@ define [ # This is the Picker/Roots Sidebar collection = new Backbone.FilteredCollection(null, {collection:collection}) collection.setFilter (content) -> return content.getChildren - @filteredMediaTypes.setFilter (type) -> return type.get('modelType')::toplevel + # TODO: Remove `topLevel` from all models + @filteredMediaTypes.setFilter (type) -> + # Filter the types to exclude Chapters and other non-loadable content. + # Written this way to support `gh-book` **and** `atc`; if something is loadable then it is creatable. + return type.get('modelType')::load + # TODO: Make the collection a FilteredCollection that only shows @model.accepts @addContent.show(new AddView {context:model, collection:@filteredMediaTypes}) diff --git a/scripts/views/workspace/menu/add.coffee b/scripts/views/workspace/menu/add.coffee index 9c338327..d356796c 100644 --- a/scripts/views/workspace/menu/add.coffee +++ b/scripts/views/workspace/menu/add.coffee @@ -36,8 +36,8 @@ define [ # Only add Models to `allContent` if they can be saved. # # ToC Sections, for example, cannot be saved but do implement Saveable because OpfFile extends TocNode - # So we use `.id` instead. - if model.id + # So we use `.load` instead. + if model.load allContent.add(model) # Add the model to the context