mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-07 08:34:29 +01:00
* Addressbook: Fix avatar icon is doubled if contact has no avatar set
This commit is contained in:
parent
b408c8b464
commit
1b0c1b9960
@ -3086,6 +3086,20 @@ window.egw_LAB.wait(function() {
|
|||||||
return $this->tmpl->exec('addressbook.addressbook_ui.search',$content,$sel_options,$readonlys,array(),2);
|
return $this->tmpl->exec('addressbook.addressbook_ui.search',$content,$sel_options,$readonlys,array(),2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if there's a photo for given contact id. This is used for avatar widget
|
||||||
|
* to set or unset delete button. If there's no uploaded photo it responses true.
|
||||||
|
*
|
||||||
|
* @param type $contact_id
|
||||||
|
*/
|
||||||
|
function ajax_noPhotoExists ($contact_id)
|
||||||
|
{
|
||||||
|
$response = Api\Json\Response::get();
|
||||||
|
$response->data((!($contact = $this->read($contact_id)) ||
|
||||||
|
empty($contact['jpegphoto']) && !(($contact['files'] & Api\Contacts::FILES_BIT_PHOTO) &&
|
||||||
|
($size = filesize($url=Api\Link::vfs_path('addressbook', $contact_id, Api\Contacts::FILES_PHOTO))))));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ajax method to update edited avatar photo via avatar widget
|
* Ajax method to update edited avatar photo via avatar widget
|
||||||
*
|
*
|
||||||
|
@ -429,8 +429,9 @@ var et2_avatar = (function(){ "use strict"; return et2_image.extend(
|
|||||||
/**
|
/**
|
||||||
* Build Editable Mask Layer (EML) in order to show edit/delete actions
|
* Build Editable Mask Layer (EML) in order to show edit/delete actions
|
||||||
* on top of profile picture.
|
* on top of profile picture.
|
||||||
|
* @param {boolean} disable delete button in initialization
|
||||||
*/
|
*/
|
||||||
_buildEditableLayer: function ()
|
_buildEditableLayer: function (_noDelete)
|
||||||
{
|
{
|
||||||
var self = this;
|
var self = this;
|
||||||
// editable mask layer (eml)
|
// editable mask layer (eml)
|
||||||
@ -457,7 +458,11 @@ var et2_avatar = (function(){ "use strict"; return et2_image.extend(
|
|||||||
var canvas = jQuery('#_cropper_image').cropper('getCroppedCanvas');
|
var canvas = jQuery('#_cropper_image').cropper('getCroppedCanvas');
|
||||||
self.image.attr('src', canvas.toDataURL("image/jpeg", 1.0));
|
self.image.attr('src', canvas.toDataURL("image/jpeg", 1.0));
|
||||||
egw.json('addressbook.addressbook_ui.ajax_update_photo', [self.options.contact_id, canvas.toDataURL('image/jpeg',1.0)], function(res){
|
egw.json('addressbook.addressbook_ui.ajax_update_photo', [self.options.contact_id, canvas.toDataURL('image/jpeg',1.0)], function(res){
|
||||||
if (res) egw.refresh('Avatar updated.', egw.app_name());
|
if (res)
|
||||||
|
{
|
||||||
|
del.show();
|
||||||
|
egw.refresh('Avatar updated.', egw.app_name());
|
||||||
|
}
|
||||||
}).sendRequest();
|
}).sendRequest();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -489,6 +494,7 @@ var et2_avatar = (function(){ "use strict"; return et2_image.extend(
|
|||||||
if (res)
|
if (res)
|
||||||
{
|
{
|
||||||
self.image.attr('src','');
|
self.image.attr('src','');
|
||||||
|
del.hide();
|
||||||
egw.refresh('Avatar Deleted.', egw.app_name());
|
egw.refresh('Avatar Deleted.', egw.app_name());
|
||||||
}
|
}
|
||||||
}).sendRequest();
|
}).sendRequest();
|
||||||
@ -496,6 +502,7 @@ var et2_avatar = (function(){ "use strict"; return et2_image.extend(
|
|||||||
}, egw.lang('Delete this photo?'), 'Delete', null, et2_dialog.BUTTONS_YES_NO);
|
}, egw.lang('Delete this photo?'), 'Delete', null, et2_dialog.BUTTONS_YES_NO);
|
||||||
})
|
})
|
||||||
.appendTo(eml);
|
.appendTo(eml);
|
||||||
|
if (_noDelete) del.hide();
|
||||||
// invisible the mask
|
// invisible the mask
|
||||||
eml.css('opacity','0');
|
eml.css('opacity','0');
|
||||||
|
|
||||||
@ -514,9 +521,18 @@ var et2_avatar = (function(){ "use strict"; return et2_image.extend(
|
|||||||
doLoadingFinished: function ()
|
doLoadingFinished: function ()
|
||||||
{
|
{
|
||||||
this._super.apply(this,arguments);
|
this._super.apply(this,arguments);
|
||||||
|
var self = this;
|
||||||
if (this.options.editable)
|
if (this.options.editable)
|
||||||
{
|
{
|
||||||
this._buildEditableLayer();
|
egw(window).json(
|
||||||
|
'addressbook.addressbook_ui.ajax_noPhotoExists',
|
||||||
|
[this.options.contact_id],
|
||||||
|
function(noPhotoExists)
|
||||||
|
{
|
||||||
|
if (noPhotoExists) self.image.attr('src','');
|
||||||
|
self._buildEditableLayer(noPhotoExists);
|
||||||
|
}
|
||||||
|
).sendRequest(true);
|
||||||
}
|
}
|
||||||
if (this.options.crop)
|
if (this.options.crop)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user