fix avatar/files update issues

This commit is contained in:
Ralf Becker 2017-11-29 09:58:36 +08:00
parent b40fd0a8eb
commit dd4ae60fa2
4 changed files with 28 additions and 15 deletions

View File

@ -3109,10 +3109,12 @@ window.egw_LAB.wait(function() {
* Ajax method to update edited avatar photo via avatar widget * Ajax method to update edited avatar photo via avatar widget
* *
* @param int $contact_id * @param int $contact_id
* @param file string $file = null null means to delete * @param file string $file null means to delete
* @param string $etemplate_exec_id to update id, files, etag, ...
*/ */
function ajax_update_photo ($contact_id, $file= null) function ajax_update_photo ($contact_id, $file, $etemplate_exec_id)
{ {
$et_request = Api\Etemplate\Request::read($etemplate_exec_id);
$response = Api\Json\Response::get(); $response = Api\Json\Response::get();
$contact = $this->read($contact_id); $contact = $this->read($contact_id);
if ($file) if ($file)
@ -3132,6 +3134,9 @@ window.egw_LAB.wait(function() {
else else
{ {
$response->data(true); $response->data(true);
// merge changes (files, id, ...) into current eT request
unset($contact['jpegphoto'], $contact['photo_unchanged']);
$et_request->preserv = array_merge($et_request->preserv, $contact);
} }
} }

View File

@ -429,7 +429,7 @@ 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 * @param {boolean} _noDelete disable delete button in initialization
*/ */
_buildEditableLayer: function (_noDelete) _buildEditableLayer: function (_noDelete)
{ {
@ -457,11 +457,14 @@ 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){ self.egw().json('addressbook.addressbook_ui.ajax_update_photo',
[self.options.contact_id, canvas.toDataURL('image/jpeg',1.0), self.getInstanceManager().etemplate_exec_id],
function(res)
{
if (res) if (res)
{ {
del.show(); del.show();
egw.refresh('Avatar updated.', egw.app_name()); self.egw().refresh('Avatar updated.', egw.app_name());
} }
}).sendRequest(); }).sendRequest();
} }
@ -490,7 +493,10 @@ var et2_avatar = (function(){ "use strict"; return et2_image.extend(
et2_dialog.show_dialog(function(_btn){ et2_dialog.show_dialog(function(_btn){
if (_btn == et2_dialog.YES_BUTTON) if (_btn == et2_dialog.YES_BUTTON)
{ {
egw.json('addressbook.addressbook_ui.ajax_update_photo', [self.options.contact_id, null], function(res){ self.egw().json('addressbook.addressbook_ui.ajax_update_photo',
[self.options.contact_id, null, self.getInstanceManager().etemplate_exec_id],
function(res)
{
if (res) if (res)
{ {
self.image.attr('src',''); self.image.attr('src','');

View File

@ -994,6 +994,7 @@ class Contacts extends Contacts\Storage
$contact['id'] = $to_write['id']; $contact['id'] = $to_write['id'];
$contact['uid'] = $to_write['uid']; $contact['uid'] = $to_write['uid'];
$contact['etag'] = $to_write['etag']; $contact['etag'] = $to_write['etag'];
$contact['files'] = $to_write['files'];
// Clear any files saved with new entries // Clear any files saved with new entries
// They've been dealt with already and they cause errors with linking // They've been dealt with already and they cause errors with linking

View File

@ -575,6 +575,7 @@ class Storage
$contact['id'] = $this->somain->data['id']; $contact['id'] = $this->somain->data['id'];
$contact['uid'] = $this->somain->data['uid']; $contact['uid'] = $this->somain->data['uid'];
$contact['etag'] = $this->somain->data['etag']; $contact['etag'] = $this->somain->data['etag'];
$contact['files'] = $this->somain->data['files'];
if ($this->contact_repository == 'sql-ldap') if ($this->contact_repository == 'sql-ldap')
{ {