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
ac732f6b
Commit
ac732f6b
authored
Feb 08, 2013
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Beginnings of feedback regarding unsaved and saved changes.
parent
09e86280
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
2 deletions
+30
-2
cms/static/js/views/settings/advanced_view.js
+29
-1
cms/templates/settings.html
+1
-1
No files found.
cms/static/js/views/settings/advanced_view.js
View file @
ac732f6b
...
@@ -3,6 +3,9 @@ if (!CMS.Views['Settings']) CMS.Views.Settings = {};
...
@@ -3,6 +3,9 @@ if (!CMS.Views['Settings']) CMS.Views.Settings = {};
CMS
.
Views
.
Settings
.
Advanced
=
CMS
.
Views
.
ValidatingView
.
extend
({
CMS
.
Views
.
Settings
.
Advanced
=
CMS
.
Views
.
ValidatingView
.
extend
({
// the key for a newly added policy-- before the user has entered a key value
// the key for a newly added policy-- before the user has entered a key value
new_key
:
"__new_advanced_key__"
,
new_key
:
"__new_advanced_key__"
,
error_saving
:
"error_saving"
,
unsaved_changes
:
"unsaved_changes"
,
successful_changes
:
"successful_changes"
,
// Model class is CMS.Models.Settings.Advanced
// Model class is CMS.Models.Settings.Advanced
events
:
{
events
:
{
...
@@ -46,6 +49,7 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
...
@@ -46,6 +49,7 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
});
});
var
policyValueDivs
=
listEle$
.
find
(
'.ace'
);
var
policyValueDivs
=
listEle$
.
find
(
'.ace'
);
_
.
each
(
policyValueDivs
,
this
.
attachAce
,
this
);
_
.
each
(
policyValueDivs
,
this
.
attachAce
,
this
);
this
.
showMessage
();
return
this
;
return
this
;
},
},
attachAce
:
function
(
div
)
{
attachAce
:
function
(
div
)
{
...
@@ -60,6 +64,7 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
...
@@ -60,6 +64,7 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
var
quotedValue
=
editor
.
getValue
();
var
quotedValue
=
editor
.
getValue
();
var
JSONValue
=
JSON
.
parse
(
quotedValue
);
var
JSONValue
=
JSON
.
parse
(
quotedValue
);
self
.
model
.
set
(
key
,
JSONValue
,
{
validate
:
true
});
self
.
model
.
set
(
key
,
JSONValue
,
{
validate
:
true
});
self
.
showMessage
(
self
.
unsaved_changes
);
});
});
// Calling getSession() directly in render causes a crash on Chrome.
// Calling getSession() directly in render causes a crash on Chrome.
...
@@ -67,6 +72,26 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
...
@@ -67,6 +72,26 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
editor
.
getSession
().
setMode
(
"ace/mode/json"
);
editor
.
getSession
().
setMode
(
"ace/mode/json"
);
},
},
showMessage
:
function
(
type
)
{
this
.
$el
.
find
(
".message-status"
).
removeClass
(
"is-shown"
);
// var saveButton = this.$el.find(".save-button").addClass('disabled');
// var cancelButton = this.$el.find(".cancel-button").addClass('disabled');
if
(
type
)
{
if
(
type
===
this
.
error_saving
)
{
this
.
$el
.
find
(
".message-status.error"
).
addClass
(
"is-shown"
);
// saveButton.removeClass("disabled");
// cancelButton.removeClass("disabled");
}
else
if
(
type
===
this
.
unsaved_changes
)
{
this
.
$el
.
find
(
".message-status.warning"
).
addClass
(
"is-shown"
);
// saveButton.removeClass("disabled");
// cancelButton.removeClass("disabled");
}
else
if
(
type
===
this
.
successful_changes
)
this
.
$el
.
find
(
".message-status.confirm"
).
addClass
(
"is-shown"
);
}
},
deleteEntry
:
function
(
event
)
{
deleteEntry
:
function
(
event
)
{
event
.
preventDefault
();
event
.
preventDefault
();
// find out which entry
// find out which entry
...
@@ -80,6 +105,7 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
...
@@ -80,6 +105,7 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
this
.
model
.
unset
(
key
);
this
.
model
.
unset
(
key
);
}
}
li$
.
remove
();
li$
.
remove
();
this
.
showMessage
(
this
.
unsaved_changes
);
},
},
saveView
:
function
(
event
)
{
saveView
:
function
(
event
)
{
// TODO one last verification scan:
// TODO one last verification scan:
...
@@ -90,7 +116,7 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
...
@@ -90,7 +116,7 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
{
{
success
:
function
()
{
success
:
function
()
{
self
.
render
();
self
.
render
();
window
.
alert
(
"Saved"
);
self
.
showMessage
(
self
.
successful_changes
);
},
},
error
:
CMS
.
ServerError
error
:
CMS
.
ServerError
});
});
...
@@ -115,6 +141,7 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
...
@@ -115,6 +141,7 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
var
policyValueDivs
=
this
.
$el
.
find
(
'#'
+
this
.
new_key
).
closest
(
'li'
).
find
(
'.ace'
);
var
policyValueDivs
=
this
.
$el
.
find
(
'#'
+
this
.
new_key
).
closest
(
'li'
).
find
(
'.ace'
);
// only 1 but hey, let's take advantage of the context mechanism
// only 1 but hey, let's take advantage of the context mechanism
_
.
each
(
policyValueDivs
,
this
.
attachAce
,
this
);
_
.
each
(
policyValueDivs
,
this
.
attachAce
,
this
);
this
.
showMessage
(
this
.
unsaved_changes
);
},
},
updateKey
:
function
(
event
)
{
updateKey
:
function
(
event
)
{
// old key: either the key as in the model or new_key.
// old key: either the key as in the model or new_key.
...
@@ -181,6 +208,7 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
...
@@ -181,6 +208,7 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
_
.
each
(
policyValueDivs
,
this
.
attachAce
,
this
);
_
.
each
(
policyValueDivs
,
this
.
attachAce
,
this
);
this
.
fieldToSelectorMap
[
newKey
]
=
newKey
;
this
.
fieldToSelectorMap
[
newKey
]
=
newKey
;
this
.
showMessage
(
this
.
unsaved_changes
);
}
}
},
},
validateKey
:
function
(
oldKey
,
newKey
)
{
validateKey
:
function
(
oldKey
,
newKey
)
{
...
...
cms/templates/settings.html
View file @
ac732f6b
...
@@ -745,7 +745,7 @@ from contentstore import utils
...
@@ -745,7 +745,7 @@ from contentstore import utils
</div>
</div>
<div
class=
"message message-status warning is-shown"
>
<div
class=
"message message-status warning is-shown"
>
Your changes w
ere saved, but they may affect settings elsewhere
Your changes w
ill not take effect until you press "Save" on the bottom of the page.
</div>
</div>
<section
class=
"settings-advanced-policies"
>
<section
class=
"settings-advanced-policies"
>
...
...
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