diff --git a/api/js/jsapi/app_base.js b/api/js/jsapi/app_base.js index af2d09d87c..105a045ff5 100644 --- a/api/js/jsapi/app_base.js +++ b/api/js/jsapi/app_base.js @@ -642,63 +642,7 @@ export const AppJS = (function(){ "use strict"; return Class.extend( */ add_favorite: function(state) { - if(typeof this.favorite_popup == "undefined" || // Create popup if it's not defined yet - (this.favorite_popup && typeof this.favorite_popup.group != "undefined" - && !this.favorite_popup.group.isAttached())) // recreate the favorite popup if the group selectbox is not attached (eg. after et2 submit) - { - this._create_favorite_popup(); - } - // Get current state - this.favorite_popup.state = jQuery.extend({}, this.getState(), state||{}); -/* - // Add in extras - for(var extra in this.options.filters) - { - // Don't overwrite what nm has, chances are nm has more up-to-date value - if(typeof this.popup.current_filters == 'undefined') - { - this.popup.current_filters[extra] = this.nextmatch.options.settings[extra]; - } - } - - // Add in application's settings - if(this.filters != true) - { - for(var i = 0; i < this.filters.length; i++) - { - this.popup.current_filters[this.options.filters[i]] = this.nextmatch.options.settings[this.options.filters[i]]; - } - } -*/ - // Make sure it's an object - deep copy to prevent references in sub-objects (col_filters) - this.favorite_popup.state = jQuery.extend(true,{},this.favorite_popup.state); - - // Update popup with current set filters (more for debug than user) - var filter_list = []; - var add_to_popup = function(arr) { - filter_list.push(""); - }; - add_to_popup(this.favorite_popup.state); - jQuery("#"+this.appname+"_favorites_popup_state",this.favorite_popup) - .replaceWith( - jQuery(filter_list.join("")).attr("id",this.appname+"_favorites_popup_state") - ); - jQuery("#"+this.appname+"_favorites_popup_state",this.favorite_popup) - .hide() - .siblings(".ui-icon-circle-plus") - .removeClass("ui-icon-circle-minus"); - - // Popup - this.favorite_popup.dialog("open"); - console.log(this); + alert('To use favorites port your app.js to TypeScript!'); // Stop the normal bubbling if this is called on click return false; @@ -734,158 +678,7 @@ export const AppJS = (function(){ "use strict"; return Class.extend( */ _create_favorite_popup: function() { - var self = this; - var favorite_prefix = 'favorite_'; - - // Clear old, if existing - if(this.favorite_popup && this.favorite_popup.group) - { - this.favorite_popup.group.free(); - delete this.favorite_popup; - } - - // Create popup - this.favorite_popup = jQuery('
\ -
\ - ' + - - '\ -
\ - '+ this.egw.lang("Details") + '\ -
    \ - \ -
' - ).appendTo(this.et2 ? this.et2.getDOMNode() : jQuery('body')); - - jQuery(".ui-icon-circle-plus",this.favorite_popup).prev().andSelf().click(function() { - var details = jQuery("#"+self.appname+"_favorites_popup_state",self.favorite_popup) - .slideToggle() - .siblings(".ui-icon-circle-plus") - .toggleClass("ui-icon-circle-minus"); - }); - - // Add some controls if user is an admin - var apps = egw().user('apps'); - var is_admin = (typeof apps['admin'] != "undefined"); - if(is_admin) - { - this.favorite_popup.group = et2_createWidget("select-account",{ - id: "favorite[group]", - account_type: "groups", - empty_label: "Groups", - no_lang: true, - parent_node: this.appname+'_favorites_popup_admin' - },(this.et2 || null)); - this.favorite_popup.group.loadingFinished(); - } - - var buttons = {}; - buttons['save'] = { - text: this.egw.lang('save'), - default: true, - style: 'background-image: url('+this.egw.image('save')+')', - click: function() { - // Add a new favorite - var name = jQuery("#name",this); - - if(name.val()) - { - // Add to the list - name.val(name.val().replace(/(<([^>]+)>)/ig,"")); - var safe_name = name.val().replace(/[^A-Za-z0-9-_]/g,"_"); - var favorite = { - name: name.val(), - group: (typeof self.favorite_popup.group != "undefined" && - self.favorite_popup.group.get_value() ? self.favorite_popup.group.get_value() : false), - state: self.favorite_popup.state - }; - - var favorite_pref = favorite_prefix+safe_name; - - // Save to preferences - if(typeof self.favorite_popup.group != "undefined" && self.favorite_popup.group.getValue() != '') - { - // Admin stuff - save preference server side - self.egw.jsonq('EGroupware\\Api\\Framework::ajax_set_favorite', - [ - self.appname, - name.val(), - "add", - self.favorite_popup.group.get_value(), - self.favorite_popup.state - ] - ); - self.favorite_popup.group.set_value(''); - } - else - { - // Normal user - just save to preferences client side - self.egw.set_preference(self.appname,favorite_pref,favorite); - } - - // Add to list immediately - if(self.sidebox) - { - // Remove any existing with that name - jQuery('[data-id="'+safe_name+'"]',self.sidebox).remove(); - - // Create new item - var html = "\n"; - jQuery(html).insertBefore(jQuery('li',self.sidebox).last()); - self._init_sidebox(self.sidebox); - } - - // Try to update nextmatch favorites too - self._refresh_fav_nm(); - } - // Reset form - delete self.favorite_popup.state; - name.val(""); - jQuery("#filters",self.favorite_popup).empty(); - - jQuery(this).dialog("close"); - } - }; - buttons['cancel'] = { - text: this.egw.lang("cancel"), - style: 'background-image: url('+this.egw.image('cancel')+')', - click: function() { - if(typeof self.favorite_popup.group !== 'undefined' && self.favorite_popup.group.set_value) - { - self.favorite_popup.group.set_value(null); - } - jQuery(this).dialog("close"); - } - }; - - this.favorite_popup.dialog({ - autoOpen: false, - modal: true, - buttons: buttons, - close: function() { - } - }); - - // Bind handler for enter keypress - this.favorite_popup.off('keydown').on('keydown', function(e) { - var tagName = e.target.tagName.toLowerCase(); - tagName = (tagName === 'input' && e.target.type === 'button') ? 'button' : tagName; - - if(e.keyCode == EGW_KEY_ENTER && tagName !== 'textarea' && tagName !== 'select' && tagName !=='button') - { - e.preventDefault(); - jQuery('button[default]',this.favorite_popup.parent()).trigger('click'); - return false; - } - }.bind(this)); + alert('To use favorites port your app.js to TypeScript!'); return false; },