Remove remaining unused collections stuff

cameron removed most of the controller/model stuff in:
3c434e8aff

but this removes the remaining view/coffeescript/stuff

Test plan:
  canvas should still work
  (sorry, this looks big but none of it was ever actually loaded)

Change-Id: Ie4e31fcdf5bc2820c9eafaef6e8b25332aaea4bc
Reviewed-on: https://gerrit.instructure.com/37508
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
QA-Review: Ryan Shaw <ryan@instructure.com>
This commit is contained in:
Ryan Shaw 2014-07-10 11:38:24 -06:00
parent 32965c3bd7
commit a221235aa4
19 changed files with 0 additions and 669 deletions

View File

@ -1,27 +0,0 @@
##
# Listens to clicks on elements that have `data-follow` attributes.
# the attribute should be set to '{"id":5, "type": "user"}' of the item you want to (un)follow.
# When complete,
# publishes a '(un)follow' event with [id, type, ServerResp, 'success', jqXHR] as args
# markup examples:
# <a data-follow='{"id":5, "type": "user"}' href="#">Follow user 5</a>
# <a data-follow='{"id":5, "type": "collection"}' href="#">UN-follow collection 5</a>
define [
'jquery'
'underscore'
'compiled/fn/preventDefault'
'vendor/jquery.ba-tinypubsub'
], ($, _, preventDefault, {publish}) ->
followableTypes =
user: '/api/v1/users'
collection: '/api/v1/collections'
_.each {follow: 'PUT', unfollow: 'DELETE'}, (method, action) ->
$(document).delegate "[data-#{action}]", 'click', preventDefault ->
{type, id} = $(this).data(action)
url = "#{followableTypes[type]}/#{id}/followers/self"
$.ajax(url, type: method).success ->
publish action, [id, type, arguments...]

View File

@ -1,38 +0,0 @@
##
# Listens to clicks on elements that have `data-repin-item` attribute.
# the attribute should be set to the id of the item you want to repin.
# markup example:
# <a data-repin-item='2' href="#">repin collectionItem 2</a>
define [
'jquery'
'compiled/fn/preventDefault'
'vendor/jquery.ba-tinypubsub'
'compiled/views/KollectionItems/KollectionItemSaveView'
'compiled/models/KollectionItem'
'jst/KollectionItems/modalSaveTemplate'
# needed by modalSaveTemplate
'jst/_avatar'
], ($, preventDefault, {publish}, KollectionItemSaveView, KollectionItem, modalSaveTemplate) ->
$(document).delegate "[data-repin-item]", 'click', preventDefault ->
itemId = $(this).data("repinItem")
kollectionItem = new KollectionItem
link_url: "/api/v1/collections/items/#{itemId}"
$dialog = $(modalSaveTemplate(ENV.current_user)).dialog
width: 700
resizable: false
modal: false
title: 'Pin To Canvas Network'
kollectionItemSaveView = new KollectionItemSaveView
model: kollectionItem
el: $dialog.find('#kollectionItemSaveViewContainer')
kollectionItem.on 'create sync', ->
# TODO publish some info about how I was re-pinned
$dialog.dialog('close')

View File

@ -1,24 +0,0 @@
##
# Listens to clicks on elements that have `data-upvote-item` and `data-deupvote-item` attributes.
# the attribute should be set to the id of the item you want to (de)upvote.
# When complete,
# publishes a '(de)upvoteItem' event with [ServerResp, 'success', jqXHR] as args
# markup examples:
# <a data-upvote-item='2' href="#">Upvote collectionItem 2</a>
# <a data-deupvote-item='2' href="#">De-Upvote collectionItem 2</a>
define [
'jquery'
'underscore'
'compiled/fn/preventDefault'
'vendor/jquery.ba-tinypubsub'
], ($, _, preventDefault, {publish}) ->
_.each ['upvote', 'deupvote'], (action) ->
$(document).delegate "[data-#{action}-item]", 'click', preventDefault ->
itemId = $(this).data("#{action}Item")
type = {upvote: 'PUT', deupvote: 'DELETE'}[action]
url = "/api/v1/collections/items/#{itemId}/upvotes/self"
$.ajax(url, type: type).success ->
publish "#{action}Item", [itemId, arguments...]

View File

@ -1,34 +0,0 @@
canvasDomain = 'put_canvas_domain_here'
# matches '//foo.bar/' in 'http://foo.bar/baz.js'
reDomainWithSlashes = /\/\/\S*\//
getSelection = ->
selection = if window.getSelection
window.getSelection()
else if document.getSelection
document.getSelection()
else
document.selection.createRange().text
"#{selection}".replace /(^\s+|\s+$)/g, ""
pin = (urlToPin) ->
width = 700
height = 450
left = Math.round((screen.width / 2) - (width / 2))
screenHeight = screen.height
top = if screenHeight > height
Math.round((screenHeight / 2) - (width / 2))
else
0
queryString = [
"popup=1"
"link_url=#{encodeURIComponent(urlToPin)}"
"description=#{encodeURIComponent(getSelection().substr(0, 1000))}"
].join('&')
popupUrl = "//#{canvasDomain}/collection_items/new/?#{queryString}"
windowFeatures = "width=#{width},height=#{height},left=#{left},top=#{top},status=no,resizable=yes,scrollbars=yes,personalbar=no,directories=no,location=no,toolbar=no,menubar=no"
window.open(popupUrl, "popup#{+(new Date)}", windowFeatures)
pin(window.location)

View File

@ -1,40 +0,0 @@
define [
'compiled/views/QuickStartBar/BaseItemView'
'jquery'
'underscore'
'compiled/models/Announcement'
'jst/quickStartBar/announcement'
'jquery.instructure_date_and_time'
], (BaseItemView, $, _, Announcement, template) ->
class AnnouncementView extends BaseItemView
template: template
contextSearchOptions:
fakeInputWidth: '100%'
contexts: ENV.CONTEXTS
placeholder: "Type the name of a class to announce this too..."
selector:
baseData:
type: 'course'
noExpand: true
browser: false
save: (json) ->
# get real date
if json.assignment?.due_at?
json.assignment.due_at = @$('.datetime_suggest').text()
# map the context_ids into deferreds, saving a copy for each context
dfds = _.map json.context_ids, (id) =>
model = new Announcement json
model.contextCode = id
model.save()
$.when dfds...
@type: 'announcement'
@title: -> super 'announcement', 'Announcement'

View File

@ -1,17 +0,0 @@
define [
'Backbone'
'compiled/quickStartBar/models/Assignment'
'jst/quickStartBarTemplates/assignment'
'jquery.instructure_date_and_time'
], ({View}, Assignment, template) ->
class AssignmentView extends View
render: ->
html = template @model.toJSON
@$el.html html
@filter()
afterRender: ->
@$('.dateField').datetime_field()

View File

@ -1,35 +0,0 @@
define [
'compiled/views/QuickStartBar/BaseItemView'
'jquery'
'underscore'
'compiled/models/QuickStartAssignment'
'jst/quickStartBar/assignment'
'compiled/widget/ContextSearch'
'jquery.instructure_date_and_time'
'jquery.disableWhileLoading'
], (BaseItemView, $, _, QuickStartAssignment, template, ContextSearch) ->
class AssignmentView extends BaseItemView
template: template
contextSearchOptions:
fakeInputWidth: '100%'
contexts: ENV.CONTEXTS
placeholder: "Type the name of a class to assign this to..."
selector:
baseData:
type: 'course'
noExpand: true
browser: false
save: (json) ->
json.date = @$('.datetime_suggest').text()
dfds = _.map json.course_ids, (id) =>
model = new QuickStartAssignment json
model.set 'course_id', id.replace /^course_/, ''
model.save()
$.when dfds...
@type: 'assignment'
@title: -> super 'assignment', 'Assignment'

View File

@ -1,82 +0,0 @@
define [
'Backbone'
'underscore'
'jquery'
'compiled/widget/ContextSearch'
'jquery.instructure_date_and_time'
'jquery.disableWhileLoading'
], ({View}, _, $, ContextSearch) ->
##
# Base class for all quickstart bar form views.
# Emits 'save' and 'saveFail' events when the underlying model is saved.
class BaseItemView extends View
##
# The form submit event is handled in this base class.
# Remember when extending with coffeescript the `events` will get
# overwritten, so you need to do something like this to not blow
# this event away:
#
# class Sub extends BaseItemView
# events: _.extend
# 'click .something': 'someHandler'
# , BaseItemView::events
events:
'submit form': 'onFormSubmit'
##
# Sub-classes should define a template function that returns
# a string. Typically this will be a pre-compiled handlebars template.
template: -> ''
##
# ContextSearch has a lengthy api, each sub-class should define
# the contextSearchOptions in its entirety, and it will be automatically
# created
contextSearchOptions:
fakeInputWidth: '100%'
contexts: ENV.CONTEXTS
placeholder: "Type the name of a class to assign this too..."
selector:
baseData:
type: 'course'
noExpand: true
browser: false
##
# Renders the template and sets the @$el html
render: ->
@$el.html @template()
super
##
# Creates date pickers and context search instances after render
afterRender: ->
@$('.dateField').datetime_field()
@contextSearch = new ContextSearch @$('.contextSearch'), @contextSearchOptions
teardown: ->
@contextSearch.teardown()
##
# Form submit handler, converts the form into a JavaScript object and calls
# the `@save` method. Also handles some shared display concerns.
onFormSubmit: (event) ->
event.preventDefault()
$form = $ event.target
json = $(event.target).toJSON()
dfd = @save json
@$('form').disableWhileLoading dfd
dfd.done => @trigger 'save'
dfd.fail => @trigger 'saveFail'
##
# Sub-classes should implement their own save method
# that returns a deferred object, used in `@onFormSubmit`
save: -> @model.save()
@title: (scope, text) ->
title = ""
I18n.scoped('dashboard', (i) -> title = i.t scope, text)
title

View File

@ -1,54 +0,0 @@
define [
'compiled/views/QuickStartBar/BaseItemView'
'jquery'
'underscore'
'compiled/models/DiscussionTopic'
'jst/quickStartBar/discussion'
'jquery.instructure_date_and_time'
'vendor/jquery.placeholder'
], (BaseItemView, $, _, Discussion, template) ->
class DiscussionView extends BaseItemView
events: _.extend
'change [name=graded]': 'onGradedClick'
, BaseItemView::events
template: template
contextSearchOptions:
fakeInputWidth: '100%'
contexts: ENV.CONTEXTS
placeholder: "Type the name of a class to send this too..."
selector:
baseData:
type: 'course'
noExpand: true
browser: false
onGradedClick: (event) ->
graded = event.target.checked
@$('[name="assignment[points_possible]"], [name="assignment[due_at]"]').prop 'disabled', not graded
@$('.ui-datepicker-trigger').toggleClass 'disabled', not graded
save: (json) ->
# get real date
if json.assignment?.due_at?
json.assignment.due_at = @$('.datetime_suggest').text()
# map the context_ids into deferreds, saving a copy for each course
dfds = _.map json.context_ids, (id) =>
model = new Discussion json
model.contextCode = id
model.save()
$.when dfds...
afterRender: ->
super
@$('.ui-datepicker-trigger').addClass('disabled')
@type: 'discussion'
@title: -> super 'discussion', 'Discussion'

View File

@ -1,39 +0,0 @@
define [
'i18n!dashboard'
'jquery'
'underscore'
'compiled/views/QuickStartBar/BaseItemView'
'compiled/models/CalendarEvent'
'jst/quickStartBar/event'
'compiled/jquery.rails_flash_notifications'
'jquery.disableWhileLoading'
], (I18n, $, _, BaseItemView, CalendarEvent, template) ->
class EventView extends BaseItemView
template: template
contextSearchOptions:
fakeInputWidth: '100%'
contexts: ENV.CONTEXTS
placeholder: "Type the name of a class to add this to..."
selector:
baseData:
type: 'course'
noExpand: true
browser: false
save: (json) ->
date = @$('.datetime_suggest').text()
json.start_at = date
json.end_at = date
delete json.date
dfds = _.map json.context_code, (code) =>
model = new CalendarEvent json
model.set 'context_code', code
model.save().done ->
$.when(dfds...).done ->
$.flashMessage I18n.t 'event_created', 'Event created'
@type: 'event'
@title: -> super 'event', 'Event'

View File

@ -1,10 +0,0 @@
define ['Backbone'], ({View}) ->
class ItemView extends View
render: ->
html = @template @present()
@$el.html html
super

View File

@ -1,32 +0,0 @@
define [
'i18n!dashboard'
'jquery'
'compiled/views/QuickStartBar/BaseItemView'
'compiled/models/Message'
'jst/quickStartBar/message'
'compiled/jquery.rails_flash_notifications'
'jquery.disableWhileLoading'
], (I18n, $, BaseItemView, Message, template) ->
class MessageView extends BaseItemView
template: template
contextSearchOptions:
fakeInputWidth: '100%'
contexts: ENV.CONTEXTS
placeholder: "Type the name of the person to send this to..."
selector:
noExpand: true
browser: false
initialize: ->
super
@model or= new Message
save: (json) ->
@model.save(json).done ->
$.flashMessage I18n.t 'message_sent', 'Message Sent'
@type: 'message'
@title: -> super 'message', 'Message'

View File

@ -1,70 +0,0 @@
define [
'jquery'
'underscore'
'compiled/views/KollectionItems/KollectionItemSaveView'
'compiled/views/QuickStartBar/BaseItemView'
'compiled/models/Pin'
'jst/quickStartBar/pin'
'compiled/models/KollectionItem'
'jquery.instructure_date_and_time'
'compiled/jquery.rails_flash_notifications'
], ($, _, KollectionItemSaveView, BaseItemView, Pin, template, KollectionItem) ->
class QuickStartKollectionItemSaveView extends KollectionItemSaveView
render: =>
super
@$('.toolbar').removeClass('toolbar')
@$('.box-header').removeClass('box-header')
@$('.box-content').removeClass('box-content').addClass('v-gutter')
@$('.btn').addClass('small-button')
@$('[autoFocus]').removeAttr('autoFocus')
class PinView extends BaseItemView
events: _.extend
'keyup [name=url]': 'onUrlKeyUp'
, BaseItemView::events
template: template
urlRegEx: /^(http(s?))?:\/\/(\w+:{0,1}\w*)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/i
render: ->
super
@createKollectionItemSaveView()
save: ->
@kollectionItemSaveView.model.save().done ->
$.flashMessage 'TODO: Add collection items to the stream >:O'
createKollectionItemSaveView: ->
@model = new KollectionItem
@kollectionItemSaveView = new QuickStartKollectionItemSaveView
model: @model
el: @$('.kollectionItemSaveView')[0]
onUrlKeyUp: _.throttle (event) ->
$el = $ event.target
val = $el.val()
url = @addHTTP val
@updateLinkData url
, 1000
addHTTP: (url) ->
if /^http(s)?:\/\//.test url
url
else
"http://#{url}"
updateLinkData: (url) ->
return if url is @url
@model.set 'title', null
@url = url
if @urlRegEx.test url
@model.set 'image_url', null, silent: true
@model.set 'link_url', url, silent: true
@model.fetchLinkData()
@type: 'pin'
@title: -> super('pin', 'Pin')

View File

@ -1,91 +0,0 @@
define [
'Backbone'
'i18n!dashboard'
'jquery'
'underscore'
'jst/quickStartBar/QuickStartBarView'
'jquery.toJSON'
], ({View, Model}, I18n, $, _, template) ->
capitalize = (str) ->
str.replace /\b[a-z]/g, (match) -> match.toUpperCase()
class QuickStartBarModel extends Model
defaults:
expanded: false
##
# Controls the activity feed and the panel that filters it
class QuickStartBarView extends View
events:
'click .nav a': 'onNavClick'
'focus .expander': 'onExpandClick'
initialize: ->
super
@model or= new QuickStartBarModel
@model.on 'change:modelName', @switchFormView
@model.on 'change:expanded', @toggleExpanded
@models = {}
@formViewsObj = _.reduce @options.formViews
, (h, v) ->
h[v.type] = v
h
, {}
# not calling set() because I don't want the magic to run
@model.attributes.modelName = @options.formViews[0].type
onSaveSuccess: (model) =>
@switchFormView()
@trigger 'save'
onSaveFail: (model) =>
@switchFormView()
@trigger 'saveFail'
onNavClick: (event) ->
event.preventDefault()
type = $(event.currentTarget).data 'type'
@model.set 'modelName', type
onExpandClick: (event) ->
@model.set 'expanded', true
switchFormView: =>
@$el.removeClass @modelName if @modelName
@modelName = @model.get 'modelName'
@$el.addClass @modelName
@currentFormView?.teardown?()
@currentFormView = @views[@modelName] or= do =>
view = new @formViewsObj[@modelName]
view.on 'save', @onSaveSuccess
view.on 'saveFail', @onSaveFail
@currentFormView.render()
@$newItemFormContainer.empty().append @currentFormView.el
@model.set 'expanded', false
@updateActiveTab @modelName
toggleExpanded: (model, expanded) =>
@$el.toggleClass 'expanded', expanded
@$el.toggleClass 'not-expanded', not expanded
updateActiveTab: (modelName) ->
@$('.nav a').each (index, tab) ->
$tab = $ tab
if $tab.is "[data-type=#{modelName}]"
$tab.addClass 'active'
else
$tab.removeClass 'active'
cacheElements: ->
@$newItemFormContainer = $ '.newItemFormContainer'
render: ->
@$el.html(template formViews: @options.formViews)
@cacheElements()
@switchFormView()
super

View File

@ -1,10 +0,0 @@
define [
'compiled/views/QuickStartBar/AssignmentView'
'compiled/views/QuickStartBar/DiscussionView'
'compiled/views/QuickStartBar/AnnouncementView'
'compiled/views/QuickStartBar/MessageView'
'compiled/views/QuickStartBar/PinView'
'compiled/views/QuickStartBar/EventView'
], (AssignmentView, DiscussionView, AnnouncementView, MessageView, PinView, EventView) ->
[AssignmentView, DiscussionView, AnnouncementView, MessageView, PinView, EventView]

View File

@ -1,12 +0,0 @@
<% js = CoffeeScript.compile(File.read(Rails.root + 'app/coffeescripts/bookmarklet_source.coffee'))
bookmarklet_src = Uglifier.compile(js).
# convert whitespace to %20
# gsub(/\s/, '%20').
# replace 'put_canvas_domain_here' with the right domain name
gsub('put_canvas_domain_here', @domain_root_account.domain) %>
<h1>Canvas Bookmarklet Tester</h1>
<p>
Add this link to your Bookmarks Bar:
<a href="javascript:void(<%= bookmarklet_src %>);" onclick="alert('Drag me to the bookarks bar'); return false;" title="Drag me to the bookmarks bar to save">Pin To Canvas</a>
</p>

View File

@ -1,22 +0,0 @@
<%
jammit_css :popup
jammit_css :collection_item_save
js_bundle :collection_item_save
%>
<div class="toolbar border border-trbl">
<h2 class="header"><%= t :pin_to_canvas_network, 'Pin to Canvas Network' %></h2>
</div>
<div class="popup-container">
<div class="image-block">
<div class="image-block-image">
<%= avatar @current_user.id, url: nil %>
</div>
<div id="kollectionItemSaveViewContainer" class="image-block-content">
</div>
</div>
<h4 id="savedSuccessfullyMessage" style="display:none">
<%= t :saved_successfully, "Saved Successfully" %>
</h4>
</div>

View File

@ -1,6 +0,0 @@
<%
@body_classes << 'no-page-block'
js_bundle :collections_app
jammit_css :collections_app
%>
<div id="collectionsApp"></div>

View File

@ -797,14 +797,6 @@ routes.draw do
concerns :files
end
# commenting out all collection urls until collections are live
# resources :collection_items, :only => [:new]
# match 'get_bookmarklet', => 'collection_items#get_bookmarklet', :as => :get_bookmarklet
match 'collection_items/link_data' => 'collection_items#link_data', :as => :collection_item_link_data, :via => :post
# resources :collections, :only => [:show, :index] do
# resources :collection_items, :only => [:show, :index]
# end
scope(:controller => :outcome_results) do
get 'courses/:course_id/outcome_rollups', :action => :rollups, :path_name => 'course_outcome_rollups'
end
@ -998,7 +990,6 @@ routes.draw do
end
topic_routes("course")
topic_routes("group")
topic_routes("collection_item")
end
scope(:controller => :collaborations) do
@ -1237,23 +1228,6 @@ routes.draw do
get 'groups/:group_id/folders/:id', :controller => :folders, :action => :show, :path_name => 'group_folder'
end
scope(:controller => :collections) do
get "collections", :action => :list, :path_name => 'collections'
resources :collections, :path_prefix => "users/:user_id", :name_prefix => "user_", :only => [:index, :create]
resources :collections, :path_prefix => "groups/:group_id", :name_prefix => "group_", :only => [:index, :create]
resources :collections, :except => [:index, :create]
put "collections/:collection_id/followers/self", :action => :follow
delete "collections/:collection_id/followers/self", :action => :unfollow
scope(:controller => :collection_items) do
get "collections/:collection_id/items", :action => :index, :path_name => 'collection_items_list'
resources :items, :path_prefix => "collections/:collection_id", :name_prefix => "collection_", :controller => :collection_items, :only => [:index, :create]
resources :items, :path_prefix => "collections", :name_prefix => "collection_", :controller => :collection_items, :except => [:index, :create]
put "collections/items/:item_id/upvotes/self", :action => :upvote
delete "collections/items/:item_id/upvotes/self", :action => :remove_upvote
end
end
scope(:controller => :developer_keys) do
get 'developer_keys', :action => :index
get 'developer_keys/:id', :action => :show