Skip to content

Commit

Permalink
Create view and related javascript for staging workflow deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
krauselukas committed Nov 9, 2018
1 parent 77fe170 commit fdd6ae2
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/api/app/assets/javascripts/webui2/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@
//= require webui2/jquery-ui.min.js
//= require webui2/cm2/use-codemirror.js
//= require webui2/package-view_file.js
//= require webui2/staging_workflow.js
9 changes: 9 additions & 0 deletions src/api/app/assets/javascripts/webui2/staging_workflow.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function setSpinnersForDeletion() { // jshint ignore:line
$("#staging-workflow-delete").on('ajax:beforeSend', function(){
$(this).find('.delete-spinner').removeClass('d-none');
});

$("#staging-workflow-delete").on('ajax:complete', function(){
$(this).find('.delete-spinner').addClass('d-none');
});
}
28 changes: 28 additions & 0 deletions src/api/app/views/webui2/webui/staging_workflows/_delete.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
%button.btn.btn-danger{ data: { toggle: 'modal', target: '#delete-staging-workflow' } }
Delete Staging Workflow

.modal.fade{ id: 'delete-staging-workflow', tabindex: -1, role: 'dialog' }
.modal-dialog.modal-dialog-centered{ role: 'document' }
.modal-content
.modal-header
%h5.modal-title
Do you want to delete the staging workflow for #{project.name}?
.modal-body
%p Please confirm deletion of the staging workflow for #{project.name}
= form_tag staging_workflow_path, method: :delete, remote: true, id: 'staging-workflow-delete' do
- if @staging_workflow.staging_projects.any?
%p Check the staging projects you want to be deleted:
- @staging_workflow.staging_projects.each do |staging_project|
.form-check
= check_box_tag 'staging_project_ids[]', staging_project.id, false, class: 'form-check-input'
%label.form-check-label
= staging_project.name
%br
.modal-footer
%i.fas.fa-spinner.fa-spin.delete-spinner.d-none
%button.btn.btn-sm.btn-outline-secondary.px-4{ data: { dismiss: 'modal' } }
Cancel
= submit_tag 'Delete', class: 'btn btn-sm btn-danger px-4'

= content_for :ready_function do
setSpinnersForDeletion();
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
= link_to(edit_staging_workflow_path(@staging_workflow), class: 'nav-link') do
%i.fas.fa-edit.text-info
Edit Staging Workflow
- if policy(@staging_workflow).destroy?
= render(partial: 'webui2/webui/staging_workflows/delete', locals: { project: @project })
%hr

%table.table.table-striped.table-bordered.table-sm.dt-responsive.w-100#staging-projects-datatable
Expand Down

0 comments on commit fdd6ae2

Please sign in to comment.