External module loading
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
class CMS.Models.Module extends Backbone.Model
|
||||
initialize: ->
|
||||
try
|
||||
@module = new window[@get('type')](@get('id'))
|
||||
catch TypeError
|
||||
console.error "Unable to load #{@get('type')}." if console
|
||||
|
||||
editUrl: ->
|
||||
"/edit_item?id=#{@get('id')}"
|
||||
"/edit_item?#{$.param(id: @get('id'))}"
|
||||
|
||||
@@ -3,7 +3,7 @@ class CMS.Views.Module extends Backbone.View
|
||||
"click .module-edit": "edit"
|
||||
|
||||
initialize: ->
|
||||
@model = new CMS.Models.Module(id: @el.id)
|
||||
@model = new CMS.Models.Module(id: @$el.data('id'), type: @$el.data('type'))
|
||||
|
||||
edit: =>
|
||||
CMS.trigger('showContent', new CMS.Views.ModuleEdit(model: @model))
|
||||
|
||||
@@ -3,4 +3,4 @@ class CMS.Views.WeekEdit extends Backbone.View
|
||||
className: 'edit-pane'
|
||||
|
||||
initialize: ->
|
||||
CMS.trigger 'week.edit'
|
||||
CMS.trigger('week.edit')
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
<ol id="weeks">
|
||||
% for week in weeks:
|
||||
<li id="${week.location.url()}">
|
||||
<li class="week" data-id="${week.location.url()}">
|
||||
<header>
|
||||
<h1><a href="#" class="module-edit">${week.name}</a></h1>
|
||||
<ul>
|
||||
@@ -50,9 +50,9 @@
|
||||
</ul>
|
||||
</header>
|
||||
|
||||
<ul id="modules">
|
||||
<ul class="modules">
|
||||
% for module in week.get_children():
|
||||
<li class="module" data-type="${module.category}" data-id="${module.location.url()}">
|
||||
<li class="module" data-id="${module.location.url()}" data-type="${module.category}">
|
||||
<a href="#" class="module-edit">${module.name}</a>
|
||||
<a href="#" class="draggable">handle</a>
|
||||
</li>
|
||||
|
||||
Reference in New Issue
Block a user