Rev4537, Add warning on invalid file save in UiFileManager
This commit is contained in:
parent
785d2351eb
commit
288050e5b4
3 changed files with 35 additions and 4 deletions
|
@ -127,6 +127,15 @@ class FileEditor extends Class
|
|||
return false
|
||||
|
||||
handleSaveClick: =>
|
||||
num_errors = (mark for mark in Page.file_editor.cm.getAllMarks() when mark.className == "CodeMirror-lint-mark-error").length
|
||||
if num_errors > 0
|
||||
Page.cmd "wrapperConfirm", ["<b>Warning:</b> The file looks invalid.", "Save anyway"], @save
|
||||
else
|
||||
@save()
|
||||
return false
|
||||
|
||||
save: =>
|
||||
Page.projector.scheduleRender()
|
||||
@is_saving = true
|
||||
Page.cmd "fileWrite", [@inner_path, Text.fileEncode(@cm.getValue())], (res) =>
|
||||
@is_saving = false
|
||||
|
@ -144,7 +153,6 @@ class FileEditor extends Class
|
|||
@mode = "Edit"
|
||||
Page.file_list.need_update = true
|
||||
Page.projector.scheduleRender()
|
||||
return false
|
||||
|
||||
render: ->
|
||||
if @need_update
|
||||
|
|
|
@ -1932,6 +1932,7 @@
|
|||
|
||||
function FileEditor(inner_path1) {
|
||||
this.inner_path = inner_path1;
|
||||
this.save = bind(this.save, this);
|
||||
this.handleSaveClick = bind(this.handleSaveClick, this);
|
||||
this.handleSidebarButtonClick = bind(this.handleSidebarButtonClick, this);
|
||||
this.foldJson = bind(this.foldJson, this);
|
||||
|
@ -2095,8 +2096,31 @@
|
|||
};
|
||||
|
||||
FileEditor.prototype.handleSaveClick = function() {
|
||||
var mark, num_errors;
|
||||
num_errors = ((function() {
|
||||
var i, len, ref, results;
|
||||
ref = Page.file_editor.cm.getAllMarks();
|
||||
results = [];
|
||||
for (i = 0, len = ref.length; i < len; i++) {
|
||||
mark = ref[i];
|
||||
if (mark.className === "CodeMirror-lint-mark-error") {
|
||||
results.push(mark);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
})()).length;
|
||||
if (num_errors > 0) {
|
||||
Page.cmd("wrapperConfirm", ["<b>Warning:</b> The file looks invalid.", "Save anyway"], this.save);
|
||||
} else {
|
||||
this.save();
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
FileEditor.prototype.save = function() {
|
||||
Page.projector.scheduleRender();
|
||||
this.is_saving = true;
|
||||
Page.cmd("fileWrite", [this.inner_path, Text.fileEncode(this.cm.getValue())], (function(_this) {
|
||||
return Page.cmd("fileWrite", [this.inner_path, Text.fileEncode(this.cm.getValue())], (function(_this) {
|
||||
return function(res) {
|
||||
_this.is_saving = false;
|
||||
if (res.error) {
|
||||
|
@ -2117,7 +2141,6 @@
|
|||
return Page.projector.scheduleRender();
|
||||
};
|
||||
})(this));
|
||||
return false;
|
||||
};
|
||||
|
||||
FileEditor.prototype.render = function() {
|
||||
|
|
|
@ -14,7 +14,7 @@ class Config(object):
|
|||
|
||||
def __init__(self, argv):
|
||||
self.version = "0.7.2"
|
||||
self.rev = 4536
|
||||
self.rev = 4537
|
||||
self.argv = argv
|
||||
self.action = None
|
||||
self.test_parser = None
|
||||
|
|
Loading…
Reference in a new issue