diff --git a/app/controllers/rb_stories_controller.rb b/app/controllers/rb_stories_controller.rb index 51465dda3..247d30bd4 100755 --- a/app/controllers/rb_stories_controller.rb +++ b/app/controllers/rb_stories_controller.rb @@ -38,19 +38,4 @@ def update end end - - def transitions - transitions = Hash.new - @project.trackers.each do |tid| - tracker = Tracker.find_by_id(tid) - transitions[tracker.id] = Hash.new - IssueStatus.find(:all, :order => "position ASC").each do |status| - allowed = status.find_new_statuses_allowed_to(User.current.roles_for_project(@project), tracker) - to = transitions[tracker.id]["from-#{status.id}"] = allowed << status - end - end - respond_to do |format| - format.json { render :json => transitions } - end - end end diff --git a/app/views/rb_server_variables/show.js.erb b/app/views/rb_server_variables/show.js.erb index 601adb502..5e8d90e05 100644 --- a/app/views/rb_server_variables/show.js.erb +++ b/app/views/rb_server_variables/show.js.erb @@ -7,13 +7,8 @@ RB.constants = { sprint_id: <%= @sprint ? @sprint.id : "null" %>, protect_against_forgery: <%= protect_against_forgery? ? "true" : "false" %>, request_forgery_protection_token: '<%= request_forgery_protection_token %>', - form_authenticity_token: '<%= form_authenticity_token %>', - transitions: {} + form_authenticity_token: '<%= form_authenticity_token %>' } -$.getJSON("/rb/transitions/" + RB.constants.project_id, function(data) { - RB.constants.transitions = data -}); - RB.buildImageTag = function(name){ return "" + name + "'/>" @@ -29,10 +24,10 @@ RB.urlFor = function(route_name, options){ RB.routes = { update_sprint: '<%= url_for(:controller => 'rb_sprints', :action => 'update', :sprint_id => ":id") %>', - + create_story: '<%= url_for(:controller => 'rb_stories', :action => 'create') %>', update_story: '<%= url_for(:controller => 'rb_stories', :action => 'update', :id => ":id") %>', - + create_task: '<%= url_for(:controller => 'rb_tasks', :action => 'create') %>', update_task: '<%= url_for(:controller => 'rb_tasks', :action => 'update', :id => ":id") %>', @@ -44,4 +39,3 @@ RB.routes = { } if(typeof console != "undefined" && console != null) console.log('*** server variables loaded ***'); - diff --git a/assets/javascripts/model.js b/assets/javascripts/model.js index 9c6cad9e9..dbf3663a8 100644 --- a/assets/javascripts/model.js +++ b/assets/javascripts/model.js @@ -9,7 +9,7 @@ RB.Model = RB.Object.create({ initialize: function(el){ var j; // This ensures that we use a local 'j' variable, not a global one. var self = this; - + this.$ = j = $(el); this.el = el; }, @@ -30,7 +30,7 @@ RB.Model = RB.Object.create({ this.afterUpdate(data, textStatus, xhr); } }, - + afterUpdate: function(data, textStatus, xhr){ // Do nothing. Child objects may optionally override this }, @@ -45,7 +45,7 @@ RB.Model = RB.Object.create({ this.$.hide('blind'); } }, - + close: function(){ this.$.addClass('closed'); }, @@ -60,7 +60,7 @@ RB.Model = RB.Object.create({ displayEditor: function(editor){ var pos = this.$.offset(); var self = this; - + editor.dialog({ buttons: { "Cancel" : function(){ self.cancelEdit(); $(this).dialog("close") }, @@ -78,16 +78,16 @@ RB.Model = RB.Object.create({ edit: function(){ var editor = this.getEditor(); - + // 'this' can change below depending on the context. var self = this; - + this.$.find('.editable').each(function(index){ var field = $(this); var fieldType = field.attr('fieldtype')!=null ? field.attr('fieldtype') : 'input'; var fieldName = field.attr('fieldname'); var input; - + $(document.createElement("label")).text(fieldName.replace(/_/ig, " ").replace(/ id$/ig,"")).appendTo(editor); input = fieldType=='select' ? $('#' + fieldName + '_options').clone(true) : $(document.createElement(fieldType)); input.removeAttr('id'); @@ -101,7 +101,7 @@ RB.Model = RB.Object.create({ input.datepicker({ changeMonth: true, changeYear: true, closeText: 'Close', - dateFormat: 'yy-mm-dd', + dateFormat: 'yy-mm-dd', firstDay: 1, onClose: function(){ $(this).focus() }, selectOtherMonths: true, @@ -112,33 +112,17 @@ RB.Model = RB.Object.create({ // So that we won't need a datepicker button to re-show it input.bind('mouseup', function(event){ $(this).datepicker("show") }); } - + // Copy the value in the field to the input element value = ( fieldType=='select' ? field.children('.v').first().text() : field.text() ); input.val(value); - + // Record in the model's root element which input field had the last focus. We will // use this information inside RB.Model.refresh() to determine where to return the // focus after the element has been refreshed with info from the server. input.focus( function(){ self.$.data('focus', $(this).attr('name')) } ) .blur( function(){ self.$.data('focus', '') } ); - - if ( fieldType=='select' && fieldName == 'status_id' ) { - story_id = field.parents('.model').first().attr('id').replace('story_','') - tracker_id = field.parents('.model').find('.tracker_id').first().children('.v').text() - status_id = field.children('.v').first().text() - status_name = field.children('.t').first().text() - transitions = RB.constants.transitions[tracker_id]['from-'+status_id] - input.html(""); - used = new Array(); - for (i=0; i'+transitions[i].name+''); - used[transitions[i].id] = true; - } - } - } + input.appendTo(editor); }); @@ -146,26 +130,26 @@ RB.Model = RB.Object.create({ this.editorDisplayed(editor); return editor; }, - + // Override this method to change the dialog title editDialogTitle: function(){ return "Edit " + this.getType() }, - + editorDisplayed: function(editor){ // Do nothing. Child objects may override this. }, - + endEdit: function(){ this.$.removeClass('editing'); }, - + error: function(xhr, textStatus, error){ this.markError(); RB.Dialog.msg($(xhr.responseText).find('.errors').html()); this.processError(xhr, textStatus, error); }, - + getEditor: function(){ // Create the model editor if it does not yet exist var editor_id = this.getType().toLowerCase() + "_editor"; @@ -177,15 +161,15 @@ RB.Model = RB.Object.create({ } return editor; }, - + getID: function(){ return this.$.children('.id').children('.v').text(); }, - + getType: function(){ throw "Child objects must override getType()"; }, - + handleClick: function(event){ var field = $(this); var model = field.parents('.model').first().data('this'); @@ -200,7 +184,7 @@ RB.Model = RB.Object.create({ var j = $(this); var self = j.data('this'); - if(!$(event.target).hasClass('editable') && + if(!$(event.target).hasClass('editable') && !$(event.target).hasClass('checkbox') && !j.hasClass('editing') && event.target.tagName!='A' && @@ -212,7 +196,7 @@ RB.Model = RB.Object.create({ isClosed: function(){ return this.$.hasClass('closed'); }, - + isNew: function(){ return this.getID()==""; }, @@ -220,11 +204,11 @@ RB.Model = RB.Object.create({ markError: function(){ this.$.addClass('error'); }, - + markIfClosed: function(){ throw "Child objects must override markIfClosed()"; }, - + markSaving: function(){ this.$.addClass('saving'); }, @@ -233,7 +217,7 @@ RB.Model = RB.Object.create({ newDialogTitle: function(){ return "New " + this.getType() }, - + open: function(){ this.$.removeClass('closed'); }, @@ -244,7 +228,7 @@ RB.Model = RB.Object.create({ refresh: function(obj){ this.$.html(obj.$.html()); - + if(obj.isClosed()){ this.close(); } else { @@ -252,7 +236,7 @@ RB.Model = RB.Object.create({ } this.refreshed(); }, - + refreshed: function(){ // Override as needed }, @@ -265,7 +249,7 @@ RB.Model = RB.Object.create({ var j = this.$; var self = this; var editors = j.find('.editor'); - + // Copy the values from the fields to the proper html elements editors.each(function(index){ editor = $(this); @@ -300,14 +284,13 @@ RB.Model = RB.Object.create({ }); self.endEdit(); }, - + unmarkError: function(){ this.$.removeClass('error'); }, - + unmarkSaving: function(){ this.$.removeClass('saving'); } -}); - +}); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 157c4d845..cd9c2f587 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -25,8 +25,6 @@ rb.resources :release, :only => :destroy, :controller => :rb_releases, :as => "release/:release_id" rb.resources :releases, :only => :index, :controller => :rb_releases, :as => "releases/:project_id" rb.resources :releases, :only => :snapshot, :controller => :rb_releases, :as => "releases/:project_id" - rb.connect "transitions/:project_id", :controller => :rb_stories, :action => 'transitions' end end - diff --git a/init.rb b/init.rb index 725390b98..9f8ee0af8 100755 --- a/init.rb +++ b/init.rb @@ -85,8 +85,7 @@ # Story permissions # :show_stories and :list_stories are implicit in :view_master_backlog permission permission :create_stories, { :rb_stories => :create } - permission :update_stories, { :rb_stories => [:update, :transitions] } - + permission :update_stories, { :rb_stories => :update } # Task permissions # :show_tasks and :list_tasks are implicit in :view_sprints