Skip to content
Snippets Groups Projects
Commit a7dc045f authored by Prem Sichanugrist's avatar Prem Sichanugrist
Browse files

External module loading

parent 7c044aa1
No related branches found
Tags release-2020-09-04-14.56
No related merge requests found
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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment