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
81c4e170
Commit
81c4e170
authored
Dec 12, 2016
by
Andy Armstrong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert to showing all posts upon adding a post
parent
7287e8ef
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
13 deletions
+41
-13
common/static/common/js/discussion/views/discussion_inline_view.js
+6
-1
common/static/common/js/discussion/views/new_post_view.js
+11
-11
common/static/common/js/spec/discussion/view/discussion_inline_view_spec.js
+24
-1
No files found.
common/static/common/js/discussion/views/discussion_inline_view.js
View file @
81c4e170
...
...
@@ -121,7 +121,7 @@
this
.
newPostView
.
render
();
this
.
listenTo
(
this
.
newPostView
,
'newPost:createPost'
,
this
.
hideNewPost
);
this
.
listenTo
(
this
.
newPostView
,
'newPost:createPost'
,
this
.
onNewPostCreated
);
this
.
listenTo
(
this
.
newPostView
,
'newPost:cancel'
,
this
.
hideNewPost
);
this
.
discussion
.
on
(
'add'
,
this
.
addThread
);
...
...
@@ -214,6 +214,11 @@
this
.
showed
=
true
;
},
onNewPostCreated
:
function
()
{
this
.
navigateToAllPosts
();
this
.
hideNewPost
();
},
hideNewPost
:
function
()
{
this
.
$
(
'section.discussion'
).
find
(
'.inline-discussion-thread-container'
).
removeClass
(
'is-hidden'
);
this
.
$
(
'section.discussion'
).
find
(
'.add_post_btn_container'
)
...
...
common/static/common/js/discussion/views/new_post_view.js
View file @
81c4e170
/* globals DiscussionTopicMenuView, DiscussionUtil, Thread */
/* globals
_, Backbone,
DiscussionTopicMenuView, DiscussionUtil, Thread */
(
function
()
{
'use strict'
;
var
__hasProp
=
{}.
hasOwnProperty
,
...
...
@@ -81,14 +81,14 @@
};
NewPostView
.
prototype
.
getCohortOptions
=
function
()
{
var
user
_cohort_i
d
;
var
user
CohortI
d
;
if
(
this
.
course_settings
.
get
(
'is_cohorted'
)
&&
DiscussionUtil
.
isPrivilegedUser
())
{
user
_cohort_i
d
=
$
(
'#discussion-container'
).
data
(
'user-cohort-id'
);
user
CohortI
d
=
$
(
'#discussion-container'
).
data
(
'user-cohort-id'
);
return
_
.
map
(
this
.
course_settings
.
get
(
'cohorts'
),
function
(
cohort
)
{
return
{
value
:
cohort
.
id
,
text
:
cohort
.
name
,
selected
:
cohort
.
id
===
user
_cohort_i
d
selected
:
cohort
.
id
===
user
CohortI
d
};
});
}
else
{
...
...
@@ -126,15 +126,15 @@
};
NewPostView
.
prototype
.
createPost
=
function
(
event
)
{
var
anonymous
,
anonymous
_to_peers
,
body
,
follow
,
group
,
thread_t
ype
,
title
,
topicId
,
url
,
var
anonymous
,
anonymous
ToPeers
,
body
,
follow
,
group
,
threadT
ype
,
title
,
topicId
,
url
,
self
=
this
;
event
.
preventDefault
();
thread
_t
ype
=
this
.
$
(
'.post-type-input:checked'
).
val
();
thread
T
ype
=
this
.
$
(
'.post-type-input:checked'
).
val
();
title
=
this
.
$
(
'.js-post-title'
).
val
();
body
=
this
.
$
(
'.js-post-body'
).
find
(
'.wmd-input'
).
val
();
group
=
this
.
$
(
'.js-group-select option:selected'
).
attr
(
'value'
);
anonymous
=
false
||
this
.
$
(
'.js-anon'
).
is
(
':checked'
);
anonymous
_to_p
eers
=
false
||
this
.
$
(
'.js-anon-peers'
).
is
(
':checked'
);
anonymous
ToP
eers
=
false
||
this
.
$
(
'.js-anon-peers'
).
is
(
':checked'
);
follow
=
false
||
this
.
$
(
'.js-follow'
).
is
(
':checked'
);
topicId
=
this
.
isTabMode
()
?
this
.
topicView
.
getCurrentTopicId
()
:
this
.
topicId
;
url
=
DiscussionUtil
.
urlFor
(
'create_thread'
,
topicId
);
...
...
@@ -145,11 +145,11 @@
type
:
'POST'
,
dataType
:
'json'
,
data
:
{
thread_type
:
thread
_t
ype
,
thread_type
:
thread
T
ype
,
title
:
title
,
body
:
body
,
anonymous
:
anonymous
,
anonymous_to_peers
:
anonymous
_to_p
eers
,
anonymous_to_peers
:
anonymous
ToP
eers
,
auto_subscribe
:
follow
,
group_id
:
group
},
...
...
@@ -179,7 +179,7 @@
}
}
this
.
trigger
(
'newPost:cancel'
);
return
this
.
resetForm
();
this
.
resetForm
();
};
NewPostView
.
prototype
.
resetForm
=
function
()
{
...
...
@@ -187,7 +187,7 @@
DiscussionUtil
.
clearFormErrors
(
this
.
$
(
'.post-errors'
));
this
.
$
(
'.wmd-preview p'
).
html
(
''
);
if
(
this
.
isTabMode
())
{
return
this
.
topicView
.
setTopic
(
this
.
$
(
'button.topic-title'
).
first
());
this
.
topicView
.
setTopic
(
this
.
$
(
'button.topic-title'
).
first
());
}
};
...
...
common/static/common/js/spec/discussion/view/discussion_inline_view_spec.js
View file @
81c4e170
...
...
@@ -120,13 +120,36 @@
expect
(
testView
.
$
(
'.new-post-article'
)).
toHaveClass
(
'is-hidden'
);
});
it
(
'should be hidden when the "
c
lose" button is clicked'
,
function
()
{
it
(
'should be hidden when the "
C
lose" button is clicked'
,
function
()
{
var
testView
=
createTestView
(
this
);
showDiscussion
(
this
,
testView
);
testView
.
$
(
'.new-post-btn'
).
click
();
testView
.
$
(
'.forum-new-post-form .add-post-cancel'
).
click
();
expect
(
testView
.
$
(
'.new-post-article'
)).
toHaveClass
(
'is-hidden'
);
});
it
(
'should return to the thread listing after adding a post'
,
function
()
{
var
testView
=
createTestView
(
this
);
showDiscussion
(
this
,
testView
);
// Navigate to an individual thread
testView
.
$
(
'.forum-nav-thread-link'
).
click
();
// Click "Add a Post", fill in the form, and submit it
testView
.
$
(
'.new-post-btn'
).
click
();
testView
.
$
(
'.js-post-title'
).
text
(
'Test title'
);
testView
.
$
(
'.wmd-input'
).
text
(
'Test body'
);
setNextAjaxResult
(
this
,
{
hello
:
'world'
});
testView
.
$
(
'.forum-new-post-form .submit'
).
click
();
// Verify that the list of threads is shown
expect
(
testView
.
$
(
'.inline-threads'
)).
not
.
toHaveClass
(
'is-hidden'
);
// Verify that the individual thread is no longer shown
expect
(
testView
.
$
(
'.group-visibility-label'
).
length
).
toBe
(
0
);
});
});
describe
(
'thread listing'
,
function
()
{
...
...
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