Disable new button and new action in filemanager when there's no writable right

This commit is contained in:
Hadi Nategh 2017-10-23 12:08:33 +02:00
parent b8f8a014fa
commit c88e3b8a69
3 changed files with 30 additions and 1 deletions

View File

@ -153,6 +153,8 @@ var et2_dropdown_button = (function(){ "use strict"; return et2_inputWidget.exte
.addClass("ui-widget ui-corner-right").removeClass("ui-corner-all")
.attr("type", "button")
.click(function() {
// ignore click on readonly button
if (self.options.readonly) return false;
// Clicking it again hides menu
if(self.menu.is(":visible"))
{
@ -277,6 +279,9 @@ var et2_dropdown_button = (function(){ "use strict"; return et2_inputWidget.exte
* @returns {Boolean}
*/
click: function(_ev) {
// ignore click on readonly button
if (this.options.readonly) return false;
this.clicked = true;
if (!this._super.apply(this, arguments))
@ -389,6 +394,28 @@ var et2_dropdown_button = (function(){ "use strict"; return et2_inputWidget.exte
getValue: function() {
return this.value;
},
/**
* Set options.readonly
*
* @param {boolean} _ro
*/
set_readonly: function(_ro)
{
if (_ro != this.options.readonly)
{
this.options.readonly = _ro;
// don't make readonly dropdown buttons clickable
if (this.buttons)
{
this.buttons.find('button')
.toggleClass('et2_clickable', !_ro)
.toggleClass('et2_button_ro', _ro)
.css('cursor', _ro ? 'default' : 'pointer');
}
}
}
});}).call(this);
et2_register_widget(et2_dropdown_button, ["dropdown_button"]);

View File

@ -152,6 +152,7 @@ class filemanager_ui
'new' => array(
'caption' => 'New',
'group' => $group,
'disableClass' => 'noEdit',
'children' => array (
'document' => array (
'caption' => 'Document',
@ -165,6 +166,7 @@ class filemanager_ui
'icon' => 'filemanager/button_createdir',
'group' => $group,
'allowOnMultiple' => false,
'disableClass' => 'noEdit',
'onExecute' => 'javaScript:app.filemanager.createdir'
),
'edit' => array(

View File

@ -1034,7 +1034,7 @@ app.classes.filemanager = AppJS.extend(
if (_path == path)
{
var ids = ['button[linkpaste]', 'button[paste]', 'button[createdir]', 'button[symlink]', 'upload'];
var ids = ['button[linkpaste]', 'button[paste]', 'button[createdir]', 'button[symlink]', 'upload', 'new'];
for(var i=0; i < ids.length; ++i)
{
var widget = etemplate2.getById(id).widgetContainer.getWidgetById(ids[i]);