Commit 51b75a4a authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review

Merge "Bug 1833034: Allow folder fail message be removed on success"

parents 52d950d4 e69b8a85
......@@ -40,6 +40,9 @@ var FileBrowser = (function($) {
if (self.config.edit || self.config.editmeta) {
self.edit_init();
}
$('#' + self.id + '_resizeonuploaduserenable').on('change', function (e) {
self.clear_create_folder_messages();
});
};
......@@ -88,6 +91,7 @@ var FileBrowser = (function($) {
}
});
}
$('#' + self.id + '_userfile').on('click', self.clear_create_folder_messages);
$('#' + self.id + '_userfile').off('change');
$('#' + self.id + '_userfile').on('change', self.upload_submit);
};
......@@ -99,6 +103,10 @@ var FileBrowser = (function($) {
return false;
};
this.clear_create_folder_messages = function() {
$('#' + self.id + '_createfolder_messages').empty();
};
this.upload_validate = function () {
if ($('#' + self.id + '_notice').length && !$('#' + self.id + '_notice').prop('checked')) {
$('#' + self.id+'_upload_messages').append($('<div>', {'class':'alert alert-danger', 'text':get_string('youmustagreetothecopyrightnotice')}));
......@@ -197,11 +205,15 @@ var FileBrowser = (function($) {
$('#' + self.id + '_createfolder_messages').empty().append(makeMessage(message, 'error'));
return false;
}
else {
$('#' + self.id + '_createfolder_messages').empty().append(makeMessage(get_string('createfoldersuccess', 'artefact.file'), 'ok'));
}
progressbarUpdate('folder');
};
this.edit_submit = function (e) {
var message;
self.clear_create_folder_messages();
var name = $('#' + self.id + '_edit_title');
if (!name.length) {
message = get_string('namefieldisrequired');
......@@ -253,6 +265,7 @@ var FileBrowser = (function($) {
this.hide_edit_form = function () {
var editrow = $('#' + self.id + '_edit_row');
this.clear_create_folder_messages();
if (!editrow.hasClass('d-none')) {
if ((typeof formchangemanager !== 'undefined') && !formchangemanager.confirmLeavingForm()) {
return false;
......@@ -277,10 +290,19 @@ var FileBrowser = (function($) {
// In IE, this.value is set to the button text
var id = $(this).prop('name').replace(/.*_edit\[(\d+)\]$/, '$1');
self.clear_create_folder_messages();
if (!self.hide_edit_form()) {
return;
}
$('[id^=' + self.id + '_edit_]').on('change', function (e) {
self.clear_create_folder_messages();
});
$('#' + self.id + '_rotator').on('change', function (e) {
self.clear_create_folder_messages();
});
$('#' + self.id + '_edit_heading').html(self.filedata[id].artefacttype == 'folder' ? get_string('editfolder') : get_string('editfile'));
var descriptionrow = $('#' + self.id + '_edit_description').closest('tr');
if (self.filedata[id].artefacttype == 'profileicon') {
......@@ -307,6 +329,7 @@ var FileBrowser = (function($) {
rotatorimg.css({'transform': 'rotate(' + (angle - origangle) + 'deg)', 'transition': 'all 1s ease'});
rotatorimg.data('angle', angle);
$('#' + self.id + '_edit_orientation').val(angle % 360);
self.clear_create_folder_messages();
});
}
else {
......@@ -382,6 +405,7 @@ var FileBrowser = (function($) {
$('#' + self.id + '_edit_row').addClass('d-none');
$(this).off();
$(this).on('click', self.edit_form);
self.clear_create_folder_messages();
}
$(this).trigger('resize.bs.modal');
return false;
......@@ -408,6 +432,7 @@ var FileBrowser = (function($) {
type: 'POST',
delay: 250,
data: function(params) {
self.clear_create_folder_messages();
return {
'q': params.term,
'page': params.page || 0,
......@@ -418,6 +443,7 @@ var FileBrowser = (function($) {
};
},
processResults: function(data, page) {
self.clear_create_folder_messages();
return {
results: data.results,
pagination: {
......@@ -486,6 +512,7 @@ var FileBrowser = (function($) {
if (warn != '') {
$(this).on('click', function (e) {
self.clear_create_folder_messages();
if (!confirm(warn)) {
e.preventDefault();
return false;
......@@ -505,6 +532,7 @@ var FileBrowser = (function($) {
return false;
});
$('#' + self.id + '_edit_artefact').on('click', self.edit_submit);
self.clear_create_folder_messages();
if (self.config.edit) {
......@@ -521,6 +549,7 @@ var FileBrowser = (function($) {
var href = $(this).prop('href');
$('#' + self.id + '_changeowner').val(1);
$('#' + self.id + '_owner').val(getUrlParameter('owner', href));
self.clear_create_folder_messages();
if (getUrlParameter('ownerid', href)) {
$('#' + self.id + '_ownerid').val(getUrlParameter('ownerid', href));
}
......@@ -542,6 +571,7 @@ var FileBrowser = (function($) {
if (self.config.edit) {
if ((typeof formchangemanager !== 'undefined') && !formchangemanager.confirmLeavingForm()) {
e.preventDefault();
self.clear_create_folder_messages();
return false;
}
}
......@@ -552,6 +582,7 @@ var FileBrowser = (function($) {
$('#' + self.id + '_ownerid').val(getUrlParameter('ownerid', href));
}
self.submitform();
self.clear_create_folder_messages();
$('#' + self.id + '_changefolder').val('');
e.preventDefault();
return false;
......@@ -685,6 +716,7 @@ var FileBrowser = (function($) {
});
}
$('#' + self.id + '_selectlist button.unselect').each(function () {
this.clear_create_folder_messages();
$(this).on('click', self.unselect);
});
};
......@@ -711,6 +743,7 @@ var FileBrowser = (function($) {
$(this).on('click', function(e) {
e.preventDefault();
self.clear_create_folder_messages();
var previewimg = $('#previewimg');
if (previewimg.length === 0) {
previewimg = $('<img id="previewimg" src="">');
......
......@@ -36,6 +36,7 @@ $string['copyrightnotice'] = 'Copyright notice';
$string['create'] = 'Create';
$string['Created'] = 'Created';
$string['createfolder'] = 'Create folder';
$string['createfoldersuccess'] = 'Folder added successfully';
$string['foldername'] = 'Folder name';
$string['confirmdeletefile'] = 'Are you sure you want to delete this file?';
$string['confirmdeletefolder'] = 'Are you sure you want to delete this folder?';
......
......@@ -192,6 +192,7 @@ class PluginArtefactFile extends PluginArtefact {
'confirmdeletefile',
'confirmdeletefolder',
'confirmdeletefolderandcontents',
'createfoldersuccess',
'defaultprofileicon',
'editfile',
'editfolder',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment