Merge branch 'master' of https://github.com/biosistemika/scinote-web into zz_tooltip_settings_enable_sci2663

Merging to update db, so i dont have to docker-clean my whole environment 2 times to switch between this branch and up to date ones
This commit is contained in:
Zanz2 2018-08-31 11:42:26 +02:00
commit d4aa5e60a2
28 changed files with 92 additions and 45 deletions

View file

@ -1 +1 @@
1.14.3
1.14.4

View file

@ -262,4 +262,9 @@ var HelperModule = (function(){
$('.modal').modal('hide');
});
});
})();
/* Fix .selectpicker (bootstrap-select) to work with Turbolinks 5.x */
$(document).on('turbolinks:load', function() {
$(window).trigger('load.bs.select.data-api');
});
})();

View file

@ -115,6 +115,7 @@
RepositoryItemEditForm.prototype.parseToFormObject = function(tableID, selectedRecord) {
var formData = this.formData;
var formDataObj = new FormData();
var removeFileColumns = [];
formDataObj.append('request_url', $(tableID).data('current-uri'));
formDataObj.append('repository_row_id', $(selectedRecord).attr('id'));
@ -125,18 +126,25 @@
} else {
var colId = element.replace('colId-', '');
var $el = $('#' + element);
// don't save anything if element is not visible
if($el.length == 0) {
return true;
}
if($el.attr('type') === 'file') {
// don't save anything if element is deleted
// handle deleting of element
if($el.attr('remove') === "true") {
return true;
removeFileColumns.push(colId);
formDataObj.append('repository_cells[' + colId + ']', null);
} else {
formDataObj.append('repository_cells[' + colId + ']',
getFileValue($el));
}
formDataObj.append('repository_cells[' + colId + ']',
getFileValue($el));
} else if(value.length > 0) {
} else if(value.length >= 0) {
formDataObj.append('repository_cells[' + colId + ']', value);
}
}
});
formDataObj.append('remove_file_columns', JSON.stringify(removeFileColumns));
return formDataObj;
}
/**

View file

@ -270,7 +270,7 @@
function _uploadedAssetPreview(asset, i) {
var html = '<div class="panel panel-default panel-step-attachment-new">';
html += '<div class="panel-heading">';
html += '<span class="fas fa-file"></span>';
html += '<span class="fas fa-paperclip"></span>';
html += '<%= I18n.t 'assets.drag_n_drop.file_label' %>';
html += '<div class="pull-right">';
html += '<a data-item-id="' + i + '" href="#">';
@ -442,7 +442,7 @@
function _uploadedAssetPreview(asset, i) {
var html = '<div class="panel panel-default panel-result-attachment-new">';
html += '<div class="panel-heading">';
html += '<span class="fas fa-file"></span>';
html += '<span class="fas fa-paperclip"></span>';
html += '<%= I18n.t 'assets.drag_n_drop.file_label' %>';
html += '<div class="pull-right">';
html += '<a data-item-id="' + i + '" href="#">';

View file

@ -164,15 +164,20 @@
}
function initializeModalsToggle() {
$("[data-trigger='invite-users']").on('click', function() {
$("[data-trigger='invite-users']").on('click', function(event) {
var id = $(this).attr('data-modal-id');
event.preventDefault();
event.stopPropagation();
$('[data-role=invite-users-modal][data-id=' + id + ']')
.modal('show');
});
}
$('[data-role=invite-users-modal]').each(function() {
initializeModal($(this));
$(document).on('turbolinks:load', function() {
$('[data-role=invite-users-modal]').each(function() {
initializeModal($(this));
});
initializeModalsToggle();
});
initializeModalsToggle();
}());

View file

@ -1,5 +1,3 @@
//= require users/settings/teams/invite_users_modal
(function() {
'use strict';

View file

@ -23,7 +23,7 @@ class ActivitiesController < ApplicationController
activities = current_user.last_activities
.page(page)
.per(Constants::ACTIVITY_AND_NOTIF_SEARCH_LIMIT)
unless activities.last_page?
unless activities.blank? || activities.last_page?
more_url = url_for(
activities_url(
format: :json,

View file

@ -34,6 +34,8 @@ module Api
end
def health
User.new && Team.new && Project.new
User.first if params[:db]
render plain: 'RUNNING'
end

View file

@ -134,7 +134,7 @@ class RepositoryRowsController < ApplicationController
existing.delete
end
elsif existing.value_type == 'RepositoryAssetValue'
next if value.blank?
existing.value.destroy && next if remove_file_columns_params.include?(key)
if existing.value.asset.update(file: value)
existing.value.asset.created_by = current_user
existing.value.asset.last_modified_by = current_user
@ -145,6 +145,7 @@ class RepositoryRowsController < ApplicationController
}
end
else
existing.value.destroy && next if value == ''
existing.value.data = value
if existing.value.save
record_annotation_notification(@record, existing)
@ -156,17 +157,12 @@ class RepositoryRowsController < ApplicationController
end
end
else
next if value == ''
# Looks like it is a new cell, so we need to create new value, cell
# will be created automatically
next if create_cell_value(@record, key, value, errors).nil?
end
end
# Clean up empty cells, not present in updated record
@record.repository_cells.each do |cell|
next if cell.value_type == 'RepositoryListValue'
cell.value.destroy unless cell_params
.key?(cell.repository_column_id.to_s)
end
else
@record.repository_cells.each { |c| c.value.destroy }
end
@ -369,6 +365,10 @@ class RepositoryRowsController < ApplicationController
params.permit(repository_cells: {}).to_h[:repository_cells]
end
def remove_file_columns_params
JSON.parse(params.fetch(:remove_file_columns) { '[]' })
end
def selected_params
params.permit(selected_rows: []).to_h[:selected_rows]
end

View file

@ -16,12 +16,14 @@ module Api
attr_accessor :core_api_token_ttl
attr_accessor :core_api_token_iss
attr_accessor :azure_ad_apps
attr_accessor :core_api_v1_preview
def initialize
@core_api_sign_alg = 'HS256'
@core_api_token_ttl = 30.minutes
@core_api_token_iss = 'SciNote'
@azure_ad_apps = {}
@core_api_v1_preview = false
end
end
end

View file

@ -39,7 +39,7 @@
<% if result.asset.is_image? %>
<span class="fas fa-image"></span>
<% else %>
<span class="fas fa-file"></span>
<span class="fas fa-paperclip"></span>
<% end %>
<% elsif result.is_text %>
<span class="fas fa-asterisk"></span>

View file

@ -17,12 +17,12 @@
<% if can_manage_protocol_in_module?(@protocol) %>
<li>
<a class="btn-open-file" href="#" data-action="load-from-file" data-import-url="<%= load_from_file_protocol_path(@protocol, format: :json) %>">
<span class="fas fa-file"></span>&nbsp;<%= t("my_modules.protocols.buttons.load_protocol_from_file") %>
<span class="fas fa-paperclip"></span>&nbsp;<%= t("my_modules.protocols.buttons.load_protocol_from_file") %>
<input type="file" value="" accept=".eln" data-turbolinks="false">
</a>
</li>
<% else %>
<li class="disabled"><a href="#"><span class="fas fa-file"></span>&nbsp;<%= t("my_modules.protocols.buttons.load_protocol_from_file") %></a></li>
<li class="disabled"><a href="#"><span class="fas fa-paperclip"></span>&nbsp;<%= t("my_modules.protocols.buttons.load_protocol_from_file") %></a></li>
<% end %>
</ul>
</div>

View file

@ -61,7 +61,7 @@
<ul class="dropdown-menu">
<li>
<a class="btn-link-alt btn-default-link btn-open-file" <%= can_create_protocols_in_repository?(@current_team) ? 'data-action="import"' : 'disabled="disabled"' %>>
<span class="fas fa-file"></span>
<span class="fas fa-paperclip"></span>
<span class="hidden-xs"><%= t("protocols.index.import_alt") %></span>
<input type="file" value="" accept=".eln" data-role="import-file-input"
data-team-id="<%= @current_team.id %>"
@ -70,8 +70,8 @@
</a>
</li>
<li>
<%= link_to "#modal-import-json-protocol", data: { toggle: 'modal', remote: true } do %>
<span class="fas fa-file"></span>
<%= link_to "#modal-import-json-protocol", data: { toggle: 'modal' } do %>
<span class="fas fa-paperclip"></span>
<span class="hidden-xs"><%= t("protocols.index.import_json") %></span>
<% end %>
</li>
@ -85,7 +85,7 @@
<div class="btn-group" role="group">
<a class="btn btn-default" data-action="archive" data-url="<%= archive_protocols_path %>">
<span class="fas fa-briefcase"></span>
<span class="fas fa-archive"></span>
<span class="hidden-xs">&nbsp;<%= t("protocols.index.archive_action") %></span>
</a>
</div>

View file

@ -8,8 +8,8 @@
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
<li><a href="#" data-sort="desc"><%= t('projects.reports.new.nav_sort_desc') %></a></li>
<li><a href="#" data-sort="asc"><%= t('projects.reports.new.nav_sort_asc') %></a></li>
<li><a href="#" data-sort="desc" data-turbolinks="false"><%= t('projects.reports.new.nav_sort_desc') %></a></li>
<li><a href="#" data-sort="asc" data-turbolinks="false"><%= t('projects.reports.new.nav_sort_asc') %></a></li>
</ul>
</div>
@ -21,7 +21,7 @@
<div class="form-group">
<%= hidden_field_tag "html", "" %>
<%= link_to "", class: "btn btn-default", remote: true, id: "get-report-pdf" do %>
<span class="fas fa-file-download"></span>
<span class="fas fa-upload"></span>
<span class="hidden-xs"><%=t "projects.reports.new.nav_pdf" %></span>
<% end %>
</div>
@ -30,6 +30,8 @@
<button
onclick="$('#savePDFtoInventory').modal('show')"
class="btn btn-default">
<span class="fas fa-save">
</span>
<%=t 'projects.reports.new.save_PDF_to_inventory'%>
</button>

View file

@ -182,7 +182,7 @@
match_case: @search_case, utf8: '✓',
search_id: @search_id}.to_query %>">
<span class="badge pull-right"><%= @asset_search_count %></span>
<span class="fas fa-file"></span>
<span class="fas fa-paperclip"></span>
<%= t'Assets' %>
</a>
</li>

View file

@ -6,7 +6,7 @@
<% if wopi_file?(asset) %>
<%= file_extension_icon(asset) %>
<% else %>
<span class="fas fa-file"></span>
<span class="fas fa-paperclip"></span>
<% end %>
<% end %>
<%= render partial: "search/results/partials/asset_text.html.erb", locals: { asset: asset, query: search_query } %>

View file

@ -8,7 +8,7 @@
<% if result.asset.is_image? %>
<span class="fas fa-image"></span>
<% else %>
<span class="fas fa-file"></span>
<span class="fas fa-paperclip"></span>
<% end %>
<% end %>
<%= render partial: "search/results/partials/result_text.html.erb", locals: { result: result, query: search_query, target: nil } %>

View file

@ -14,7 +14,7 @@
id="new-step-assets-tab"
onClick="dragNdropAssetsInit('steps')">
<a href="#new-step-assets" data-toggle="tab" data-no-turbolink="true">
<span class="fas fa-file"></span>
<span class="fas fa-paperclip"></span>
<%= t("protocols.steps.new.tab_assets") %>
</a>
</li>

View file

@ -1,6 +1,6 @@
<div class="panel panel-default panel-step-attachment">
<div class="panel-heading">
<span class="fas fa-file"></span>
<span class="fas fa-paperclip"></span>
<%= t("protocols.steps.new.asset_panel_title") %>
<div class="pull-right">
<% unless ff.object.file.exists? && ff.object.locked? %>

View file

@ -93,7 +93,7 @@
<div class="panel-body">
<div class="col-xs-24 col-sm-12">
<a href="#" class="btn btn-primary pull-right row" data-trigger="invite-users"
data-modal-id="team-invite-users-modal" data-remote="true">
data-modal-id="team-invite-users-modal">
<span class="fas fa-plus"></span>
<%= t("users.settings.teams.edit.add_user") %>
</a>
@ -137,4 +137,5 @@
<%= render partial: 'users/settings/user_teams/destroy_user_team_modal.html.erb' %>
<%= stylesheet_link_tag 'datatables' %>
<%= javascript_include_tag 'users/settings/teams/show' %>
<%= javascript_include_tag 'users/settings/teams/invite_users_modal' %>
<span data-hook="team-bottom"></span>

View file

@ -9,6 +9,8 @@ Api.configure do |config|
config.core_api_token_iss = ENV['CORE_API_TOKEN_ISS']
end
config.core_api_v1_preview = true if ENV['CORE_API_V1_PREVIEW']
vars = ENV.select { |name, _| name =~ /^[[:alnum:]]*_AZURE_AD_APP_ID/ }
vars.each do |name, value|
app_name = name.sub('_AZURE_AD_APP_ID', '')

View file

@ -28,6 +28,8 @@ Rails.application.config.assets.precompile +=
Rails.application.config.assets.precompile +=
%w(users/settings/teams/add_user_modal.js)
Rails.application.config.assets.precompile += %w(users/settings/teams/show.js)
Rails.application.config.assets.precompile +=
%w(users/settings/teams/invite_users_modal.js)
Rails.application.config.assets.precompile += %w(my_modules/activities.js)
Rails.application.config.assets.precompile += %w(my_modules/protocols.js)
Rails.application.config.assets.precompile +=

View file

@ -61,7 +61,7 @@ class Extends
repository_asset_value: :asset]
# List of implemented core API versions
API_VERSIONS = ['20170715']
API_VERSIONS = %w(20170715 v1)
# Array used for injecting names of additional authentication methods for API
API_PLUGABLE_AUTH_METHODS = [:azure_jwt_auth]

View file

@ -7,7 +7,8 @@ Rails.application.configure do
config.log_tags,
silence: [
# Silence WickedPDF rendering in logs
%r{/projects/[0-9]*/reports/generate.pdf}
%r{/projects/[0-9]*/reports/generate.pdf},
'/api/health'
]
)
end

View file

@ -540,8 +540,10 @@ Rails.application.routes.draw do
get 'health', to: 'api#health'
get 'status', to: 'api#status'
post 'auth/token', to: 'api#authenticate'
namespace :v1 do
resources :teams, only: %i(index show) do
if Api.configuration.core_api_v1_preview
namespace :v1 do
resources :teams, only: %i(index show) do
end
end
end
end

View file

@ -2,7 +2,7 @@ version: '2'
services:
db:
container_name: scinote_db_development
image: postgres:9.4
image: postgres:9.6
volumes:
- scinote_development_postgres:/var/lib/postgresql/data

View file

@ -1,6 +1,18 @@
require 'rails_helper'
describe Api::ApiController, type: :controller do
describe 'GET #health' do
before do
get :health
end
it 'Returns HTTP success and with correct text' do
expect(response).to be_success
expect(response).to have_http_status(200)
expect(response.body).to match('RUNNING')
end
end
describe 'GET #status' do
before do
get :status
@ -17,7 +29,9 @@ describe Api::ApiController, type: :controller do
expect(hash_body).to match(
'message' => I18n.t('api.core.status_ok'),
'versions' => [{ 'version' => '20170715',
'baseUrl' => '/api/20170715/' }]
'baseUrl' => '/api/20170715/' },
{ 'version' => 'v1',
'baseUrl' => '/api/v1/' }]
)
end
end

View file

@ -5,6 +5,9 @@ require 'database_cleaner'
require 'devise'
require_relative 'support/controller_macros'
ENV['RAILS_ENV'] = 'test'
ENV['CORE_API_V1_PREVIEW'] = 'true'
require File.expand_path('../../config/environment', __FILE__)
# Prevent database truncation if the environment is production
abort('The Rails environment is running in production mode!') if Rails.env.production?