From 6386891928529da8bad6750a978e4555efcf1c3b Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Sat, 31 Jan 2009 10:28:26 -0500 Subject: [PATCH] Attach the 'add' action to the tagger input box. Adding tags now work from the calendar panel. Obviously the CSS needs some work, UI suggestions welcome. --- kronolith/js/tagactions.js | 13 +++++++------ kronolith/lib/Imple/TagActions.php | 8 ++++---- kronolith/templates/panel.inc | 6 +++++- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/kronolith/js/tagactions.js b/kronolith/js/tagactions.js index 84c85bccc..f9fc362a3 100755 --- a/kronolith/js/tagactions.js +++ b/kronolith/js/tagactions.js @@ -1,14 +1,14 @@ -function addTag() +function addTag(resource, type, endpoint) { - if (!$('addtag').value.blank()) { + if (!$('newtags-input_' + resource).value.blank()) { var params = new Object(); - params.requestType="TagActions/action=add/gallery=" + tagActions.gallery + "/tags=" + $('addtag').value; - new Ajax.Updater({success:'tags'}, - tagActions.url, + params.imple="TagActions/action=add/resource=" + resource + "/type=" + type + "/tags=" + $('newtags-input_' + resource).value; + new Ajax.Updater({success:'tags_' + resource}, + endpoint, { method: 'post', parameters: params, - onComplete: function() {$('addtag').value = "";} + onComplete: function() {$('newtags-input_' + resource).value = "";} } ); } @@ -27,6 +27,7 @@ function removeTag(resource, type, tagid, endpoint) parameters: params } ); + return true; } diff --git a/kronolith/lib/Imple/TagActions.php b/kronolith/lib/Imple/TagActions.php index 619a49a20..c0df540b6 100644 --- a/kronolith/lib/Imple/TagActions.php +++ b/kronolith/lib/Imple/TagActions.php @@ -23,11 +23,11 @@ class Kronolith_Imple_TagActions extends Kronolith_Imple $action = $this->_params['action']; $content_id = $this->_params['resource']; $content_type = $this->_params['type']; - $tag_id = $this->_params['tagId']; + $tag_id = !empty($this->_params['tagId']) ? $this->_params['tagId'] : null; $endpoint = Horde::url('imple.php', true); if ($action == 'add') { - $js = "Event.observe('" . $dom_id . "', 'click', function(event) {addTag(); Event.stop(event)});"; + $js = "Event.observe('" . $dom_id . "_" . $content_id . "', 'click', function(event) {addTag('" . $content_id . "', '" . $content_type . "', '" . $endpoint . "'); Event.stop(event)});"; } elseif ($action == 'delete') { $js = "Event.observe('" . $dom_id . "', 'click', function(event) {removeTag('" . $content_id . "', '" . $content_type . "', " . $tag_id . ", '" . $endpoint . "'); Event.stop(event)});"; } @@ -61,12 +61,12 @@ class Kronolith_Imple_TagActions extends Kronolith_Imple if ($perm) { /* Get the resource owner */ + $tagger = new Kronolith_Tagger(); switch ($request) { case 'add': - //@TODO + $tagger->tag($args['resource'], $tags, $args['type']); break; case 'remove': - $tagger = new Kronolith_Tagger(); $tagger->untag($args['resource'], (int)$tags, $args['type']); break; } diff --git a/kronolith/templates/panel.inc b/kronolith/templates/panel.inc index c410548e7..750ce8091 100644 --- a/kronolith/templates/panel.inc +++ b/kronolith/templates/panel.inc @@ -62,11 +62,15 @@ $tagger = new Kronolith_Tagger();
 
- +
'newtags-input', 'id' => $id)); + Kronolith_Imple::factory('TagActions', array('triggerId' => 'newtags-button', + 'resource' => $id, + 'type' => 'calendar', + 'action' => 'add')); ?> -- 2.11.0