mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-11-08 07:21:03 +08:00
adds manage columns page [fixes SCI-2218]
This commit is contained in:
parent
35afc06cbd
commit
3be3c00574
13 changed files with 203 additions and 10 deletions
|
|
@ -227,7 +227,7 @@ var HelperModule = (function(){
|
||||||
'<button type="button" class="close" ' +
|
'<button type="button" class="close" ' +
|
||||||
'data-dismiss="alert" aria-label="Close">' +
|
'data-dismiss="alert" aria-label="Close">' +
|
||||||
'<span aria-hidden="true">×</span></button>' +
|
'<span aria-hidden="true">×</span></button>' +
|
||||||
'<span class="glyphicon' + glyphSign + '"></span>' +
|
'<span class="glyphicon' + glyphSign + '"></span> ' +
|
||||||
'<span>' + message + '</span>' +
|
'<span>' + message + '</span>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'</div>';
|
'</div>';
|
||||||
|
|
|
||||||
|
|
@ -1514,7 +1514,6 @@ var RepositoryDatatable = (function(global) {
|
||||||
initSorting();
|
initSorting();
|
||||||
toggleColumnVisibility();
|
toggleColumnVisibility();
|
||||||
initEditColumns();
|
initEditColumns();
|
||||||
initDeleteColumns();
|
|
||||||
});
|
});
|
||||||
$('#repository-columns-dropdown').on('show.bs.dropdown', function() {
|
$('#repository-columns-dropdown').on('show.bs.dropdown', function() {
|
||||||
loadColumnsNames();
|
loadColumnsNames();
|
||||||
|
|
|
||||||
47
app/assets/javascripts/repository_columns/index.js
Normal file
47
app/assets/javascripts/repository_columns/index.js
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
(function() {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
function initEditCoumnModal() {}
|
||||||
|
|
||||||
|
function initDeleteColumnModal() {
|
||||||
|
$('[data-action="destroy"]').on('click', function() {
|
||||||
|
var element = $(this);
|
||||||
|
var modal_html = $("#deleteRepositoryColumn");
|
||||||
|
$.get(element.closest('li').attr('data-destroy-url'), function(data) {
|
||||||
|
modal_html.find('.modal-body').html(data.html)
|
||||||
|
.promise()
|
||||||
|
.done(function() {
|
||||||
|
modal_html.modal('show');
|
||||||
|
initSubmitAction(modal_html, $(modal_html.find('form')));
|
||||||
|
});
|
||||||
|
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function initSubmitAction(modal, form) {
|
||||||
|
modal.find('[data-action="delete"]').on('click', function() {
|
||||||
|
form.submit();
|
||||||
|
modal.modal('hide')
|
||||||
|
animateSpinner();
|
||||||
|
processResponse(form);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function processResponse(form) {
|
||||||
|
form.on('ajax:success', function(e, data) {
|
||||||
|
$('.list-group-item[data-id="' + data.id + '"]').remove();
|
||||||
|
HelperModule.flashAlertMsg(data.message, 'success');
|
||||||
|
animateSpinner(null, false);
|
||||||
|
}).on('ajax:error', function(e, xhr, status, error) {
|
||||||
|
HelperModule.flashAlertMsg(error.message, 'danger');
|
||||||
|
animateSpinner(null, false);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
initEditCoumnModal();
|
||||||
|
initDeleteColumnModal();
|
||||||
|
})
|
||||||
|
})()
|
||||||
30
app/assets/stylesheets/themes/repositories.scss
Normal file
30
app/assets/stylesheets/themes/repositories.scss
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
@import "constants";
|
||||||
|
|
||||||
|
.repository-columns-header {
|
||||||
|
margin-top: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.repository-columns-body {
|
||||||
|
margin-top: 50px
|
||||||
|
}
|
||||||
|
|
||||||
|
.repository-columns-body .list-group-item {
|
||||||
|
padding: 28px;
|
||||||
|
|
||||||
|
.controlls {
|
||||||
|
margin-top: -18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
span {
|
||||||
|
margin-top: -10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.glyphicon-trash {
|
||||||
|
margin-right: 10px;
|
||||||
|
color: $color-milano-red;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
@import 'constants';
|
@import "constants";
|
||||||
@import "mixins";
|
@import "mixins";
|
||||||
@import "main_navigation";
|
@import "main_navigation";
|
||||||
@import "buttons";
|
@import "buttons";
|
||||||
|
@import "repositories";
|
||||||
|
|
||||||
/** Layout **/
|
/** Layout **/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,15 @@
|
||||||
class RepositoryColumnsController < ApplicationController
|
class RepositoryColumnsController < ApplicationController
|
||||||
include InputSanitizeHelper
|
include InputSanitizeHelper
|
||||||
|
|
||||||
before_action :load_vars, except: :create
|
before_action :load_vars, except: %i(create index)
|
||||||
before_action :load_vars_nested, only: :create
|
before_action :load_vars_nested, only: %i(create index)
|
||||||
before_action :check_create_permissions, only: :create
|
before_action :check_create_permissions, only: :create
|
||||||
before_action :check_manage_permissions, except: :create
|
before_action :check_manage_permissions, except: %i(create index)
|
||||||
|
before_action :load_repository_columns, only: :index
|
||||||
|
|
||||||
|
def index
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@repository_column = RepositoryColumn.new(repository_column_params)
|
@repository_column = RepositoryColumn.new(repository_column_params)
|
||||||
|
|
@ -77,6 +82,7 @@ class RepositoryColumnsController < ApplicationController
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@del_repository_column = @repository_column.dup
|
@del_repository_column = @repository_column.dup
|
||||||
|
column_id = @repository_column.id
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json do
|
format.json do
|
||||||
if @repository_column.destroy
|
if @repository_column.destroy
|
||||||
|
|
@ -85,9 +91,17 @@ class RepositoryColumnsController < ApplicationController
|
||||||
params[:repository_column][:column_index],
|
params[:repository_column][:column_index],
|
||||||
current_user
|
current_user
|
||||||
)
|
)
|
||||||
render json: { status: :ok }
|
render json: {
|
||||||
|
message: t('libraries.repository_columns.destroy.success_flash',
|
||||||
|
name: @del_repository_column.name),
|
||||||
|
id: column_id,
|
||||||
|
status: :ok
|
||||||
|
}
|
||||||
else
|
else
|
||||||
render json: { status: :unprocessable_entity }
|
render json: {
|
||||||
|
message: t('libraries.repository_columns.destroy.error_flash'),
|
||||||
|
status: :unprocessable_entity
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -107,6 +121,10 @@ class RepositoryColumnsController < ApplicationController
|
||||||
render_404 unless @repository
|
render_404 unless @repository
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def load_repository_columns
|
||||||
|
@repository_columns = @repository.repository_columns.order(:created_at)
|
||||||
|
end
|
||||||
|
|
||||||
def check_create_permissions
|
def check_create_permissions
|
||||||
render_403 unless can_create_repository_columns?(@repository.team)
|
render_403 unless can_create_repository_columns?(@repository.team)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
16
app/views/repository_columns/_delete_column_modal.html.erb
Normal file
16
app/views/repository_columns/_delete_column_modal.html.erb
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
<div class="modal fade" id="deleteRepositoryColumn" tabindex="-1" role="dialog" aria-labelledby="deleteRepositoryColumnLabel">
|
||||||
|
<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.modal_delete_column.title") %></h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-primary" data-action="delete"><%= t("repositories.modal_delete_column.delete") %></button>
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal"><%= t("general.cancel")%></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
<%= bootstrap_form_for @repository_column,
|
||||||
|
url: repository_repository_column_path(@repository,
|
||||||
|
@repository_column),
|
||||||
|
remote: true,
|
||||||
|
method: :delete,
|
||||||
|
data: { role: "destroy-repository-column-form",
|
||||||
|
id: @repository_column.id} do |f| %>
|
||||||
|
<%= f.hidden_field :column_index, value: column_index %>
|
||||||
|
<p><%= t("repositories.modal_delete_column.message", column: @repository_column.name) %></p>
|
||||||
|
<div class="alert alert-danger" role="alert">
|
||||||
|
<span class="glyphicon glyphicon-exclamation-sign"></span>
|
||||||
|
|
||||||
|
<%= t("repositories.modal_delete_column.alert_heading") %>
|
||||||
|
<ul>
|
||||||
|
<li><%= t("repositories.modal_delete_column.alert_line_1", nr: @repository_column.repository_cells.count) %></li>
|
||||||
|
<li><%= t("repositories.modal_delete_column.alert_line_2") %></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
50
app/views/repository_columns/index.html.erb
Normal file
50
app/views/repository_columns/index.html.erb
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
<% provide(:head_title, t('libraries.repository_columns.head_title', repository: @repository.name)) %>
|
||||||
|
<div>
|
||||||
|
<div class="repository-columns-header container">
|
||||||
|
<div class="row">
|
||||||
|
<%= link_to t('libraries.repository_columns.index.back_to_repository_html', repository: @repository.name),
|
||||||
|
repository_path(@repository) %>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6 text-left page-title">
|
||||||
|
<h2><strong><%=t 'libraries.repository_columns.index.manage_column' %></strong></h2>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 text-right">
|
||||||
|
<button class="btn btn-primary btn-lg">
|
||||||
|
<span class="glyphicon glyphicon-plus"></span> <%=t 'libraries.repository_columns.index.new_column' %>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="repository-columns-body container">
|
||||||
|
<ul class="list-group"
|
||||||
|
data-repository-id="<%= @repository.id %>">
|
||||||
|
<% if @repository_columns.length.zero? %>
|
||||||
|
<li class="list-group-item text-center">
|
||||||
|
<strong><%=t 'libraries.repository_columns.index.no_column' %></strong>
|
||||||
|
</li>
|
||||||
|
<% else %>
|
||||||
|
<% @repository_columns.each do |column| %>
|
||||||
|
<% cache column do %>
|
||||||
|
<li class="list-group-item"
|
||||||
|
data-id="<%= column.id %>"
|
||||||
|
data-destroy-url="<%= repository_columns_destroy_html_path(@repository, column) %>">
|
||||||
|
<span class="pull-left"><%= column.name %></span>
|
||||||
|
<span class="controlls pull-right">
|
||||||
|
<span class="glyphicon glyphicon-trash"
|
||||||
|
aria-hidden="true"
|
||||||
|
data-action="destroy"></span>
|
||||||
|
<button class="btn btn-primary" data-action="edit">
|
||||||
|
<%=t 'libraries.repository_columns.index.edit_column'%>
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= render partial: 'delete_column_modal' %>
|
||||||
|
<%= javascript_include_tag "repository_columns/index", "data-turbolinks-track" => true %>
|
||||||
|
|
@ -83,6 +83,7 @@ Rails.application.config.assets.precompile +=
|
||||||
Rails.application.config.assets.precompile +=
|
Rails.application.config.assets.precompile +=
|
||||||
%w(repositories/my_module_repository.js)
|
%w(repositories/my_module_repository.js)
|
||||||
Rails.application.config.assets.precompile += %w(activities/index.js)
|
Rails.application.config.assets.precompile += %w(activities/index.js)
|
||||||
|
Rails.application.config.assets.precompile += %w(repository_columns/index.js)
|
||||||
|
|
||||||
# Libraries needed for Handsontable formulas
|
# Libraries needed for Handsontable formulas
|
||||||
Rails.application.config.assets.precompile += %w(lodash.js)
|
Rails.application.config.assets.precompile += %w(lodash.js)
|
||||||
|
|
|
||||||
|
|
@ -985,6 +985,18 @@ en:
|
||||||
no_records_unassigned_flash: "No items were unassigned from task"
|
no_records_unassigned_flash: "No items were unassigned from task"
|
||||||
default_column: 'Name'
|
default_column: 'Name'
|
||||||
|
|
||||||
|
libraries:
|
||||||
|
repository_columns:
|
||||||
|
head_title: '%{repository} | Manage Columns'
|
||||||
|
destroy:
|
||||||
|
success_flash: "Column %{name} was successfully deleted."
|
||||||
|
error_flash: "Something went wrong! Please try again later."
|
||||||
|
index:
|
||||||
|
manage_column: "Manage Columns"
|
||||||
|
new_column: "New"
|
||||||
|
no_column: "No columns"
|
||||||
|
edit_column: "Edit"
|
||||||
|
back_to_repository_html: "<span class='glyphicon glyphicon-chevron-left'></span> Back to %{repository}"
|
||||||
repository_row:
|
repository_row:
|
||||||
modal_info:
|
modal_info:
|
||||||
head_title: "Information for item '%{repository_row}'"
|
head_title: "Information for item '%{repository_row}'"
|
||||||
|
|
|
||||||
|
|
@ -468,11 +468,11 @@ Rails.application.routes.draw do
|
||||||
to: 'repository_rows#delete_records',
|
to: 'repository_rows#delete_records',
|
||||||
as: 'delete_records',
|
as: 'delete_records',
|
||||||
defaults: { format: 'json' }
|
defaults: { format: 'json' }
|
||||||
post 'repository_columns/:id/destroy_html',
|
get 'repository_columns/:id/destroy_html',
|
||||||
to: 'repository_columns#destroy_html',
|
to: 'repository_columns#destroy_html',
|
||||||
as: 'columns_destroy_html'
|
as: 'columns_destroy_html'
|
||||||
|
|
||||||
resources :repository_columns, only: %i(create edit update destroy)
|
resources :repository_columns, only: %i(index create edit update destroy)
|
||||||
resources :repository_rows, only: %i(create edit update)
|
resources :repository_rows, only: %i(create edit update)
|
||||||
member do
|
member do
|
||||||
post 'parse_sheet'
|
post 'parse_sheet'
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue