]> source.dussan.org Git - nextcloud-server.git/commitdiff
Make PHOTO deletable.
authorThomas Tanghus <thomas@tanghus.net>
Tue, 13 Mar 2012 13:56:03 +0000 (14:56 +0100)
committerThomas Tanghus <thomas@tanghus.net>
Tue, 13 Mar 2012 13:56:03 +0000 (14:56 +0100)
apps/contacts/ajax/loadphoto.php
apps/contacts/js/contacts.js
apps/contacts/templates/part.contact.php

index 1f4cde0b535afd574ee1623b8bb48289f70f5834..2c8bb7bf1ed80e1097d1ba70446fea3248605b44 100644 (file)
@@ -43,8 +43,17 @@ if($id == '') {
        bailOut(OC_Contacts_App::$l10n->t('Missing contact id.'));
 }
 
+$checksum = '';
+$vcard = OC_Contacts_App::getContactVCard( $id );
+foreach($vcard->children as $property){
+       if($property->name == 'PHOTO') {
+               $checksum = md5($property->serialize());
+               break;
+       }
+}
+
 $tmpl = new OC_TEMPLATE("contacts", "part.contactphoto");
 $tmpl->assign('id', $id);
 $page = $tmpl->fetchPage();
-OC_JSON::success(array('data' => array('page'=>$page)));
+OC_JSON::success(array('data' => array('page'=>$page, 'checksum'=>$checksum)));
 ?>
index 13d71be384d152aa8b7d34d25d21bd37c6e7735e..18214cb1cc52ab397fcefa9412812223f5ab6bdb 100644 (file)
@@ -662,7 +662,9 @@ Contacts={
                                                        } else if(type == 'single') {
                                                                var proptype = Contacts.UI.propertyTypeFor(obj);
                                                                console.log('deleteProperty, hiding: ' + proptype);
-                                                               if(proptype == 'NOTE') {
+                                                               var othertypes = ['NOTE', 'PHOTO'];
+                                                               if(othertypes.indexOf(proptype) != -1) {
+                                                                       console.log('NOTE or PHOTO');
                                                                        Contacts.UI.propertyContainerFor(obj).hide();
                                                                        Contacts.UI.propertyContainerFor(obj).data('checksum', '');
                                                                } else {
@@ -943,6 +945,7 @@ Contacts={
                                        $.getJSON('ajax/loadphoto.php',{'id':this.id},function(jsondata){
                                                if(jsondata.status == 'success'){
                                                        //alert(jsondata.data.page);
+                                                       $('#file_upload_form').data('checksum', jsondata.data.checksum);
                                                        $('#contacts_details_photo_wrapper').html(jsondata.data.page);
                                                }
                                                else{
index a3b4917ae9896b942e040e78c9ff9f9035f334f2..cb1e080a40a3c28da923d1b2d01ed217ebd39dc0 100644 (file)
@@ -23,8 +23,9 @@ $id = isset($_['id']) ? $_['id'] : '';
 
        <div class="contactsection">
 
-       <form style="display:none;" id="file_upload_form" action="ajax/uploadphoto.php" method="post" enctype="multipart/form-data" target="file_upload_target">
+       <form style="display:none;" id="file_upload_form" action="ajax/uploadphoto.php" method="post" enctype="multipart/form-data" target="file_upload_target" class="propertycontainer" data-element="PHOTO">
        <fieldset id="photo" class="formfloat">
+       <a class="action delete" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'single');" title="<?php echo $l->t('Delete'); ?>"></a>
                <div id="contacts_details_photo_wrapper" title="<?php echo $l->t('Click or drop to upload picture'); ?> (max <?php echo $_['uploadMaxHumanFilesize']; ?>)">
                <!-- img style="padding: 1em;" id="contacts_details_photo" alt="Profile picture"  src="photo.php?id=<?php echo $_['id']; ?>" / -->
                <progress id="contacts_details_photo_progress" style="display:none;" value="0" max="100">0 %</progress>
@@ -63,7 +64,7 @@ $id = isset($_['id']) ? $_['id'] : '';
                        <a class="action edit" onclick="$(this).tipsy('hide');OCCategories.edit();" title="<?php echo $l->t('Edit categories'); ?>"></a>
                </dd -->
                <dt style="display:none;" id="categories_label" data-element="CATEGORIES"><label for="categories"><?php echo $l->t('Categories'); ?></label></dt>
-               <dd style="display:none;" class="propertycontainer" id="categories_value" data-element="CATEGORIES"><input id="categories"  required="required" name="value[CATEGORIES]" type="text" class="contacts_property" style="width:16em;" name="value" value="" placeholder="<?php echo $l->t('Categories'); ?>" /><a class="delete" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'single');" title="<?php echo $l->t('Delete'); ?>"></a><a class="action edit" onclick="$(this).tipsy('hide');OCCategories.edit();" title="<?php echo $l->t('Edit categories'); ?>"></a></dd>
+               <dd style="display:none;" class="propertycontainer" id="categories_value" data-element="CATEGORIES"><input id="categories"  required="required" name="value[CATEGORIES]" type="text" class="contacts_property" style="width:16em;" name="value" value="" placeholder="<?php echo $l->t('Categories'); ?>" /><a class="action delete" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'single');" title="<?php echo $l->t('Delete'); ?>"></a><a class="action edit" onclick="$(this).tipsy('hide');OCCategories.edit();" title="<?php echo $l->t('Edit categories'); ?>"></a></dd>
        </dl>
        </fieldset>
        <fieldset id="note" class="formfloat propertycontainer contactpart" style="display:none;" data-element="NOTE">