evanmsanders / flex2sms

Web front-end to SACFS flex2sms system.
1 stars 0 forks source link

Service Delete button on contact view page deletes service, not subscription #45

Closed mazzone closed 11 years ago

mazzone commented 11 years ago

Need the "Delete" button next to services on the contacts view pages to unsubscribe a contact to that service, rather than delete the service. Could possibly change it to "Unsubscribe" as well.

evanmsanders commented 11 years ago

I'd like to suggest we push this feature into version 2. It's extremely complicated to do because of the way we've set up the contacts -> services relationship.

Cake automatically flushes the join table records every time we save the contact or the service (and we're relying on this behaviour for the add/edit forms) which means that we need to load up the whole model, remove the service from the right part of the array, and then save it again.

The way to solve this is to set up a "Subscriptions" model so that Contact->HasMany->Subscriptions<-HasMany<-Services. That way we can delete just the subscription. HOWEVER, this will break all our forms, so it's a lot of work to do.

Given how easy it is to simply edit the Contact and untick a service checkbox, I've replaced the 'Delete' buttons on the Contact view page with enable/disable service instead.

Feel free to re-open if you disagree... :P

mazzone commented 11 years ago

I agree that it's probably not worth the effort, but I don't think we should have an enable/disable button there either, as that could lead to services being disabled accidentally when what we really want is a contact to be removed from them.

We could possible have an edit button that edits the service/contact and allows you to remove the subscription that way?

I'll re-open until we remove the buttons or make them edit ones :)

evanmsanders commented 11 years ago

Ok - so then the page will have just an 'Edit' button at the top which will edit the contact (and allow you to remove the service from the contact) and an 'Edit' button for each service (which will allow you to remove the contact from the service).

mazzone commented 11 years ago

Yes, that would be perfect.