Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

New Stuff!


Reply

17 Posts   3439 Views

Avatar
vancouverWill

26 November 2009 at 8:01am Community Member, 121 Posts

So seeing how you got this working made me look into a bit more and see a few possibilities. A while ago I asked you how I could add delete confirmation on the DOM and now it is relatively straightforward.

In my project page class I added the following code

$projectfield->removePermission("delete");

to turn off the main delete button. I then added to the dataobject a delete function and a new DataObjectManagerAction

public function confirmDelete()
{
if($this)
$this->delete();
else
{
       }
}

new DataObjectManagerAction(
'Delete Project',
"http://synergysilverstripelatest/admin/EditForm/field/Projects/item/$this->ID/delete",
"delete-confirm",
"/assets/graphics/$deleteImage"
));


notice I called 'delete-confirm' my new $behaviour javascript function which I placed in dataobject_manager.js

$container.find('a.delete-link-synergy-test-edit').unbind('click').click(function(e) {
         alert('this works cause its wills test');
         var answer = confirm('Do you want to delete this?');
         if (answer){
         alert("You deleted it!");
         params = $('#SecurityID') ? {'forceajax' : '1', 'SecurityID' : $('#SecurityID').attr('value')} : {'forceajax' : '1'};
         $target = $(this);
         $.post(
            $target.attr('href'),
            params,
            function() {$($target).parents('li:first').fadeOut();$(".ajax-loader").fadeOut("fast");}
         );
         e.stopPropagation();
         return false;
         }
         else
         {
            alert("Thanks for sticking around!");
            return false;
         }
      });


where I just copied your delete function and added a confirm function in there. At the moment I just edited the dataobject_manager.js which works but is obviously a bad way to do it as it will be deleted come upgrade time.

I tried creating a new class called WillsDataObjectManagerAction.php which wasn't too big as it just had the DataObjectManagerAction in it but it had to call a new copy of dataobject_manager.js called willsdataobject_manager.js which worked too but I am wondering is this a bad way to do it cause it's a big js file and if I keep using my copy of it's current state it will gradually get more out of date. Is it better to do this or just edit the main js file every upgrade. How much is the js file likely to change I guess I'm asking as well. Thanks. Hope this helps someone.

Avatar
vancouverWill

1 December 2009 at 7:15am Community Member, 121 Posts

any thoughts on the best way to seperate my js so that it will still fit in with future versions of DOM?

Avatar
UncleCheese

1 December 2009 at 9:16am 4085 Posts

I think I'm going to roll in the confirm delete feature. I just hate using javascript alert windows. I was hoping to come up with something a little more graceful.

Avatar
vancouverWill

3 December 2009 at 10:18am Community Member, 121 Posts

In dataobjectmanager when I hit any of the icons which refresh the page using AJAX, they are calling the frontend theme css. I couldn't understand it for a while but then I thought about it and realised the way you recommended to add a a new DataObjectManagerAction links to the ExamplePage_Controller where as it is an extension of Page_Controller the frontend CSS is called. While everything still works it makes my CMS look super ugly. I guess I could hack my frontend CSS a lot so it doesn't effect the CMS but this seems like a big job. Is there anyway of staying within the admin section so the front end CSS isn't called at all?

Thanks

Will

Avatar
UncleCheese

3 December 2009 at 10:46am 4085 Posts

Nooooo... you should not be using a Page_Controller subclass. Just "Controller."

Avatar
vancouverWill

3 December 2009 at 11:01am Community Member, 121 Posts

Ummm you used ListingPage_Controller and you call "/ListingPage_Controller/approve/$this->ID" ?

Can I have for my example

class Project_Controller extends Controller to hold the new functions

as well as the classes I already have to hold the data details and page functions

class ProjectPage extends Page
class ProjectPage_Controller extends Page_Controller

Avatar
UncleCheese

3 December 2009 at 11:18am 4085 Posts

Whoops. You're right. That's a typo. That should read "Listing_Controller". You can put it in the same file as your DataObject class -- e.g. Listing.php contains Listing extends DataObject as well as Listing_Controller extends Controller.

Hope that helps.

Avatar
vancouverWill

3 December 2009 at 11:34am Community Member, 121 Posts

Yes. awesome. thanks again.