From 4696246b7b7ebfe7d02356f05468d47db65597ae Mon Sep 17 00:00:00 2001 From: nathangray Date: Thu, 4 May 2017 09:33:15 -0600 Subject: [PATCH] Fix readonly link-to widget was not read-only --- api/js/etemplate/et2_widget_link.js | 30 ++++++++++++++++++----------- api/js/etemplate/et2_widget_vfs.js | 18 +++++++++++++++++ 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/api/js/etemplate/et2_widget_link.js b/api/js/etemplate/et2_widget_link.js index 5f0f78d2ec..eaf540d3e3 100644 --- a/api/js/etemplate/et2_widget_link.js +++ b/api/js/etemplate/et2_widget_link.js @@ -174,14 +174,16 @@ var et2_link_to = (function(){ "use strict"; return et2_inputWidget.extend( application_list: this.options.application_list, blur: this.options.search_label ? this.options.search_label : this.egw().lang('Search...'), query: function() { self.link_button.hide(); return true;}, - select: function() {self.link_button.show(); return true;} + select: function() {self.link_button.show(); return true;}, + readonly: this.options.readonly }; this.link_entry = et2_createWidget("link-entry", link_entry_attrs,this); // Filemanager select var select_attrs = { button_label: egw.lang('Link'), - button_caption: '' + button_caption: '', + readonly: this.options.readonly }; // only set server-side callback, if we have a real application-id (not null or array) // otherwise it only gives an error on server-side @@ -190,6 +192,7 @@ var et2_link_to = (function(){ "use strict"; return et2_inputWidget.extend( select_attrs.method_id = self.options.value.to_app + ':' + self.options.value.to_id; } this.vfs_select = et2_createWidget("vfs-select", select_attrs,this); + this.vfs_select.set_readonly(this.options.readonly); jQuery(this.vfs_select.getDOMNode()).change( function() { var values = true; // If entry not yet saved, store for linking on server @@ -197,16 +200,19 @@ var et2_link_to = (function(){ "use strict"; return et2_inputWidget.extend( { values = self.options.value.to_id || {}; var files = self.vfs_select.getValue(); - for(var i = 0; i < files.length; i++) + if(typeof files !== 'undefined') { - values['link:'+files[i]] = { - app: 'link', - id: files[i], - type: 'unknown', - icon: 'link', - remark: '', - title: files[i] - }; + for(var i = 0; i < files.length; i++) + { + values['link:'+files[i]] = { + app: 'link', + id: files[i], + type: 'unknown', + icon: 'link', + remark: '', + title: files[i] + }; + } } } self._link_result(values); @@ -219,6 +225,7 @@ var et2_link_to = (function(){ "use strict"; return et2_inputWidget.extend( label: '', // Make the whole template a drop target drop_target: this.getInstanceManager().DOMContainer.getAttribute("id"), + readonly: this.options.readonly, // Change to this tab when they drop onStart: function(event, file_count) { @@ -252,6 +259,7 @@ var et2_link_to = (function(){ "use strict"; return et2_inputWidget.extend( }; this.file_upload = et2_createWidget("file", file_attrs,this); + this.file_upload.set_readonly(this.options.readonly); return true; }, diff --git a/api/js/etemplate/et2_widget_vfs.js b/api/js/etemplate/et2_widget_vfs.js index 73e87a2d0a..294e03b518 100644 --- a/api/js/etemplate/et2_widget_vfs.js +++ b/api/js/etemplate/et2_widget_vfs.js @@ -916,6 +916,11 @@ var et2_vfsSelect = (function(){ "use strict"; return et2_inputWidget.extend( .addClass("et2_button et2_vfs_btn") .css("background-image","url("+this.egw().image("filemanager/navbar")+")"); + if(this.options.readonly) + { + this.button.hide(); + } + if (this.options.button_caption != "") { this.button.text(this.options.button_caption); @@ -1025,6 +1030,19 @@ var et2_vfsSelect = (function(){ "use strict"; return et2_inputWidget.extend( this.options.method_id = id; }, + set_readonly: function(readonly) { + this.options.readonly = Boolean(readonly); + debugger; + if(this.options.readonly) + { + this.button.hide(); + } + else + { + this.button.show(); + } + }, + getValue: function() { return this.value; }