Fix missing group ID when deleting group favorites, fixes unable to delete group favorites

This commit is contained in:
Nathan Gray 2014-02-12 17:33:22 +00:00
parent 17b8bfcc95
commit 1ca01da9b0
2 changed files with 11 additions and 12 deletions

View File

@ -1957,7 +1957,7 @@ abstract class egw_framework
foreach($filters as $name => $filter) foreach($filters as $name => $filter)
{ {
$href = "javascript:app.$app.setState(" . json_encode($filter,JSON_FORCE_OBJECT) . ');'; $href = "javascript:app.$app.setState(" . json_encode($filter,JSON_FORCE_OBJECT) . ');';
$html .= "<li data-id='$name' class='ui-menu-item' role='menuitem'>\n"; $html .= "<li data-id='$name' data-group='{$filter['group']}' class='ui-menu-item' role='menuitem'>\n";
$html .= '<a href="'.htmlspecialchars($href).'" class="ui-corner-all" tabindex="-1">'; $html .= '<a href="'.htmlspecialchars($href).'" class="ui-corner-all" tabindex="-1">';
$html .= "<div class='" . ($name == $default_filter ? 'ui-icon ui-icon-heart' : 'sideboxstar') . "'></div>". $html .= "<div class='" . ($name == $default_filter ? 'ui-icon ui-icon-heart' : 'sideboxstar') . "'></div>".
$filter['name'] .($filter['group'] != false ? "" :""); $filter['name'] .($filter['group'] != false ? "" :"");
@ -2011,7 +2011,7 @@ abstract class egw_framework
// This is the name as user entered it, minus tags // This is the name as user entered it, minus tags
'name' => $name, 'name' => $name,
'group' => $group ? $group : false, 'group' => $group ? $group : false,
'filter' => $filters 'state' => $filters
); );
$result = $prefs->add($app,$pref_name,$filters,$type); $result = $prefs->add($app,$pref_name,$filters,$type);
$pref = $prefs->save_repository(false,$type); $pref = $prefs->save_repository(false,$type);

View File

@ -485,21 +485,16 @@ var AppJS = Class.extend(
} }
// Add to list immediately // Add to list immediately
var state = {
name: name.val(),
group: false,
state:self.favorite_popup.state
};
if(self.sidebox) if(self.sidebox)
{ {
// Remove any existing with that name // Remove any existing with that name
$j('[data-id="'+safe_name+'"]',self.sidebox).remove(); $j('[data-id="'+safe_name+'"]',self.sidebox).remove();
// Create new item // Create new item
var html = "<li data-id='"+safe_name+"' class='ui-menu-item' role='menuitem'>\n"; var html = "<li data-id='"+safe_name+"' data-group='" + favorite.group + "' class='ui-menu-item' role='menuitem'>\n";
html += "<a href='#' class='ui-corner-all' tabindex='-1'>"; html += "<a href='#' class='ui-corner-all' tabindex='-1'>";
html += "<div class='" + 'sideboxstar' + "'></div>"+ html += "<div class='" + 'sideboxstar' + "'></div>"+
name.val() /*+(filter['group'] != false ? " ♦" :"")*/; favorite.name +(favorite.group != false ? " ♦" :"");
html += "<div class='ui-icon ui-icon-trash' title='" + egw.lang('Delete') + "'/>"; html += "<div class='ui-icon ui-icon-trash' title='" + egw.lang('Delete') + "'/>";
html += "</a></li>\n"; html += "</a></li>\n";
$j(html).on('click.favorites',jQuery.proxy(function(event) { $j(html).on('click.favorites',jQuery.proxy(function(event) {
@ -509,7 +504,7 @@ var AppJS = Class.extend(
return; return;
} }
app[self.appname].setState(this); app[self.appname].setState(this);
},state)) },favorite))
.insertBefore($j('li',self.sidebox).last()); .insertBefore($j('li',self.sidebox).last());
self._init_sidebox(self.sidebox); self._init_sidebox(self.sidebox);
} }
@ -566,6 +561,7 @@ var AppJS = Class.extend(
var app = event.data; var app = event.data;
var id = $j(this).parentsUntil('li').parent().attr("data-id"); var id = $j(this).parentsUntil('li').parent().attr("data-id");
var group = $j(this).parentsUntil('li').parent().attr("data-group") || '';
var line = $j('li[data-id="'+id+'"]',app.sidebox); var line = $j('li[data-id="'+id+'"]',app.sidebox);
var name = line.first().text(); var name = line.first().text();
var trash = this; var trash = this;
@ -585,9 +581,12 @@ var AppJS = Class.extend(
// Delete preference server side // Delete preference server side
var request = egw.json(app.appname + ".egw_framework.ajax_set_favorite.template", var request = egw.json(app.appname + ".egw_framework.ajax_set_favorite.template",
[app.appname, id, "delete", '', ''], [app.appname, id, "delete", group, ''],
function(result) { function(result) {
if(result) // Got the full response from callback, which we don't want
if(result.type) return;
if(result && typeof result == 'boolean')
{ {
// Remove line from list // Remove line from list
line.slideUp("slow", function() { }); line.slideUp("slow", function() { });