From c88e3b8a691384afb42926316871616a37909d90 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Mon, 23 Oct 2017 12:08:33 +0200 Subject: [PATCH] Disable new button and new action in filemanager when there's no writable right --- .../etemplate/et2_widget_dropdown_button.js | 27 +++++++++++++++++++ filemanager/inc/class.filemanager_ui.inc.php | 2 ++ filemanager/js/app.js | 2 +- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/api/js/etemplate/et2_widget_dropdown_button.js b/api/js/etemplate/et2_widget_dropdown_button.js index fee3be2585..e6d7f32d24 100644 --- a/api/js/etemplate/et2_widget_dropdown_button.js +++ b/api/js/etemplate/et2_widget_dropdown_button.js @@ -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"]); diff --git a/filemanager/inc/class.filemanager_ui.inc.php b/filemanager/inc/class.filemanager_ui.inc.php index 265620a6cd..eac6305358 100644 --- a/filemanager/inc/class.filemanager_ui.inc.php +++ b/filemanager/inc/class.filemanager_ui.inc.php @@ -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( diff --git a/filemanager/js/app.js b/filemanager/js/app.js index 23a9e69d3c..6ee3b6bf08 100644 --- a/filemanager/js/app.js +++ b/filemanager/js/app.js @@ -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]);