mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
enable deleting basil images
This commit is contained in:
parent
9a36b581e1
commit
7ee780f021
@ -322,6 +322,7 @@ class BasilController < ApplicationController
|
||||
user: current_user
|
||||
)
|
||||
@commission.update(saved_at: DateTime.current)
|
||||
render json: { success: true }, status: 200
|
||||
end
|
||||
|
||||
def delete
|
||||
@ -330,6 +331,7 @@ class BasilController < ApplicationController
|
||||
user: current_user
|
||||
)
|
||||
@commission.destroy!
|
||||
render json: { success: true }, status: 200
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@ -157,6 +157,8 @@ class ContentController < ApplicationController
|
||||
@random_image_including_private_pool_cache = ImageUpload.where(
|
||||
user_id: current_user.id,
|
||||
).group_by { |image| [image.content_type, image.content_id] }
|
||||
@basil_images = BasilCommission.where(entity: @content)
|
||||
.where.not(saved_at: nil)
|
||||
|
||||
respond_to do |format|
|
||||
format.html { render 'content/edit', locals: { content: @content } }
|
||||
|
||||
@ -190,7 +190,7 @@ function commission_basil(style) {
|
||||
<% else %>
|
||||
<%= link_to "Save", '#', class: 'purple-text js-save-commission', data: { endpoint: basil_save_path(commission) } %>
|
||||
<% end %>
|
||||
<%= link_to "Delete", basil_delete_path(commission), class: 'red-text right right-align', style: 'margin-right: 0' %>
|
||||
<%= link_to "Delete", '#', class: 'js-delete-commission red-text right right-align', style: 'margin-right: 0', data: { endpoint: basil_delete_path(commission) } %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -217,5 +217,19 @@ $(document).ready(function() {
|
||||
console.log(data);
|
||||
});
|
||||
});
|
||||
|
||||
$('.js-delete-commission').click(function() {
|
||||
$(this).text('Deleting...');
|
||||
$(this).closest('.card').hide();
|
||||
|
||||
var delete_endpoint = $(this).data('endpoint');
|
||||
$.ajax({
|
||||
url: delete_endpoint,
|
||||
type: 'DELETE',
|
||||
success: function(result) {
|
||||
$(this).closest('.card').hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
<% end %>
|
||||
@ -30,3 +30,31 @@
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if @basil_images.any? %>
|
||||
<% @basil_images.each do |commission| %>
|
||||
<div class="row">
|
||||
<div class="col s12 m3">
|
||||
<%= link_to commission.image, class: 'z-depth-1 hoverable right', target: '_new' do %>
|
||||
<%= image_tag commission.image, style: 'max-width: 100%' %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="col s12 m9">
|
||||
<h5>
|
||||
Generated with <%= link_to 'Basil', basil_path %>
|
||||
<small class="grey-text">
|
||||
<%# Filesize.from("#{commission.image.src_file_size}B").to_f('KB').round(2) %> <!--KB-->
|
||||
</small>
|
||||
</h5>
|
||||
<div>
|
||||
<%= link_to 'Open', commission.image, class: 'btn white black-text', target: '_new' %>
|
||||
<%= link_to 'Delete', basil_delete_path(commission),
|
||||
class: 'btn white black-text js-remove-image',
|
||||
method: 'delete',
|
||||
remote: true,
|
||||
data: { confirm: "Are you sure? This can't be undone." } %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
Loading…
Reference in New Issue
Block a user