]> source.dussan.org Git - nextcloud-server.git/commitdiff
Contacts: Trying to improve PHOTO handling a bit.
authorThomas Tanghus <thomas@tanghus.net>
Mon, 30 Apr 2012 08:30:10 +0000 (10:30 +0200)
committerThomas Tanghus <thomas@tanghus.net>
Wed, 2 May 2012 09:44:00 +0000 (11:44 +0200)
apps/contacts/js/contacts.js

index ba8e08fd8755b676839af7d56258fc73081a3f6b..47c660efce8ead51e5f257915b9399ecc1c418c2 100644 (file)
@@ -693,6 +693,7 @@ Contacts={
                                                                //Contacts.UI.checkListFor(obj);
                                                        } else if(type == 'single') {
                                                                var proptype = Contacts.UI.propertyTypeFor(obj);
+                                                               Contacts.UI.Card.data[proptype] = null;
                                                                console.log('deleteProperty, hiding: ' + proptype);
                                                                var othertypes = ['NOTE', 'PHOTO'];
                                                                if(othertypes.indexOf(proptype) != -1) {
@@ -701,7 +702,7 @@ Contacts={
                                                                        if(proptype == 'PHOTO') {
                                                                                console.log('Delete PHOTO');
                                                                                Contacts.UI.Contacts.refreshThumbnail(Contacts.UI.Card.id);
-                                                                               Contacts.UI.Card.loadPhoto();
+                                                                               Contacts.UI.Card.loadPhoto(true);
                                                                        } else if(proptype == 'NOTE') {
                                                                                $('#note').find('textarea').val('');
                                                                                Contacts.UI.propertyContainerFor(obj).hide();
@@ -1119,26 +1120,19 @@ Contacts={
                                        }
                                });
                        },
-                       loadPhoto:function(force){
-                               //if(this.data.PHOTO||force==true) {
-                                       $.getJSON(OC.filePath('contacts', 'ajax', 'loadphoto.php'),{'id':this.id},function(jsondata){
-                                               if(jsondata.status == 'success'){
-                                                       //alert(jsondata.data.page);
-                                                       $('#contacts_details_photo_wrapper').data('checksum', jsondata.data.checksum);
-                                                       $('#contacts_details_photo_wrapper').html(jsondata.data.page);
-                                                       Contacts.UI.Card.loadPhotoHandlers();
-                                               }
-                                               else{
-                                                       OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
-                                               }
-                                       });
-                                       $('#file_upload_form').show();
-                                       $('#contacts_propertymenu a[data-type="PHOTO"]').parent().hide();
-                               /*} else {
-                                       $('#contacts_details_photo_wrapper').empty();
-                                       $('#file_upload_form').hide();
-                                       $('#contacts_propertymenu a[data-type="PHOTO"]').parent().show();
-                               }*/
+                       loadPhoto:function(refresh){
+                               $.getJSON(OC.filePath('contacts', 'ajax', 'loadphoto.php'),{'id':this.id, 'refresh': refresh},function(jsondata){
+                                       if(jsondata.status == 'success'){
+                                               $('#contacts_details_photo_wrapper').data('checksum', jsondata.data.checksum);
+                                               $('#contacts_details_photo_wrapper').html(jsondata.data.page);
+                                               Contacts.UI.Card.loadPhotoHandlers();
+                                       }
+                                       else{
+                                               OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
+                                       }
+                               });
+                               $('#file_upload_form').show();
+                               $('#contacts_propertymenu a[data-type="PHOTO"]').parent().hide();
                        },
                        editCurrentPhoto:function(){
                                $.getJSON(OC.filePath('contacts', 'ajax', 'currentphoto.php'),{'id':this.id},function(jsondata){
@@ -1178,6 +1172,7 @@ Contacts={
                                        if(response != undefined && response.status == 'success'){
                                                // load cropped photo.
                                                $('#contacts_details_photo_wrapper').html(response.data.page);
+                                               Contacts.UI.Card.data.PHOTO = true;
                                                Contacts.UI.Card.loadPhotoHandlers();
                                        }else{
                                                OC.dialogs.alert(response.data.message, t('contacts', 'Error'));