mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-22548, hide main file element completely
This commit is contained in:
parent
1daea7fa49
commit
ac9c14dd29
4 changed files with 23 additions and 13 deletions
|
@ -55,7 +55,14 @@ M.form_filemanager.init = function(Y, options) {
|
|||
initializer: function(options) {
|
||||
this.options = options;
|
||||
if (options.mainfile) {
|
||||
this.mainfile = options.mainfile;
|
||||
this.enablemainfile = options.mainfile;
|
||||
var mainid = '#id_'+this.enablemainfile;
|
||||
var filename = Y.one(mainid).get('value');
|
||||
this.mainfilename = '';
|
||||
if (filename) {
|
||||
var parts = filename.split('/');
|
||||
this.mainfilename = parts[parts.length-1];
|
||||
}
|
||||
}
|
||||
this.client_id = options.client_id;
|
||||
this.currentpath = '/';
|
||||
|
@ -259,7 +266,7 @@ M.form_filemanager.init = function(Y, options) {
|
|||
}, this);
|
||||
},
|
||||
empty_filelist: function(container) {
|
||||
container.set('innerHTML', '<div class="mdl-align">'+M.str.repository.emptylist+'</div>');
|
||||
container.set('innerHTML', '<div class="mdl-align">'+M.str.repository.nofilesattached+'</div>');
|
||||
},
|
||||
render: function() {
|
||||
var options = this.options;
|
||||
|
@ -363,8 +370,6 @@ M.form_filemanager.init = function(Y, options) {
|
|||
list[i].action = action;
|
||||
|
||||
var url = "###";
|
||||
// check main file
|
||||
var ismainfile = false;
|
||||
|
||||
switch (list[i].type) {
|
||||
case 'folder':
|
||||
|
@ -392,7 +397,11 @@ M.form_filemanager.init = function(Y, options) {
|
|||
}
|
||||
var fullname = list[i].fullname;
|
||||
|
||||
html = html.replace('___fullname___', '<a href="'+url+'" id="'+fileid+'"><img src="'+list[i].icon+'" /> ' + fullname + '</a>');
|
||||
if (this.mainfilename == fullname) {
|
||||
html = html.replace('___fullname___', '<strong><a href="'+url+'" id="'+fileid+'"><img src="'+list[i].icon+'" /> ' + fullname + '</a></strong>');
|
||||
} else {
|
||||
html = html.replace('___fullname___', '<a href="'+url+'" id="'+fileid+'"><img src="'+list[i].icon+'" /> ' + fullname + '</a>');
|
||||
}
|
||||
html = html.replace('___action___', '<span class="fm-menuicon" id="'+action+'"><img alt="▶" src="'+M.util.image_url('i/menu')+'" /></span>');
|
||||
html = '<li id="'+htmlid+'">'+html+'</li>';
|
||||
listhtml += html;
|
||||
|
@ -436,16 +445,19 @@ M.form_filemanager.init = function(Y, options) {
|
|||
var options = this.options;
|
||||
var node = e.currentTarget;
|
||||
var file = data[node.get('id')];
|
||||
var scope = this;
|
||||
|
||||
var menuitems = [
|
||||
{text: M.str.moodle.download, url:file.url}
|
||||
];
|
||||
function setmainfile(type, ev, obj) {
|
||||
var file = obj[node.get('id')];
|
||||
this.mainfilename = file.filename;
|
||||
Y.one(mainid).set('value', file.filepath+file.filename);
|
||||
scope.refresh(scope.currentpath);
|
||||
}
|
||||
if (this.mainfile) {
|
||||
var mainid = '#id_'+this.mainfile;
|
||||
if (this.enablemainfile && (file.filename != this.mainfilename)) {
|
||||
var mainid = '#id_'+this.enablemainfile;
|
||||
var menu = {text: M.str.repository.setmainfile, onclick:{fn: setmainfile, obj:data, scope:this}};
|
||||
menuitems.push(menu);
|
||||
}
|
||||
|
|
|
@ -1722,7 +1722,6 @@ class core_renderer extends renderer_base {
|
|||
|
||||
return html_writer::tag('a', $output, $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the file picker
|
||||
*
|
||||
|
@ -1876,7 +1875,7 @@ FMHTML;
|
|||
'strings' => array(array('loading', 'repository'), array('nomorefiles', 'repository'), array('confirmdeletefile', 'repository'),
|
||||
array('add', 'repository'), array('accessiblefilepicker', 'repository'), array('move', 'moodle'),
|
||||
array('cancel', 'moodle'), array('download', 'moodle'), array('ok', 'moodle'),
|
||||
array('emptylist', 'repository'), array('entername', 'repository'), array('enternewname', 'repository'),
|
||||
array('emptylist', 'repository'), array('nofilesattached', 'repository'), array('entername', 'repository'), array('enternewname', 'repository'),
|
||||
array('zip', 'editor'), array('unzip', 'moodle'), array('rename', 'moodle'), array('delete', 'moodle'),
|
||||
array('cannotdeletefile', 'error'), array('confirmdeletefile', 'repository'),
|
||||
array('nopathselected', 'repository'), array('popupblockeddownload', 'repository'),
|
||||
|
|
|
@ -71,3 +71,4 @@ $string['resourceadministration'] = 'Resource administration';
|
|||
$string['resourcecontent'] = 'Files and subfolders';
|
||||
$string['resource:exportresource'] = 'Export resource';
|
||||
$string['resource:view'] = 'View resource';
|
||||
$string['selectmainfile'] = 'Please select the main file by clicking the icon next to file name.';
|
||||
|
|
|
@ -72,8 +72,7 @@ class mod_resource_mod_form extends moodleform_mod {
|
|||
|
||||
$mform->addElement('filemanager', 'files', get_string('selectfiles'), null, $filemanager_options);
|
||||
|
||||
//TODO: ohlala, it should be hidden when JS file manager loaded, the main file should be somehow highlighted directly in editor
|
||||
$mform->addElement('text', 'mainfile', get_string('areamainfile', 'repository'));
|
||||
$mform->addElement('hidden', 'mainfile', get_string('areamainfile', 'repository'), array('id'=>'id_mainfile'));
|
||||
$mform->setType('mainfile', PARAM_PATH);
|
||||
|
||||
//-------------------------------------------------------
|
||||
|
@ -211,9 +210,8 @@ class mod_resource_mod_form extends moodleform_mod {
|
|||
$filepaths[] = $file->get_filepath().$file->get_filename();
|
||||
}
|
||||
if (!in_array($data['mainfile'], $filepaths)) {
|
||||
$errors['mainfile'] = 'Please type correct main file path'; //TODO: will not be needed, do NOT localize!
|
||||
$errors['files'] = get_string('selectmainfile', 'resource');
|
||||
}
|
||||
return $errors;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue