changeset 782:eb3e9e1ffc13 feature_14

Fixes Bug #339. Might need some JS refactoring later on…
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Fri, 18 Nov 2011 15:48:53 +0000
parents 62a8d632451c
children b153713dc4fd
files vendor/plugins/redmine_tags/app/views/projects/_filter_search_tags.html.erb vendor/plugins/redmine_tags/assets/javascripts/projects_index.js vendor/plugins/redmine_tags/assets/javascripts/tags_input.js
diffstat 3 files changed, 21 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/vendor/plugins/redmine_tags/app/views/projects/_filter_search_tags.html.erb	Fri Nov 18 14:24:31 2011 +0000
+++ b/vendor/plugins/redmine_tags/app/views/projects/_filter_search_tags.html.erb	Fri Nov 18 15:48:53 2011 +0000
@@ -7,7 +7,7 @@
       <div id="project_tag_candidates" class="autocomplete"></div>
       <%= javascript_include_tag 'tags_input', :plugin => 'redmine_tags' %>
 
-      <%= javascript_tag "observeProjectTagsField('#{url_for(:controller => 'auto_completes', :action => 'project_search_tags', :project_id => Project.first.id)}')" %>
+      <%= javascript_tag "observeProjectTagsField('#{url_for(:controller => 'auto_completes', :action => 'project_search_tags', :project_id => Project.first.id)}', true)" %>
     </div>
   <% end -%>
 </p>
--- a/vendor/plugins/redmine_tags/assets/javascripts/projects_index.js	Fri Nov 18 14:24:31 2011 +0000
+++ b/vendor/plugins/redmine_tags/assets/javascripts/projects_index.js	Fri Nov 18 15:48:53 2011 +0000
@@ -1,7 +1,3 @@
-// Event.observe(window, 'load', function() {
-// });
-
-
 function toggleFieldsetWithState(this_field){
 	id = Element.up(this_field, 'fieldset').id;	
 	// is the fieldset collapsed?
@@ -19,3 +15,7 @@
     	asynchronous: true
   	});
 }
+
+function submitForm(){
+	$('submitButton').click(); return false;
+}
\ No newline at end of file
--- a/vendor/plugins/redmine_tags/assets/javascripts/tags_input.js	Fri Nov 18 14:24:31 2011 +0000
+++ b/vendor/plugins/redmine_tags/assets/javascripts/tags_input.js	Fri Nov 18 15:48:53 2011 +0000
@@ -21,12 +21,14 @@
 var Redmine = Redmine || {};
 
 Redmine.TagsInput = Class.create({
-  initialize: function(element) {
+  initialize: function(element, update) {
     this.element  = $(element);
     this.input    = new Element('input', { 'type': 'text', 'autocomplete': 'off', 'size': 10 });
     this.button   = new Element('span', { 'class': 'tag-add icon icon-add' });
     this.tags     = new Hash();
     
+		this.update = update;
+
     Event.observe(this.button, 'click', this.readTags.bind(this));
     Event.observe(this.input, 'keypress', this.onKeyPress.bindAsEventListener(this));
 
@@ -35,15 +37,16 @@
     this.addTagsList(this.element.value);
   },
 
-  readTags: function() {
+  readTags: function() {		
     this.addTagsList(this.input.value);
     this.input.value = '';
+		if(this.update){submitForm();};
   },
 
   onKeyPress: function(event) {
     if (Event.KEY_RETURN == event.keyCode) {
       this.readTags(event);
-      Event.stop(event);
+      Event.stop(event);			
     }
   },
 
@@ -57,10 +60,13 @@
     this.element.value = this.getTagsList();
     this.element.insert({ 'before': label });
 
+		if(this.update){submitForm();};
+
     Event.observe(button, 'click', function(){
       this.tags.unset(tag);
       this.element.value = this.getTagsList();
       label.remove();
+		  if(this.update){submitForm();};
     }.bind(this));
   },
 
@@ -90,9 +96,13 @@
 
 
 function observeIssueTagsField(url) {
-  new Redmine.TagsInput('issue_tag_list').autocomplete('issue_tag_candidates', url);
+  new Redmine.TagsInput('issue_tag_list', false).autocomplete('issue_tag_candidates', url);
 }
 
-function observeProjectTagsField(url) {
-	new Redmine.TagsInput('project_tag_list').autocomplete('project_tag_candidates', url);
+function observeProjectTagsField(url, update) {
+	if(!update) { 
+			var update = false;
+		};
+	
+	new Redmine.TagsInput('project_tag_list', update).autocomplete('project_tag_candidates', url);
 }
\ No newline at end of file