Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
bfeccd88
Commit
bfeccd88
authored
Sep 29, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable creation of new components
parent
80579860
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
37 deletions
+37
-37
cms/djangoapps/contentstore/views.py
+2
-11
cms/static/coffee/src/views/module_edit.coffee
+13
-2
cms/static/js/base.js
+19
-21
cms/templates/unit.html
+3
-3
No files found.
cms/djangoapps/contentstore/views.py
View file @
bfeccd88
...
@@ -145,15 +145,7 @@ def edit_unit(request, location):
...
@@ -145,15 +145,7 @@ def edit_unit(request, location):
else
:
else
:
lms_link
=
None
lms_link
=
None
<<<<<<<
HEAD
return
render_to_response
(
'unit.html'
,
{
'module'
:
item
,
'editable_preview'
:
get_module_previews
(
request
,
item
)[
0
],
})
=======
component_templates
=
defaultdict
(
list
)
component_templates
=
defaultdict
(
list
)
>>>>>>>
Separate
unit
page
from
vertical
implementation
for
editing
templates
=
modulestore
()
.
get_items
(
Location
(
'i4x'
,
'edx'
,
'templates'
))
templates
=
modulestore
()
.
get_items
(
Location
(
'i4x'
,
'edx'
,
'templates'
))
for
template
in
templates
:
for
template
in
templates
:
...
@@ -170,7 +162,7 @@ def edit_unit(request, location):
...
@@ -170,7 +162,7 @@ def edit_unit(request, location):
]
]
return
render_to_response
(
'unit.html'
,
{
return
render_to_response
(
'unit.html'
,
{
'unit
_name'
:
item
.
display_name
,
'unit
'
:
item
,
'components'
:
components
,
'components'
:
components
,
'component_templates'
:
component_templates
,
'component_templates'
:
component_templates
,
})
})
...
@@ -432,7 +424,7 @@ def clone_item(request):
...
@@ -432,7 +424,7 @@ def clone_item(request):
modulestore
()
.
update_metadata
(
new_item
.
location
.
url
(),
new_item
.
own_metadata
)
modulestore
()
.
update_metadata
(
new_item
.
location
.
url
(),
new_item
.
own_metadata
)
modulestore
()
.
update_children
(
parent_location
,
parent
.
definition
.
get
(
'children'
,
[])
+
[
new_item
.
location
.
url
()])
modulestore
()
.
update_children
(
parent_location
,
parent
.
definition
.
get
(
'children'
,
[])
+
[
new_item
.
location
.
url
()])
return
HttpResponse
(
)
return
preview_component
(
request
,
new_item
.
location
)
'''
'''
cdodge: this method allows for POST uploading of files into the course asset library, which will
cdodge: this method allows for POST uploading of files into the course asset library, which will
...
@@ -523,4 +515,3 @@ def upload_asset(request, org, course, coursename):
...
@@ -523,4 +515,3 @@ def upload_asset(request, org, course, coursename):
logging
.
error
(
'Failed to generate thumbnail for {0}. Continuing...'
.
format
(
name
))
logging
.
error
(
'Failed to generate thumbnail for {0}. Continuing...'
.
format
(
name
))
return
HttpResponse
(
'Upload completed'
)
return
HttpResponse
(
'Upload completed'
)
cms/static/coffee/src/views/module_edit.coffee
View file @
bfeccd88
...
@@ -32,12 +32,23 @@ class CMS.Views.ModuleEdit extends Backbone.View
...
@@ -32,12 +32,23 @@ class CMS.Views.ModuleEdit extends Backbone.View
return
_metadata
return
_metadata
render
:
->
cloneTemplate
:
(
template
,
name
)
->
@
$el
.
load
(
"/preview_component/
#{
@
model
.
id
}
"
,
=>
@
$el
.
load
(
"/clone_item"
,
{
parent_location
:
@
$el
.
parent
().
data
(
'id'
)
template
:
template
name
:
name
},
=>
@
loadModules
()
@
loadModules
()
@
delegateEvents
()
@
delegateEvents
()
)
)
render
:
->
if
@
model
.
id
@
$el
.
load
(
"/preview_component/
#{
@
model
.
id
}
"
,
=>
@
loadModules
()
@
delegateEvents
()
)
clickSaveButton
:
(
event
)
=>
clickSaveButton
:
(
event
)
=>
event
.
preventDefault
()
event
.
preventDefault
()
data
=
@
module
.
save
()
data
=
@
module
.
save
()
...
...
cms/static/js/base.js
View file @
bfeccd88
...
@@ -10,7 +10,8 @@ $(document).ready(function() {
...
@@ -10,7 +10,8 @@ $(document).ready(function() {
$modal
=
$
(
'.history-modal'
);
$modal
=
$
(
'.history-modal'
);
$modalCover
=
$
(
'.modal-cover'
);
$modalCover
=
$
(
'.modal-cover'
);
$newComponentItem
=
$
(
'.new-component-item'
);
$newComponentItem
=
$
(
'.new-component-item'
);
$newComponentChooser
=
$
(
'.new-component'
);
$newComponentTypePicker
=
$
(
'.new-component'
);
$newComponentTemplatePickers
=
$
(
'.new-component-templates'
);
$newComponentButton
=
$
(
'.new-component-button'
);
$newComponentButton
=
$
(
'.new-component-button'
);
$
(
'li.component'
).
each
(
function
(
idx
,
element
)
{
$
(
'li.component'
).
each
(
function
(
idx
,
element
)
{
...
@@ -26,7 +27,10 @@ $(document).ready(function() {
...
@@ -26,7 +27,10 @@ $(document).ready(function() {
$
(
'.visibility-options'
).
bind
(
'change'
,
setVisibility
);
$
(
'.visibility-options'
).
bind
(
'change'
,
setVisibility
);
$newComponentButton
.
bind
(
'click'
,
showNewComponentForm
);
$newComponentButton
.
bind
(
'click'
,
showNewComponentForm
);
$newComponentChooser
.
find
(
'.new-component-type a'
).
bind
(
'click'
,
showComponentTemplates
);
$newComponentTypePicker
.
find
(
'.new-component-type a'
).
bind
(
'click'
,
showComponentTemplates
);
$newComponentTypePicker
.
find
(
'.cancel-button'
).
bind
(
'click'
,
closeNewComponent
);
$newComponentTemplatePickers
.
find
(
'.new-component-template a'
).
bind
(
'click'
,
saveNewComponent
);
$newComponentTemplatePickers
.
find
(
'.cancel-button'
).
bind
(
'click'
,
closeNewComponent
);
$
(
'.unit-history ol a'
).
bind
(
'click'
,
showHistoryModal
);
$
(
'.unit-history ol a'
).
bind
(
'click'
,
showHistoryModal
);
$modal
.
bind
(
'click'
,
hideHistoryModal
);
$modal
.
bind
(
'click'
,
hideHistoryModal
);
...
@@ -58,21 +62,22 @@ function showNewComponentForm(e) {
...
@@ -58,21 +62,22 @@ function showNewComponentForm(e) {
e
.
preventDefault
();
e
.
preventDefault
();
$newComponentItem
.
addClass
(
'adding'
);
$newComponentItem
.
addClass
(
'adding'
);
$
(
this
).
slideUp
(
150
);
$
(
this
).
slideUp
(
150
);
$newComponent
Chooser
.
slideDown
(
1
50
);
$newComponent
TypePicker
.
slideDown
(
2
50
);
}
}
function
showComponentTemplates
(
e
)
{
function
showComponentTemplates
(
e
)
{
e
.
preventDefault
();
e
.
preventDefault
();
var
type
=
$
(
this
).
data
(
'type'
);
var
type
=
$
(
this
).
data
(
'type'
);
$newComponent
Choos
er
.
slideUp
(
250
);
$newComponent
TypePick
er
.
slideUp
(
250
);
$
(
'.new-component-'
+
type
).
slideDown
(
250
);
$
(
'.new-component-'
+
type
).
slideDown
(
250
);
}
}
function
c
ancel
NewComponent
(
e
)
{
function
c
lose
NewComponent
(
e
)
{
e
.
preventDefault
();
e
.
preventDefault
();
$newComponentStep2
.
slideUp
(
250
);
$newComponentTypePicker
.
slideUp
(
250
);
$newComponentTemplatePickers
.
slideUp
(
250
);
$newComponentButton
.
slideDown
(
250
);
$newComponentButton
.
slideDown
(
250
);
$newComponentItem
.
removeClass
(
'adding'
);
$newComponentItem
.
removeClass
(
'adding'
);
$newComponentItem
.
find
(
'.rendered-component'
).
remove
();
$newComponentItem
.
find
(
'.rendered-component'
).
remove
();
...
@@ -81,22 +86,15 @@ function cancelNewComponent(e) {
...
@@ -81,22 +86,15 @@ function cancelNewComponent(e) {
function
saveNewComponent
(
e
)
{
function
saveNewComponent
(
e
)
{
e
.
preventDefault
();
e
.
preventDefault
();
var
$newComponent
=
$newComponentItem
.
clone
();
editor
=
new
CMS
.
Views
.
ModuleEdit
({
$newComponent
.
removeClass
(
'adding'
).
removeClass
(
'new-component-item'
);
model
:
new
CMS
.
Models
.
Module
()
$newComponent
.
find
(
'.new-component-step-2'
).
removeClass
(
'new-component-step-2'
).
addClass
(
'component-editor'
);
})
setTimeout
(
function
()
{
$newComponent
.
find
(
'.component-editor'
).
slideUp
(
250
);
$
(
'.components'
).
append
(
editor
.
$el
)
},
10
);
$newComponent
.
append
(
'<div class="component-actions"><a href="#" class="edit-button"><span class="edit-icon white"></span>Edit</a><a href="#" class="delete-button"><span class="delete-icon white"></span>Delete</a> </div><a href="#" class="drag-handle"></a>'
);
editor
.
cloneTemplate
(
$
(
this
).
data
(
'location'
))
$newComponent
.
find
(
'.new-component-step-1'
).
remove
();
$newComponent
.
find
(
'.new-component-button'
).
remove
();
$newComponentStep2
.
slideUp
(
250
);
$newComponentButton
.
slideDown
(
250
);
$newComponentItem
.
removeClass
(
'adding'
);
$newComponentItem
.
find
(
'.rendered-component'
).
remove
();
$newComponentItem
.
before
(
$newComponent
);
closeNewComponent
(
e
);
}
}
function
showHistoryModal
(
e
)
{
function
showHistoryModal
(
e
)
{
...
...
cms/templates/unit.html
View file @
bfeccd88
...
@@ -9,10 +9,10 @@
...
@@ -9,10 +9,10 @@
<ul>
<ul>
<li><a
href=
"#"
>
Week 2
</a></li>
<li><a
href=
"#"
>
Week 2
</a></li>
<li><a
href=
"#"
>
Linearity and Superposition
</a></li>
<li><a
href=
"#"
>
Linearity and Superposition
</a></li>
<li><span
class=
"current-page"
>
${unit_name}
</span></li>
<li><span
class=
"current-page"
>
${unit
.display
_name}
</span></li>
</ul>
</ul>
</nav>
</nav>
<ol
class=
"components"
>
<ol
class=
"components"
data-id=
"${unit.location.url()}"
>
% for id in components:
% for id in components:
<li
class=
"component"
data-id=
"${id}"
/>
<li
class=
"component"
data-id=
"${id}"
/>
% endfor
% endfor
...
@@ -56,7 +56,7 @@
...
@@ -56,7 +56,7 @@
<div
class=
"unit-properties window"
>
<div
class=
"unit-properties window"
>
<h4>
Properties
</h4>
<h4>
Properties
</h4>
<div
class=
"window-contents"
>
<div
class=
"window-contents"
>
<div
class=
"row"
><label>
Display Name:
</label><input
type=
"text"
value=
"${unit_name}"
/></div>
<div
class=
"row"
><label>
Display Name:
</label><input
type=
"text"
value=
"${unit
.display
_name}"
/></div>
<div
class=
"row"
>
<div
class=
"row"
>
<label>
State:
</label>
<label>
State:
</label>
<div
class=
"visibility-options"
>
<div
class=
"visibility-options"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment