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
de303755
Commit
de303755
authored
Oct 10, 2012
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add basic section/subsection CRUD on the overview page
parent
6079c571
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
155 additions
and
14 deletions
+155
-14
cms/djangoapps/contentstore/views.py
+3
-0
cms/static/js/base.js
+108
-8
cms/templates/base.html
+2
-0
cms/templates/overview.html
+42
-6
No files found.
cms/djangoapps/contentstore/views.py
View file @
de303755
...
...
@@ -141,6 +141,9 @@ def course_index(request, org, course, name):
return
render_to_response
(
'overview.html'
,
{
'sections'
:
sections
,
'parent_location'
:
course
.
location
,
'new_section_template'
:
Location
(
'i4x'
,
'edx'
,
'templates'
,
'sequential'
,
'Empty'
),
'new_subsection_template'
:
Location
(
'i4x'
,
'edx'
,
'templates'
,
'sequential'
,
'Empty'
),
# for now they are the same, but the could be different at some point...
'upload_asset_callback_url'
:
upload_asset_callback_url
,
'create_new_unit_template'
:
Location
(
'i4x'
,
'edx'
,
'templates'
,
'vertical'
,
'Empty'
)
})
...
...
cms/static/js/base.js
View file @
de303755
...
...
@@ -36,6 +36,14 @@ $(document).ready(function() {
$
(
'.set-date'
).
bind
(
'click'
,
showDateSetter
);
$
(
'.remove-date'
).
bind
(
'click'
,
removeDateSetter
);
// add new/delete section
$
(
'.new-courseware-section-button'
).
bind
(
'click'
,
addNewSection
);
$
(
'.delete-section-button'
).
bind
(
'click'
,
deleteSection
);
// add new/delete subsection
$
(
'.new-subsection-item'
).
bind
(
'click'
,
addNewSubsection
);
$
(
'.delete-subsection-button'
).
bind
(
'click'
,
deleteSubsection
);
});
// This method only changes the ordering of the child objects in a subsection
...
...
@@ -120,6 +128,7 @@ function saveSubsection(e) {
});
}
function
createNewUnit
(
e
)
{
e
.
preventDefault
();
...
...
@@ -139,18 +148,30 @@ function createNewUnit(e) {
function
deleteUnit
(
e
)
{
e
.
preventDefault
();
_deleteItem
(
$
(
this
).
parents
(
'li.leaf'
));
}
function
deleteSubsection
(
e
)
{
e
.
preventDefault
();
_deleteItem
(
$
(
this
).
parents
(
'li.branch'
));
}
if
(
!
confirm
(
'Are you sure you wish to delete this item. It cannot be reversed!'
))
return
;
function
deleteSection
(
e
)
{
e
.
preventDefault
();
_deleteItem
(
$
(
this
).
parents
(
'section.branch'
));
}
var
_li_el
=
$
(
this
).
parents
(
'li.leaf'
);
var
id
=
_li_el
.
data
(
'id'
);
function
_deleteItem
(
$el
)
{
if
(
!
confirm
(
'Are you sure you wish to delete this item. It cannot be reversed!'
))
return
;
var
id
=
$el
.
data
(
'id'
);
$
.
post
(
'/delete_item'
,
{
'id'
:
id
,
'delete_children'
:
true
},
function
(
data
)
{
_li_
el
.
remove
();
});
{
'id'
:
id
,
'delete_children'
:
true
},
function
(
data
)
{
$
el
.
remove
();
});
}
function
showUploadModal
(
e
)
{
...
...
@@ -282,3 +303,82 @@ function hideToastMessage(e) {
e
.
preventDefault
();
$
(
this
).
closest
(
'.toast-notification'
).
remove
();
}
function
addNewSection
(
e
)
{
e
.
preventDefault
();
var
$newSection
=
$
(
$
(
'#new-section-template'
).
html
());
$
(
'.new-courseware-section-button'
).
after
(
$newSection
);
$newSection
.
find
(
'.new-section-name'
).
focus
().
select
();
$newSection
.
find
(
'.new-section-name-save'
).
bind
(
'click'
,
saveNewSection
);
$newSection
.
find
(
'.new-section-name-cancel'
).
bind
(
'click'
,
cancelNewSection
);
}
function
saveNewSection
(
e
)
{
e
.
preventDefault
();
parent
=
$
(
this
).
data
(
'parent'
);
template
=
$
(
this
).
data
(
'template'
);
display_name
=
$
(
this
).
prev
(
'.new-section-name'
).
val
();
$
.
post
(
'/clone_item'
,
{
'parent_location'
:
parent
,
'template'
:
template
,
'display_name'
:
display_name
,
},
function
(
data
)
{
if
(
data
.
id
!=
undefined
)
location
.
reload
();
});
}
function
cancelNewSection
(
e
)
{
e
.
preventDefault
();
$
(
this
).
parents
(
'section.new-section'
).
remove
();
}
function
addNewSubsection
(
e
)
{
e
.
preventDefault
();
var
$section
=
$
(
this
).
closest
(
'.courseware-section'
);
var
$newSubsection
=
$
(
$
(
'#new-subsection-template'
).
html
());
$section
.
find
(
'.unit-list > ol'
).
append
(
$newSubsection
);
$section
.
find
(
'.new-subsection-name-input'
).
focus
().
select
();
var
$saveButton
=
$newSubsection
.
find
(
'.new-subsection-name-save'
);
$saveButton
.
bind
(
'click'
,
saveNewSubsection
);
parent
=
$
(
this
).
parents
(
"section.branch"
).
data
(
"id"
);
$saveButton
.
data
(
'parent'
,
parent
)
$saveButton
.
data
(
'template'
,
$
(
this
).
data
(
'template'
));
$newSubsection
.
find
(
'.new-subsection-name-cancel'
).
bind
(
'click'
,
cancelNewSubsection
);
}
function
saveNewSubsection
(
e
)
{
e
.
preventDefault
();
parent
=
$
(
this
).
data
(
'parent'
);
template
=
$
(
this
).
data
(
'template'
);
display_name
=
$
(
this
).
prev
(
'.subsection-name'
).
find
(
'.new-subsection-name-input'
).
val
()
$
.
post
(
'/clone_item'
,
{
'parent_location'
:
parent
,
'template'
:
template
,
'display_name'
:
display_name
,
},
function
(
data
)
{
if
(
data
.
id
!=
undefined
)
{
location
.
reload
();
}
});
}
function
cancelNewSubsection
(
e
)
{
e
.
preventDefault
();
$
(
this
).
parents
(
'li.branch'
).
remove
();
}
cms/templates/base.html
View file @
de303755
...
...
@@ -13,6 +13,8 @@
<meta
name=
"viewport"
content=
"width=device-width,initial-scale=1"
>
<meta
name=
"path_prefix"
content=
"${MITX_ROOT_URL}"
>
<
%
block
name=
"header_extras"
></
%
block>
</head>
<body
class=
"<%block name='bodyclass'></%block>"
>
...
...
cms/templates/overview.html
View file @
de303755
...
...
@@ -4,6 +4,42 @@
<
%
namespace
name=
"units"
file=
"widgets/units.html"
/>
<
%
block
name=
"header_extras"
>
<script
type=
"text/template"
id=
"new-section-template"
>
<
section
class
=
"courseware-section branch new-section"
>
<
header
>
<
a
href
=
"#"
class
=
"expand-collapse-icon collapse"
><
/a
>
<
div
class
=
"item-details"
>
<
h3
class
=
"section-name"
><
input
type
=
"text"
value
=
"New Section Name"
class
=
"new-section-name"
/><
a
href
=
"#"
class
=
"new-section-name-save"
data
-
parent
=
"${parent_location}"
data
-
template
=
"${new_section_template}"
>
Save
<
/a><a href="#" class="new-section-name-cancel">Cancel</
a
><
/h3
>
<
/div
>
<
/header
>
<
/section
>
</script>
<script
type=
"text/template"
id=
"new-subsection-template"
>
<
li
class
=
"branch collapsed"
>
<
div
class
=
"section-item editing"
>
<
div
>
<
span
class
=
"folder-icon"
><
/span
>
<
span
class
=
"subsection-name"
>
<
input
type
=
"text"
value
=
"New Subsection"
class
=
"new-subsection-name-input"
/>
<
/span
>
<
a
href
=
"#"
class
=
"new-subsection-name-save"
>
Save
<
/a
>
<
a
href
=
"#"
class
=
"new-subsection-name-cancel"
>
Cancel
<
/a
>
<
/div
>
<
/div
>
<
ol
>
<
li
>
<
a
href
=
"unit.html"
class
=
"new-unit-item"
>
<
span
class
=
"new-unit-icon"
><
/span>New Uni
t
<
/a
>
<
/li
>
<
/ol
>
<
/li
>
</script>
</
%
block>
<
%
block
name=
"content"
>
<div
class=
"main-wrapper"
>
...
...
@@ -13,9 +49,9 @@
<input
type=
"text"
class=
"courseware-unit-search-input search wip-box"
placeholder=
"search units"
/>
</div>
<article
class=
"courseware-overview"
>
<a
href=
"#"
class=
"new-courseware-section-button
wip-box
"
><span
class=
"plus-icon"
></span>
New Section
</a>
<a
href=
"#"
class=
"new-courseware-section-button"
><span
class=
"plus-icon"
></span>
New Section
</a>
% for section in sections:
<section
class=
"courseware-section branch"
>
<section
class=
"courseware-section branch"
data-id=
"${section.location}"
>
<header>
<a
href=
"#"
class=
"expand-collapse-icon collapse"
></a>
<div
class=
"item-details"
>
...
...
@@ -23,19 +59,19 @@
<h4><strong>
Unscheduled:
</strong>
<a
href=
"#"
>
click here to set
</a></h4>
</div>
<div
class=
"item-actions"
>
<a
href=
"#"
class=
"
edit-button wip
"
><span
class=
"delete-icon"
></span></a>
<a
href=
"#"
class=
"
delete-button delete-section-button
"
><span
class=
"delete-icon"
></span></a>
<a
href=
"#"
class=
"drag-handle wip"
></a>
</div>
</header>
<div
class=
"unit-list"
>
<div
class=
"list-header"
>
<a
href=
"#"
class=
"new-subsection-item
wip-box
"
>
<a
href=
"#"
class=
"new-subsection-item
"
data-template=
"${new_subsection_template}
"
>
<span
class=
"new-folder-icon"
></span>
New Subsection
</a>
</div>
<ol>
% for subsection in section.get_children():
<li
class=
"branch collapsed"
>
<li
class=
"branch collapsed"
data-id=
"${subsection.location}"
>
<div
class=
"section-item"
>
<div>
<a
href=
"#"
class=
"expand-collapse-icon expand"
></a>
...
...
@@ -45,7 +81,7 @@
</a>
</div>
<div
class=
"item-actions"
>
<a
href=
"#"
class=
"delete-button
wip
"
><span
class=
"delete-icon"
></span></a>
<a
href=
"#"
class=
"delete-button
delete-subsection-button
"
><span
class=
"delete-icon"
></span></a>
<a
href=
"#"
class=
"drag-handle wip"
></a>
</div>
</div>
...
...
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