From 84e9126b93b72653b1032d751f29988c37e1ff4b Mon Sep 17 00:00:00 2001 From: Philip Schatz Date: Tue, 29 Oct 2013 15:44:44 -0400 Subject: [PATCH 1/2] exclude "New Chapter" from the book picker add button --- scripts/gh-book/app.coffee | 5 ----- scripts/views/layouts/workspace/sidebar.coffee | 6 +++++- scripts/views/workspace/menu/add.coffee | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) 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..24ad9e00 100644 --- a/scripts/views/layouts/workspace/sidebar.coffee +++ b/scripts/views/layouts/workspace/sidebar.coffee @@ -37,7 +37,11 @@ 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 + 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 From 0beda3a60d7aec05c7b2f311d6f07685e6da5914 Mon Sep 17 00:00:00 2001 From: Philip Schatz Date: Wed, 30 Oct 2013 15:29:26 -0400 Subject: [PATCH 2/2] add comment explaining why .accept is not sufficient --- scripts/views/layouts/workspace/sidebar.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/views/layouts/workspace/sidebar.coffee b/scripts/views/layouts/workspace/sidebar.coffee index 24ad9e00..8fe831fb 100644 --- a/scripts/views/layouts/workspace/sidebar.coffee +++ b/scripts/views/layouts/workspace/sidebar.coffee @@ -39,7 +39,8 @@ define [ collection.setFilter (content) -> return content.getChildren # TODO: Remove `topLevel` from all models @filteredMediaTypes.setFilter (type) -> - # Filter the types to exclude Chapters and other non-loadable content + # 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