Merge pull request #468 from abf/rosa-build:ajax_remove_project_from_repository
remove a project from repository with ajax
This commit is contained in:
commit
1cdd7c7153
3
Gemfile
3
Gemfile
|
@ -98,6 +98,9 @@ gem 'sitemap_generator'
|
|||
|
||||
gem 'codemirror-rails', '~> 4.5'
|
||||
|
||||
source 'https://rails-assets.org' do
|
||||
gem 'rails-assets-notifyjs'
|
||||
end
|
||||
|
||||
group :production do
|
||||
gem 'airbrake'
|
||||
|
|
|
@ -51,6 +51,7 @@ GIT
|
|||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
remote: https://rails-assets.org/
|
||||
specs:
|
||||
RedCloth (4.2.9)
|
||||
actionmailer (4.1.9)
|
||||
|
@ -370,6 +371,7 @@ GEM
|
|||
bundler (>= 1.3.0, < 2.0)
|
||||
railties (= 4.1.9)
|
||||
sprockets-rails (~> 2.0)
|
||||
rails-assets-notifyjs (0.3.2)
|
||||
rails3-generators (1.0.0)
|
||||
railties (>= 3.0.0)
|
||||
rails3-jquery-autocomplete (1.0.15)
|
||||
|
@ -635,6 +637,7 @@ DEPENDENCIES
|
|||
puma
|
||||
rack-throttle (~> 0.3.0)
|
||||
rails (= 4.1.9)
|
||||
rails-assets-notifyjs!
|
||||
rails3-generators
|
||||
rails3-jquery-autocomplete
|
||||
rake
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
RosaABF.controller 'RepositoryProjectsController', ['$scope', '$http', '$location', ($scope, $http, $location) ->
|
||||
RosaABF.controller 'RepositoryProjectsController', ['$scope', '$http', '$location', 'confirmMessage', ($scope, $http, $location, confirmMessage) ->
|
||||
|
||||
$scope.added = $('#added').val()
|
||||
$scope.platform_id = $('#platform_id').val()
|
||||
|
@ -51,4 +51,13 @@ RosaABF.controller 'RepositoryProjectsController', ['$scope', '$http', '$locatio
|
|||
$scope.goToPage = (number) ->
|
||||
$location.search('page', number)
|
||||
|
||||
$scope.removeProject = (project) ->
|
||||
return false unless confirmMessage.show()
|
||||
$http.delete(project.remove_path).success (data) ->
|
||||
$.notify(data.message, 'success')
|
||||
|
||||
$scope.projects = _.reject($scope.projects, (pr) ->
|
||||
return pr.id is project.id
|
||||
)
|
||||
false
|
||||
]
|
|
@ -27,11 +27,14 @@
|
|||
|
||||
//= require zeroclipboard
|
||||
|
||||
//= require notifyjs
|
||||
//= require notifyjs/styles/bootstrap/notify-bootstrap
|
||||
|
||||
//= require lib/Chart
|
||||
//= require lib/bootstrap-typeahead
|
||||
//= require lib/custom-bootstrap-typeahead
|
||||
//= require extra/highlight
|
||||
|
||||
//= require extra/highlight
|
||||
//= require extra/pull
|
||||
//= require extra/scroller
|
||||
//= require extra/fork
|
||||
|
|
|
@ -140,7 +140,11 @@ class Platforms::RepositoriesController < Platforms::BaseController
|
|||
end
|
||||
if params[:project_id].present?
|
||||
ProjectToRepository.where(project_id: params[:project_id], repository_id: @repository.id).destroy_all
|
||||
redirect_to platform_repository_path(@platform, @repository), notice: t('flash.repository.project_removed')
|
||||
message = t('flash.repository.project_removed')
|
||||
respond_to do |format|
|
||||
format.html {redirect_to platform_repository_path(@platform, @repository), notice: message}
|
||||
format.json {render json: { message: message }}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ div ng-controller='RepositoryProjectsController'
|
|||
th= t("activerecord.attributes.project.description")
|
||||
th
|
||||
tbody ng-hide='processing'
|
||||
tr ng-repeat='project in projects'
|
||||
tr ng-repeat='project in projects' ng-cloak = true
|
||||
|
||||
td
|
||||
i.fa ng-class='project.visibility_class'
|
||||
|
@ -35,10 +35,9 @@ div ng-controller='RepositoryProjectsController'
|
|||
td
|
||||
a ng-href='{{project.add_path}}' ng-show='project.add_path'
|
||||
= t('layout.add')
|
||||
a[ng-href = '{{project.remove_path}}'
|
||||
ng-show = 'project.remove_path'
|
||||
data-method = 'delete'
|
||||
data-confirm = t('layout.confirm')]
|
||||
a.pointer[ng-href = ''
|
||||
ng-show = 'project.remove_path'
|
||||
ng-click = 'removeProject(project)']
|
||||
span.glyphicon.glyphicon-remove
|
||||
|
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
json.total_items @total_items
|
||||
|
||||
json.projects @projects do |project|
|
||||
json.id project.id
|
||||
json.visibility_class fa_visibility_icon(project)
|
||||
json.path project_path(project.name_with_owner)
|
||||
json.name project.name_with_owner
|
||||
|
|
Loading…
Reference in New Issue