oc-vcategories.txt 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. Using OCCategories
  2. This 'class' is meant for any apps that uses OC_VObjects with the CATEGORIES field e.g.
  3. Contacts and Calendar. It provides an editor UI for adding/deleting and rescanning categories
  4. and basic ajax functions for adding and deleting.
  5. To use the mass updating of OC_VObjects that /lib/vcategories.php provides, the app must implement
  6. its own ajax functions in /apps/$(APP)/ajax/categories/rescan.php and /apps/$(APP)/ajax/categories/delete.php
  7. See examples in /apps/contacts/ajax/categories and the inline docs in /lib/vcategories.php.
  8. In your app make sure you load the script and stylesheet:
  9. OC_Util::addScript('','oc-vcategories');
  10. OC_Util::addStyle('','oc-vcategories');
  11. Set the app specific values in your javascript file. This is what I've used for the Contacts app:
  12. OCCategories.app = 'contacts';
  13. OCCategories.changed = Contacts.UI.Card.categoriesChanged;
  14. If OCCategories.changed is set that function will be called each time the categories have been changed
  15. in the editor (add/delete/rescan) to allow the app to update the UI accordingly. The only argument to the function
  16. is an array of the updated categories e.g.:
  17. OCCategories.changed = function(categories) {
  18. for(var category in categories) {
  19. console.log(categories[category]);
  20. }
  21. }
  22. To show the categories editor call:
  23. OCCategories.edit()