mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-03 19:24:48 +08:00
Added remove repository modal logic. [SCI-1269]
This commit is contained in:
parent
791bb934ca
commit
cdaac6a01b
5 changed files with 43 additions and 7 deletions
19
app/assets/javascripts/repositories/index.js
Normal file
19
app/assets/javascripts/repositories/index.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
(function() {
|
||||
'use strict';
|
||||
|
||||
// Show modal for repository deletion
|
||||
$(document).on('click', '#delete-repo-option', function() {
|
||||
var url = $(this).attr('href');
|
||||
$.ajax({
|
||||
method: 'GET',
|
||||
url: url,
|
||||
dataType: 'json'
|
||||
}).done(function(xhr, settings, data) {
|
||||
$('body').append($.parseHTML(data.responseJSON.html));
|
||||
$('#delete-repo-modal').modal('show', {
|
||||
backdrop: true,
|
||||
keyboard: false
|
||||
});
|
||||
});
|
||||
});
|
||||
})();
|
|
@ -6,6 +6,19 @@ class RepositoriesController < ApplicationController
|
|||
render('repositories/index')
|
||||
end
|
||||
|
||||
def destroy_modal
|
||||
@repository = Repository.find(params[:repository_id])
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
render json: {
|
||||
html: render_to_string(
|
||||
partial: 'delete_repository_modal.html.erb'
|
||||
)
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@repo = Repository.find(params[:id])
|
||||
@repo.destroy if @repo
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<div class="modal fade" id="deleteRepoModal" tabindex="-1" role="dialog">
|
||||
<div class="modal fade" id="delete-repo-modal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title"><%= t("repositories.index.modal_delete.title_html", name: "ASD") %></h4>
|
||||
<h4 class="modal-title"><%= t("repositories.index.modal_delete.title_html", name: @repository.name) %></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p><%= t("repositories.index.modal_delete.message_html", name: "ASD") %></p>
|
||||
<p><%= t("repositories.index.modal_delete.message_html", name: @repository.name) %></p>
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<span class="glyphicon glyphicon-exclamation-sign"></span>
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
|||
</div>
|
||||
<div class="modal-footer">
|
||||
<%= link_to t('repositories.index.modal_delete.delete'),
|
||||
team_repository_path(id: -1),
|
||||
team_repository_path(id: @repository),
|
||||
id: "confirm-repo-delete",
|
||||
method: :delete,
|
||||
remote: true,
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<% provide(:head_title, t("repositories.index.head_title")) %>
|
||||
|
||||
<% if current_team %>
|
||||
<%= render partial: "repositories/delete_repository_modal" %>
|
||||
<%= render partial: "repositories/breadcrumbs.html.erb", locals: { teams: @teams, current_team: current_team, type: @type } %>
|
||||
|
||||
<!-- Nav tabs -->
|
||||
|
@ -49,7 +48,10 @@
|
|||
</li>
|
||||
<li role="separator" class="divider"></li>
|
||||
<li>
|
||||
<%= link_to t('repositories.index.options_dropdown.delete'), "#deleteRepoModal", class: "delete-repo-option", data: {toggle: "modal", href: team_repository_path(id: repo)} %>
|
||||
<%= link_to t('repositories.index.modal_delete.delete'),
|
||||
team_repository_destroy_modal_path(repository_id: repo),
|
||||
id: "delete-repo-option",
|
||||
remote: true %>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -123,7 +123,9 @@ Rails.application.routes.draw do
|
|||
as: 'file_expired'
|
||||
|
||||
resources :teams do
|
||||
resources :repositories, only: [:index, :edit, :destroy]
|
||||
resources :repositories, only: [:index, :destroy] do
|
||||
get 'destroy_modal', to: 'repositories#destroy_modal'
|
||||
end
|
||||
resources :samples, only: [:new, :create]
|
||||
resources :sample_types, except: [:show, :new] do
|
||||
get 'sample_type_element', to: 'sample_types#sample_type_element'
|
||||
|
|
Loading…
Reference in a new issue