mirror of
https://github.com/owncloudarchive/contacts.git
synced 2025-01-19 08:52:22 +01:00
Fix editing contact photos.
This commit is contained in:
parent
8ce15144c9
commit
bf095621e0
@ -251,7 +251,7 @@ $this->create('contacts_cache_fs_photo', 'addressbook/{backend}/{addressBookId}/
|
||||
$dispatcher->dispatch('ContactPhotoController', 'cacheFileSystemPhoto');
|
||||
}
|
||||
)
|
||||
->requirements(array('backend', 'addressbook', 'contactId'));
|
||||
->requirements(array('backend', 'addressBookId', 'contactId'));
|
||||
|
||||
$this->create('contacts_tmp_contact_photo', 'addressbook/{backend}/{addressBookId}/contact/{contactId}/photo/{key}/tmp')
|
||||
->get()
|
||||
|
25
js/app.js
25
js/app.js
@ -744,7 +744,7 @@ OC.Contacts = OC.Contacts || {
|
||||
var form = $('#file_upload_form');
|
||||
var url = OC.Router.generate(
|
||||
'contacts_upload_contact_photo',
|
||||
{backend: metadata.backend, addressbookid: metadata.addressbookid, contactid: metadata.contactid}
|
||||
{backend: metadata.backend, addressBookId: metadata.addressBookId, contactId: metadata.contactId}
|
||||
);
|
||||
form.attr('action', url);
|
||||
}).on('change', function() {
|
||||
@ -1456,11 +1456,12 @@ OC.Contacts = OC.Contacts || {
|
||||
console.log('cloudPhotoSelected', metadata);
|
||||
var url = OC.Router.generate(
|
||||
'contacts_cache_fs_photo',
|
||||
{backend: metadata.backend, addressbookid: metadata.addressbookid, contactid: metadata.contactid, path: path}
|
||||
{backend: metadata.backend, addressBookId: metadata.addressBookId, contactId: metadata.contactId, path: path}
|
||||
);
|
||||
$.getJSON(url, function(response) {
|
||||
var jqXHR = $.getJSON(url, function(response) {
|
||||
console.log('response', response);
|
||||
if(response.status == 'success') {
|
||||
response = self.storage.formatResponse(response, jqXHR);
|
||||
if(!response.error) {
|
||||
self.editPhoto(metadata, response.data.tmp);
|
||||
} else {
|
||||
$(document).trigger('status.contacts.error', response);
|
||||
@ -1471,13 +1472,13 @@ OC.Contacts = OC.Contacts || {
|
||||
var self = this;
|
||||
var url = OC.Router.generate(
|
||||
'contacts_cache_contact_photo',
|
||||
{backend: metadata.backend, addressbookid: metadata.addressbookid, contactid: metadata.contactid}
|
||||
{backend: metadata.backend, addressBookId: metadata.addressBookId, contactId: metadata.contactId}
|
||||
);
|
||||
console.log('url', url);
|
||||
$.getJSON(url, function(response) {
|
||||
if(response.status == 'success') {
|
||||
var jqXHR = $.getJSON(url, function(response) {
|
||||
response = self.storage.formatResponse(response, jqXHR)
|
||||
if(!response.error) {
|
||||
self.editPhoto(metadata, response.data.tmp);
|
||||
$('#edit_photo_dialog_img').html(response.data.page);
|
||||
} else {
|
||||
$(document).trigger('status.contacts.error', response);
|
||||
}
|
||||
@ -1507,7 +1508,7 @@ OC.Contacts = OC.Contacts || {
|
||||
var $container = $('<div />').appendTo($('body'));
|
||||
var url = OC.Router.generate(
|
||||
'contacts_crop_contact_photo',
|
||||
{backend: metadata.backend, addressbookid: metadata.addressbookid, contactid: metadata.contactid, key: tmpkey}
|
||||
{backend: metadata.backend, addressBookId: metadata.addressBookId, contactId: metadata.contactId, key: tmpkey}
|
||||
);
|
||||
var $dlg = this.$cropBoxTmpl.octemplate(
|
||||
{
|
||||
@ -1520,8 +1521,8 @@ OC.Contacts = OC.Contacts || {
|
||||
|
||||
$.when(this.storage.getTempContactPhoto(
|
||||
metadata.backend,
|
||||
metadata.addressbookid,
|
||||
metadata.contactid,
|
||||
metadata.addressBookId,
|
||||
metadata.contactId,
|
||||
tmpkey
|
||||
))
|
||||
.then(function(image) {
|
||||
@ -1577,8 +1578,8 @@ OC.Contacts = OC.Contacts || {
|
||||
$target.on('load', function() {
|
||||
console.log('submitted');
|
||||
var response = $.parseJSON($target.contents().text());
|
||||
console.log('response', response);
|
||||
if(response && response.status == 'success') {
|
||||
console.log('response', response);
|
||||
$(document).trigger('status.contact.photoupdated', {
|
||||
id: response.data.id,
|
||||
thumbnail: response.data.thumbnail
|
||||
|
@ -125,13 +125,16 @@ class ContactPhotoController extends Controller {
|
||||
return $response;
|
||||
}
|
||||
|
||||
$response->setParams(array(
|
||||
'tmp'=>$tmpkey,
|
||||
'metadata' => array(
|
||||
'contactId'=> $params['contactId'],
|
||||
'addressBookId'=> $params['addressBookId'],
|
||||
'backend'=> $params['backend'],
|
||||
),
|
||||
$response->setData(array(
|
||||
'status' => 'success',
|
||||
'data' => array(
|
||||
'tmp'=>$tmpkey,
|
||||
'metadata' => array(
|
||||
'contactId'=> $params['contactId'],
|
||||
'addressBookId'=> $params['addressBookId'],
|
||||
'backend'=> $params['backend'],
|
||||
),
|
||||
)
|
||||
));
|
||||
|
||||
return $response;
|
||||
@ -259,7 +262,7 @@ class ContactPhotoController extends Controller {
|
||||
$w = (isset($this->request->post['w']) && $this->request->post['w']) ? $this->request->post['w'] : -1;
|
||||
$h = (isset($this->request->post['h']) && $this->request->post['h']) ? $this->request->post['h'] : -1;
|
||||
$tmpkey = $params['key'];
|
||||
$maxSize = isset($this->request->get['maxSize']) ? $this->request->post['maxSize'] : 200;
|
||||
$maxSize = isset($this->request->post['maxSize']) ? $this->request->post['maxSize'] : 200;
|
||||
|
||||
$app = new App($this->api->getUserId());
|
||||
$addressBook = $app->getAddressBook($params['backend'], $params['addressBookId']);
|
||||
@ -322,14 +325,19 @@ class ContactPhotoController extends Controller {
|
||||
$contact->add('PHOTO',
|
||||
strval($image), array('ENCODING' => 'b',
|
||||
'TYPE' => $type));
|
||||
// TODO: Fix this hack
|
||||
$contact->setSaved(false);
|
||||
}
|
||||
if(!$contact->save()) {
|
||||
return $response->bailOut(App::$l10n->t('Error saving contact.'));
|
||||
}
|
||||
$thumbnail = $contact->cacheThumbnail($image);
|
||||
$response->setParams(array(
|
||||
'id' => $params['contactId'],
|
||||
'thumbnail' => $thumbnail,
|
||||
$response->setData(array(
|
||||
'status' => 'success',
|
||||
'data' => array(
|
||||
'id' => $params['contactId'],
|
||||
'thumbnail' => $thumbnail,
|
||||
)
|
||||
));
|
||||
|
||||
$this->server->getCache()->remove($tmpkey);
|
||||
|
Loading…
x
Reference in New Issue
Block a user