fixed sometimes preferences for app "eGroupware" are requested

This commit is contained in:
Ralf Becker 2014-02-11 12:17:08 +00:00
parent 6d17e87b0a
commit e7206aa071

View File

@ -24,9 +24,9 @@
/** /**
* UI widgets for Egroupware linking system * UI widgets for Egroupware linking system
* *
* @augments et2_inputWidget * @augments et2_inputWidget
*/ */
var et2_link_to = et2_inputWidget.extend( var et2_link_to = et2_inputWidget.extend(
{ {
attributes: { attributes: {
@ -63,7 +63,7 @@ var et2_link_to = et2_inputWidget.extend(
"link_label": { "link_label": {
"name": "Link label", "name": "Link label",
"type": "string", "type": "string",
"default": "Link", "default": "Link",
"description": "Label for the link button" "description": "Label for the link button"
}, },
"value": { "value": {
@ -77,7 +77,7 @@ var et2_link_to = et2_inputWidget.extend(
/** /**
* Constructor * Constructor
* *
* @memberOf et2_link_to * @memberOf et2_link_to
*/ */
init: function() { init: function() {
@ -132,7 +132,7 @@ var et2_link_to = et2_inputWidget.extend(
.text(this.egw().lang(this.options.link_label)) .text(this.egw().lang(this.options.link_label))
.appendTo(this.div).hide() .appendTo(this.div).hide()
.click(this, this.createLink); .click(this, this.createLink);
// Span for indicating status // Span for indicating status
this.status_span = $j(document.createElement("span")) this.status_span = $j(document.createElement("span"))
.appendTo(this.div).addClass("status").hide(); .appendTo(this.div).addClass("status").hide();
@ -154,7 +154,7 @@ var et2_link_to = et2_inputWidget.extend(
// Filemanager link popup // Filemanager link popup
this.filemanager_button = $j(document.createElement("div")).appendTo(this.div); this.filemanager_button = $j(document.createElement("div")).appendTo(this.div);
// Need a div for file upload widget // Need a div for file upload widget
this.file_div = $j(document.createElement("div")).appendTo(this.div); this.file_div = $j(document.createElement("div")).appendTo(this.div);
@ -170,7 +170,7 @@ var et2_link_to = et2_inputWidget.extend(
// Already done // Already done
return false; return false;
} }
// Link-to // Link-to
var link_entry_attrs = { var link_entry_attrs = {
id: this.id + '_link_entry', id: this.id + '_link_entry',
@ -210,15 +210,15 @@ var et2_link_to = et2_inputWidget.extend(
} }
self._link_result(values); self._link_result(values);
}); });
// File upload // File upload
var file_attrs = { var file_attrs = {
multiple: true, multiple: true,
id: this.id + '_file', id: this.id + '_file',
// Make the whole template a drop target // Make the whole template a drop target
drop_target: this.getInstanceManager().DOMContainer.getAttribute("id"), drop_target: this.getInstanceManager().DOMContainer.getAttribute("id"),
// Change to this tab when they drop // Change to this tab when they drop
onStart: function(event, file_count) { onStart: function(event, file_count) {
// Find the tab widget, if there is one // Find the tab widget, if there is one
@ -288,12 +288,12 @@ var et2_link_to = et2_inputWidget.extend(
} }
self.comment.val(self.comment.attr("placeholder")); self.comment.val(self.comment.attr("placeholder"));
} }
// Files // Files
if(!self.options.no_files) if(!self.options.no_files)
{ {
for(var file in self.file_upload.options.value) { for(var file in self.file_upload.options.value) {
links.push({ links.push({
app: 'file', app: 'file',
id: file, id: file,
@ -308,7 +308,7 @@ var et2_link_to = et2_inputWidget.extend(
{ {
return; return;
} }
var request = egw.json(self.egw().getAppName()+".etemplate_widget_link.ajax_link.etemplate", var request = egw.json(self.egw().getAppName()+".etemplate_widget_link.ajax_link.etemplate",
[values.to_app, values.to_id, links], [values.to_app, values.to_id, links],
self._link_result, self._link_result,
@ -382,7 +382,7 @@ var et2_link_to = et2_inputWidget.extend(
}, },
this, et2_link_list this, et2_link_list
); );
// If there's an array of data (entry is not yet saved), updating the list will // If there's an array of data (entry is not yet saved), updating the list will
// not work, so add them in explicitly. // not work, so add them in explicitly.
if(list_widget && success) if(list_widget && success)
@ -457,7 +457,7 @@ var et2_link_apps = et2_selectbox.extend(
/** /**
* Constructor * Constructor
* *
* @memberOf et2_link_apps * @memberOf et2_link_apps
*/ */
init: function() { init: function() {
@ -476,7 +476,7 @@ var et2_link_apps = et2_selectbox.extend(
}),this); }),this);
} }
}, },
/** /**
* We get some minor speedups by overriding parent searching and directly setting select options * We get some minor speedups by overriding parent searching and directly setting select options
*/ */
@ -543,7 +543,7 @@ var et2_link_entry = et2_inputWidget.extend(
/** /**
* Constructor * Constructor
* *
* @memberOf et2_link_entry * @memberOf et2_link_entry
*/ */
init: function() { init: function() {
@ -587,10 +587,10 @@ var et2_link_entry = et2_inputWidget.extend(
.change(function(e) { .change(function(e) {
// Clear cache when app changes // Clear cache when app changes
self.cache = {}; self.cache = {};
// Update preference with new value // Update preference with new value
egw.set_preference(self.options.value.to_app || window.egw_appName,'link_app',self.app_select.val()); egw.set_preference(self.options.value.to_app || window.egw_appName,'link_app',self.app_select.val());
if(typeof self.options.value != 'object') self.options.value = {}; if(typeof self.options.value != 'object') self.options.value = {};
self.options.value.app = self.app_select.val(); self.options.value.app = self.app_select.val();
}); });
@ -602,7 +602,7 @@ var et2_link_entry = et2_inputWidget.extend(
.text(this.options.select_options[key]); .text(this.options.select_options[key]);
option.appendTo(this.app_select); option.appendTo(this.app_select);
} }
if(this.options.only_app) if(this.options.only_app)
{ {
this.app_select.val(this.options.only_app); this.app_select.val(this.options.only_app);
this.app_select.hide(); this.app_select.hide();
@ -610,7 +610,7 @@ var et2_link_entry = et2_inputWidget.extend(
} }
// Search input // Search input
this.search = $j(document.createElement("input")) this.search = $j(document.createElement("input"))
// .attr("type", "search") // Fake it for all browsers below // .attr("type", "search") // Fake it for all browsers below
.focus(function(){if(!self.options.only_app) { .focus(function(){if(!self.options.only_app) {
// Adjust width, leave room for app select & link button // Adjust width, leave room for app select & link button
@ -619,7 +619,7 @@ var et2_link_entry = et2_inputWidget.extend(
.appendTo(this.div); .appendTo(this.div);
this.set_blur(this.options.blur ? this.options.blur : this.egw().lang("search"), this.search); this.set_blur(this.options.blur ? this.options.blur : this.egw().lang("search"), this.search);
// Autocomplete // Autocomplete
this.search.autocomplete({ this.search.autocomplete({
source: function(request, response) { return self.query(request, response);}, source: function(request, response) { return self.query(request, response);},
@ -630,8 +630,8 @@ var et2_link_entry = et2_inputWidget.extend(
self.select(event,item); self.select(event,item);
return false; return false;
}, },
focus: function(event, item) { focus: function(event, item) {
event.stopPropagation(); event.stopPropagation();
self.search.val(item.item.label); self.search.val(item.item.label);
return false; return false;
}, },
@ -639,7 +639,7 @@ var et2_link_entry = et2_inputWidget.extend(
disabled: self.options.disabled, disabled: self.options.disabled,
appendTo: self.div appendTo: self.div
}); });
// Custom display (colors) // Custom display (colors)
this.search.data("uiAutocomplete")._renderItem = function(ul, item) { this.search.data("uiAutocomplete")._renderItem = function(ul, item) {
var li = jQuery(document.createElement('li')) var li = jQuery(document.createElement('li'))
@ -755,12 +755,12 @@ var et2_link_entry = et2_inputWidget.extend(
doLoadingFinished: function() { doLoadingFinished: function() {
if(typeof this.options.value == 'object' && !this.options.value.app) if(typeof this.options.value == 'object' && !this.options.value.app)
{ {
this.options.value.app = egw.preference('link_app',this.options.value.to_app || window.egw_appName); this.options.value.app = egw.preference('link_app',this.options.value.to_app || this.egw().app_name());
this.app_select.val(this.options.value.app); this.app_select.val(this.options.value.app);
} }
return this._super.apply(this,arguments); return this._super.apply(this,arguments);
}, },
getValue: function() { getValue: function() {
var value = this.options.only_app ? this.options.value.id : this.options.value; var value = this.options.only_app ? this.options.value.id : this.options.value;
if(!this.options.only_app) if(!this.options.only_app)
@ -835,7 +835,7 @@ var et2_link_entry = et2_inputWidget.extend(
this.search.val(_value.title+""); this.search.val(_value.title+"");
} }
this.options.value = _value; this.options.value = _value;
jQuery("option[value='"+_value.app+"']",this.app_select).prop("selected",true); jQuery("option[value='"+_value.app+"']",this.app_select).prop("selected",true);
this.app_select.hide(); this.app_select.hide();
this.div.addClass("no_app"); this.div.addClass("no_app");
@ -863,7 +863,7 @@ var et2_link_entry = et2_inputWidget.extend(
this.search.removeAttr("placeholder"); this.search.removeAttr("placeholder");
} }
}, },
/** /**
* Ask server for entries matching selected app/type and filtered by search string * Ask server for entries matching selected app/type and filtered by search string
*/ */
@ -961,7 +961,7 @@ var et2_link_entry = et2_inputWidget.extend(
}); });
self.search.val(""); self.search.val("");
} }
// If a link array was passed in, don't make the ajax call // If a link array was passed in, don't make the ajax call
if(typeof _links == 'undefined') if(typeof _links == 'undefined')
{ {
@ -991,9 +991,9 @@ et2_register_widget(et2_link_entry, ["link-entry"]);
/** /**
* UI widget for a single (read-only) link * UI widget for a single (read-only) link
* *
* @augments et2_valueWidget * @augments et2_valueWidget
*/ */
var et2_link = et2_valueWidget.extend([et2_IDetachedDOM], var et2_link = et2_valueWidget.extend([et2_IDetachedDOM],
{ {
attributes: { attributes: {
@ -1012,10 +1012,10 @@ var et2_link = et2_valueWidget.extend([et2_IDetachedDOM],
} }
}, },
legacyOptions: ["only_app"], legacyOptions: ["only_app"],
/** /**
* Constructor * Constructor
* *
* @memberOf et2_link * @memberOf et2_link
*/ */
init: function() { init: function() {
@ -1035,11 +1035,11 @@ var et2_link = et2_valueWidget.extend([et2_IDetachedDOM],
this.link = null; this.link = null;
this._super.apply(this, arguments); this._super.apply(this, arguments);
}, },
set_label: function(label) { set_label: function(label) {
// Remove current label // Remove current label
this.label_span.contents() this.label_span.contents()
.filter(function(){ return this.nodeType == 3; }).remove(); .filter(function(){ return this.nodeType == 3; }).remove();
var parts = et2_csvSplit(label, 2, "%s"); var parts = et2_csvSplit(label, 2, "%s");
this.label_span.prepend(parts[0]); this.label_span.prepend(parts[0]);
this.label_span.append(parts[1]); this.label_span.append(parts[1]);
@ -1148,10 +1148,10 @@ et2_register_widget(et2_link, ["link", "link-entry_ro"]);
/** /**
* UI widget for one or more links, comma separated * UI widget for one or more links, comma separated
* *
* @augments et2_valueWidget * @augments et2_valueWidget
*/ */
var et2_link_string = et2_valueWidget.extend([et2_IDetachedDOM], var et2_link_string = et2_valueWidget.extend([et2_IDetachedDOM],
{ {
attributes: { attributes: {
"application": { "application": {
@ -1177,10 +1177,10 @@ var et2_link_string = et2_valueWidget.extend([et2_IDetachedDOM],
"description": "Sub-type key to list only entries of that type" "description": "Sub-type key to list only entries of that type"
} }
}, },
/** /**
* Constructor * Constructor
* *
* @memberOf et2_link_string * @memberOf et2_link_string
*/ */
init: function() { init: function() {
@ -1202,7 +1202,7 @@ var et2_link_string = et2_valueWidget.extend([et2_IDetachedDOM],
set_value: function(_value) { set_value: function(_value) {
// Get data // Get data
if(!_value || _value == null) if(!_value || _value == null)
{ {
this.list.empty(); this.list.empty();
return; return;
@ -1211,7 +1211,7 @@ var et2_link_string = et2_valueWidget.extend([et2_IDetachedDOM],
{ {
_value = _value.split(','); _value = _value.split(',');
} }
if(!_value.to_app && typeof _value == "object" && this.options.application) if(!_value.to_app && typeof _value == "object" && this.options.application)
{ {
_value.to_app = this.options.application; _value.to_app = this.options.application;
} }
@ -1307,9 +1307,9 @@ et2_register_widget(et2_link_string, ["link-string"]);
/** /**
* UI widget for one or more links in a list (table) * UI widget for one or more links in a list (table)
* *
* @augments et2_link_string * @augments et2_link_string
*/ */
var et2_link_list = et2_link_string.extend( var et2_link_list = et2_link_string.extend(
{ {
attributes: { attributes: {
@ -1320,10 +1320,10 @@ var et2_link_list = et2_link_string.extend(
"description": "Show links that are marked as deleted, being held for purge" "description": "Show links that are marked as deleted, being held for purge"
} }
}, },
/** /**
* Constructor * Constructor
* *
* @memberOf et2_link_list * @memberOf et2_link_list
*/ */
init: function() { init: function() {
@ -1339,7 +1339,7 @@ var et2_link_list = et2_link_string.extend(
this.context = new egwMenu(); this.context = new egwMenu();
this.context.addItem("comment", this.egw().lang("Comment"), "", function() { this.context.addItem("comment", this.egw().lang("Comment"), "", function() {
var link_id = self.context.data.link_id; var link_id = self.context.data.link_id;
et2_dialog.show_prompt( et2_dialog.show_prompt(
function(button, comment) { function(button, comment) {
if(button != et2_dialog.OK_BUTTON) return; if(button != et2_dialog.OK_BUTTON) return;
@ -1361,7 +1361,7 @@ var et2_link_list = et2_link_string.extend(
}, },
'',self.egw().lang("Comment"),self.context.data.remark||'' '',self.egw().lang("Comment"),self.context.data.remark||''
); );
}); });
this.context.addItem("file_info", this.egw().lang("File information"), this.egw().image("edit"), function(menu_item) { this.context.addItem("file_info", this.egw().lang("File information"), this.egw().image("edit"), function(menu_item) {
var link_data = self.context.data; var link_data = self.context.data;
@ -1386,9 +1386,9 @@ var et2_link_list = et2_link_string.extend(
self._delete_link(link_id); self._delete_link(link_id);
}); });
}, },
destroy: function() { destroy: function() {
this._super.apply(this, arguments); this._super.apply(this, arguments);
if(this.context) if(this.context)
{ {
@ -1422,9 +1422,9 @@ var et2_link_list = et2_link_string.extend(
if(src) icon_widget.set_src(src); if(src) icon_widget.set_src(src);
icon.append(icon_widget.getDOMNode()); icon.append(icon_widget.getDOMNode());
} }
var columns = ['title','remark']; var columns = ['title','remark'];
var self = this; var self = this;
for(var i = 0; i < columns.length; i++) { for(var i = 0; i < columns.length; i++) {
$j(document.createElement("td")) $j(document.createElement("td"))
@ -1493,9 +1493,9 @@ et2_register_widget(et2_link_list, ["link-list"]);
/** /**
* UI widget for one or more links in a list (table) * UI widget for one or more links in a list (table)
* *
* @augments et2_inputWidget * @augments et2_inputWidget
*/ */
var et2_link_add = et2_inputWidget.extend( var et2_link_add = et2_inputWidget.extend(
{ {
attributes: { attributes: {
@ -1512,7 +1512,7 @@ var et2_link_add = et2_inputWidget.extend(
}, },
/** /**
* Constructor * Constructor
* *
* @memberOf et2_link_add * @memberOf et2_link_add
*/ */
init: function() { init: function() {
@ -1540,7 +1540,7 @@ var et2_link_add = et2_inputWidget.extend(
self.egw().open(self.options.value.to_app + ":" + self.options.value.to_id, self.app_select.get_value(), 'add'); self.egw().open(self.options.value.to_app + ":" + self.options.value.to_id, self.app_select.get_value(), 'add');
}; };
this.div.append(this.button.getDOMNode()); this.div.append(this.button.getDOMNode());
return true; return true;
}, },
/** /**