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
fd7223bd
Commit
fd7223bd
authored
Sep 27, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make editing work, building towards drag/drop saving
parent
b91c2b66
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
93 additions
and
46 deletions
+93
-46
cms/static/coffee/src/models/module.coffee
+0
-4
cms/static/coffee/src/views/module_edit.coffee
+34
-27
cms/static/js/base.js
+2
-5
common/lib/xmodule/xmodule/js/src/discussion/display.coffee
+1
-1
common/lib/xmodule/xmodule/js/src/raw/edit/json.coffee
+3
-2
common/lib/xmodule/xmodule/js/src/raw/edit/xml.coffee
+3
-2
common/lib/xmodule/xmodule/js/src/sequence/edit.coffee
+1
-1
common/lib/xmodule/xmodule/js/src/vertical/edit.coffee
+1
-1
common/lib/xmodule/xmodule/seq_module.py
+1
-0
common/static/coffee/src/xmodule.coffee
+44
-2
lms/templates/seq_module.html
+3
-1
No files found.
cms/static/coffee/src/models/module.coffee
View file @
fd7223bd
...
...
@@ -10,7 +10,3 @@ class CMS.Models.Module extends Backbone.Model
@
unset
(
'module'
)
delete
attributes
.
module
super
(
attributes
)
save
:
(
args
...)
->
@
set
(
data
:
@
module
.
save
())
if
@
module
super
(
args
...)
cms/static/coffee/src/views/module_edit.coffee
View file @
fd7223bd
...
...
@@ -3,58 +3,65 @@ class CMS.Views.ModuleEdit extends Backbone.View
className
:
'xmodule_edit'
initialize
:
->
@
delegate
()
@
module
=
@
options
.
module
@
module
.
onUpdate
(
@
save
)
@
$component_editor
=
@
$el
.
find
(
'.component-editor'
)
@
$metadata
=
@
$component_editor
.
find
(
'.metadata_edit'
)
@
setEvents
()
delegate
:
->
$component_editor
:
->
@
$el
.
find
(
'.component-editor'
)
setEvents
:
->
id
=
@
$el
.
data
(
'id'
)
events
=
{}
events
[
"click .component-editor[data-id=
#{
id
}
] .cancel-button"
]
=
'cancel
'
events
[
"click .component-editor[data-id=
#{
id
}
] .save-button"
]
=
'save
'
events
[
"click .component-actions[data-id=
#{
id
}
] .edit-button"
]
=
'edit
'
@
events
=
{}
@
events
[
"click .component-editor[data-id=
#{
id
}
] .cancel-button"
]
=
'clickCancelButton
'
@
events
[
"click .component-editor[data-id=
#{
id
}
] .save-button"
]
=
'clickSaveButton
'
@
events
[
"click .component-actions[data-id=
#{
id
}
] .edit-button"
]
=
'clickEditButton
'
@
delegateEvents
(
events
)
@
delegateEvents
()
metadata
:
->
# cdodge: package up metadata which is separated into a number of input fields
# there's probably a better way to do this, but at least this lets me continue to move onwards
_metadata
=
{}
if
@
$metadata
$metadata
=
@
$component_editor
().
find
(
'.metadata_edit'
)
if
$metadata
# walk through the set of elments which have the 'xmetadata_name' attribute and
# build up a object to pass back to the server on the subsequent POST
_metadata
[
$
(
el
).
data
(
"metadata-name"
)]
=
el
.
value
for
el
in
$
(
'[data-metadata-name]'
,
@
$metadata
)
_metadata
[
$
(
el
).
data
(
"metadata-name"
)]
=
el
.
value
for
el
in
$
(
'[data-metadata-name]'
,
$metadata
)
_metadata
save
:
(
event
)
=>
event
.
preventDefault
()
@
model
.
save
(
metadata
:
@
metadata
()
).
done
((
preview
)
=>
save
:
(
data
)
=>
@
model
.
set
(
data
)
@
model
.
save
().
done
((
preview
)
=>
alert
(
"Your changes have been saved."
)
new_el
=
$
(
preview
)
@
$el
.
replaceWith
(
new_el
)
@
$el
=
new_el
@
delegate
()
@
model
.
module
=
XModule
.
loadModule
(
@
$el
)
$preview
=
$
(
preview
)
@
$el
.
replaceWith
(
$preview
)
@
setElement
(
$preview
)
@
module
.
constructor
(
@
$el
)
XModule
.
loadModules
(
@
$el
)
).
fail
(
->
alert
(
"There was an error saving your changes. Please try again."
)
)
cancel
:
(
event
)
->
clickSaveButton
:
(
event
)
=>
event
.
preventDefault
()
data
=
@
module
.
save
()
data
.
metadata
=
@
metadata
()
@
save
(
data
)
clickCancelButton
:
(
event
)
->
event
.
preventDefault
()
@
$el
.
removeClass
(
'editing'
)
@
$component_editor
.
slideUp
(
150
)
@
$component_editor
()
.
slideUp
(
150
)
edit
:
(
event
)
->
clickEditButton
:
(
event
)
->
event
.
preventDefault
()
@
$el
.
addClass
(
'editing'
)
@
$component_editor
.
slideDown
(
150
)
@
$component_editor
()
.
slideDown
(
150
)
cms/static/js/base.js
View file @
fd7223bd
...
...
@@ -14,16 +14,13 @@ $(document).ready(function() {
$newComponentStep2
=
$
(
'.new-component-step-2'
);
$newComponentButton
=
$
(
'.new-component-button'
);
$
(
document
).
bind
(
'XModule.loaded'
,
function
(
e
,
element
)
{
if
(
$
(
element
).
hasClass
(
'.xmodule_display'
))
{
return
}
$
(
document
).
bind
(
'XModule.loaded.edit'
,
function
(
e
,
element
,
module
)
{
var
previewType
=
$
(
element
).
data
(
'preview-type'
);
var
moduleType
=
$
(
element
).
data
(
'type'
);
new
CMS
.
Views
.
ModuleEdit
({
el
:
element
,
module
:
module
,
model
:
new
CMS
.
Models
.
Module
({
module
:
$
(
element
).
data
(
'module'
),
id
:
$
(
element
).
data
(
'id'
),
type
:
moduleType
==
'None'
?
null
:
moduleType
,
previewType
:
previewType
==
'None'
?
null
:
previewType
,
...
...
common/lib/xmodule/xmodule/js/src/discussion/display.coffee
View file @
fd7223bd
class
@
InlineDiscussion
class
@
InlineDiscussion
extends
XModule
.
Descriptor
constructor
:
(
element
)
->
@
el
=
$
(
element
).
find
(
'.discussion-module'
)
@
view
=
new
DiscussionModuleView
(
el
:
@
el
)
common/lib/xmodule/xmodule/js/src/raw/edit/json.coffee
View file @
fd7223bd
class
@
JSONEditingDescriptor
class
@
JSONEditingDescriptor
extends
XModule
.
Descriptor
constructor
:
(
@
element
)
->
@
edit_box
=
CodeMirror
.
fromTextArea
(
$
(
".edit-box"
,
@
element
)[
0
],
{
mode
:
{
name
:
"javascript"
,
json
:
true
}
})
save
:
->
JSON
.
parse
@
edit_box
.
getValue
()
save
:
->
data
:
JSON
.
parse
@
edit_box
.
getValue
()
common/lib/xmodule/xmodule/js/src/raw/edit/xml.coffee
View file @
fd7223bd
class
@
XMLEditingDescriptor
class
@
XMLEditingDescriptor
extends
XModule
.
Descriptor
constructor
:
(
@
element
)
->
@
edit_box
=
CodeMirror
.
fromTextArea
(
$
(
".edit-box"
,
@
element
)[
0
],
{
mode
:
"xml"
})
save
:
->
@
edit_box
.
getValue
()
save
:
->
data
:
@
edit_box
.
getValue
()
common/lib/xmodule/xmodule/js/src/sequence/edit.coffee
View file @
fd7223bd
class
@
SequenceDescriptor
class
@
SequenceDescriptor
extends
XModule
.
Descriptor
constructor
:
(
@
element
)
->
@
$tabs
=
$
(
@
element
).
find
(
"#sequence-list"
)
@
$tabs
.
sortable
()
common/lib/xmodule/xmodule/js/src/vertical/edit.coffee
View file @
fd7223bd
class
@
VerticalDescriptor
class
@
VerticalDescriptor
extends
XModule
.
Descriptor
constructor
:
(
@
element
)
->
@
$items
=
$
(
@
element
).
find
(
".vert-mod"
)
@
$items
.
sortable
()
common/lib/xmodule/xmodule/seq_module.py
View file @
fd7223bd
...
...
@@ -86,6 +86,7 @@ class SequenceModule(XModule):
'progress_status'
:
Progress
.
to_js_status_str
(
progress
),
'progress_detail'
:
Progress
.
to_js_detail_str
(
progress
),
'type'
:
child
.
get_icon_class
(),
'id'
:
child
.
id
,
}
if
childinfo
[
'title'
]
==
''
:
childinfo
[
'title'
]
=
child
.
metadata
.
get
(
'display_name'
,
''
)
...
...
common/static/coffee/src/xmodule.coffee
View file @
fd7223bd
...
...
@@ -10,8 +10,13 @@
return
try
$
(
element
).
data
(
'module'
,
new
window
[
moduleType
](
element
))
$
(
document
).
trigger
(
'XModule.loaded'
,
[
element
])
module
=
new
window
[
moduleType
](
element
)
if
$
(
element
).
hasClass
(
'xmodule_edit'
)
$
(
document
).
trigger
(
'XModule.loaded.edit'
,
[
element
,
module
])
if
$
(
element
).
hasClass
(
'xmodule_display'
)
$
(
document
).
trigger
(
'XModule.loaded.display'
,
[
element
,
module
])
catch
error
console
.
error
"Unable to load
#{
moduleType
}
:
#{
error
.
message
}
"
if
console
...
...
@@ -29,3 +34,40 @@
modules
=
$
(
selector
)
modules
.
each
(
idx
,
element
)
->
XModule
.
loadModule
element
class
@
XModule
.
Descriptor
callbacks
:
[]
###
Register a callback method to be called when the state of this
descriptor is updated. The callback will be passed the results
of calling the save method on this descriptor.
###
onUpdate
:
(
callback
)
->
@
callbacks
.
push
(
callback
)
###
Notify registered callbacks that the state of this descriptor has changed
###
update
:
=>
data
=
@
save
()
callback
(
data
)
for
callback
in
@
callbacks
###
Bind the module to an element. This may be called multiple times,
if the element content has changed and so the module needs to be rebound
@method: constructor
@param {html element} the .xmodule_edit section containing all of the descriptor content
###
constructor
:
(
@
element
)
->
return
###
Return the current state of the descriptor (to be written to the module store)
@method: save
@returns {object} An object containing children and data attributes (both optional).
The contents of the attributes will be saved to the server
###
save
:
->
return
{}
lms/templates/seq_module.html
View file @
fd7223bd
...
...
@@ -8,7 +8,9 @@
## implementation note: will need to figure out how to handle combining detail
## statuses of multiple modules in js.
<li>
<a
class=
"seq_${item['type']} inactive progress-${item['progress_status']}"
data-element=
"${idx+1}"
>
<a
class=
"seq_${item['type']} inactive progress-${item['progress_status']}"
data-id=
"${item['id']}"
data-element=
"${idx+1}"
>
<p>
${item['title']}
</p>
</a>
</li>
...
...
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