-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from mlibrary/identifiers
Identifiers
- Loading branch information
Showing
68 changed files
with
1,808 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* This is a manifest file that'll be compiled into application.css, which will include all the files | ||
* listed below. | ||
* | ||
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's | ||
* vendor/assets/stylesheets directory can be referenced here using a relative path. | ||
* | ||
* You're free to add application-wide styles to this file and they'll appear at the bottom of the | ||
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS | ||
* files in this directory. Styles in this file should be added after the last require_* statement. | ||
* It is generally better to create a new file per style scope. | ||
* | ||
* Then, remove all the *= require and *= require_tree statements from the Sass file. Instead, | ||
* use @import to import Sass files. | ||
* | ||
* Do not use *= require in Sass or your other stylesheets will not be able to access the | ||
* Bootstrap mixins and variables. | ||
*/ | ||
|
||
// Custom bootstrap variables must be set or imported *before* bootstrap. | ||
@import "bootstrap"; | ||
|
||
/* | ||
* Configuration | ||
* Sass: Autoprefixer | ||
* Bootstrap requires the use of Autoprefixer. | ||
* Autoprefixer adds vendor prefixes to CSS rules using values from Can I Use. | ||
* | ||
* If you are using bootstrap with Rails, autoprefixer is set up for you automatically. | ||
* Otherwise, please consult the Autoprefixer documentation. | ||
* | ||
* Sass: Individual components | ||
* By default all of Bootstrap is imported. | ||
* | ||
* You can also import components explicitly. To start with a full list of modules | ||
* copy _bootstrap.scss file into your assets as _bootstrap-custom.scss. Then | ||
* comment out components you do not want from _bootstrap-custom. In the application Sass file, | ||
* replace @import 'bootstrap' with: | ||
* | ||
* @import 'bootstrap-custom'; | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'open-uri' | ||
|
||
class IdentifiersController < ApplicationController | ||
before_action :set_identifier, only: %i[show edit update destroy] | ||
|
||
def index | ||
@identifiers = Identifier.filter(filtering_params(params)).order(name: :asc).page(params[:page]) | ||
end | ||
|
||
def show | ||
@aliases = @identifier.aliases | ||
end | ||
|
||
def new | ||
@identifier = Identifier.new | ||
@aliases = Identifier.all | ||
@alias_id = 0 | ||
end | ||
|
||
def edit | ||
@aliases = Identifier.all | ||
@alias_id = @identifier.id | ||
end | ||
|
||
def create # rubocop:disable Metrics/MethodLength, Metrics/AbcSize | ||
create_identifier_params = identifier_params | ||
create_identifier_params[:uuid] = if create_identifier_params[:uuid].present? | ||
Identifier.find(create_identifier_params[:uuid]).uuid | ||
else | ||
Uuid.generator | ||
end | ||
@identifier = Identifier.new(create_identifier_params) | ||
respond_to do |format| | ||
if @identifier.save | ||
format.html { redirect_to identifier_path(@identifier), notice: 'Identifier was successfully created.' } | ||
format.json { render :show, status: :created, location: @identifier } | ||
else | ||
format.html do | ||
@aliases = Identifier.all | ||
if @identifier.uuid.identifiers.count.positive? | ||
@alias_id = identifier_params[:uuid] | ||
else | ||
@identifier.uuid.destroy | ||
@identifier.uuid = nil | ||
@aliases_id = 0 | ||
end | ||
render :new | ||
end | ||
format.json { render json: @identifier.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
def update # rubocop:disable Metrics/PerceivedComplexity, Metrics/MethodLength, Metrics/AbcSize | ||
update_identifier_params = identifier_params | ||
update_identifier_params[:uuid] = if update_identifier_params[:uuid].present? | ||
Identifier.find(update_identifier_params[:uuid]).uuid | ||
else | ||
Uuid.generator | ||
end | ||
unless @identifier.uuid == update_identifier_params[:uuid] | ||
@identifier.uuid.identifiers.delete(@identifier) | ||
@identifier.uuid = nil | ||
end | ||
respond_to do |format| | ||
if @identifier.update(update_identifier_params) | ||
format.html { redirect_to identifier_path(@identifier), notice: 'Identifier was successfully updated.' } | ||
format.json { render :show, status: :ok, location: @identifier } | ||
else | ||
format.html do | ||
@aliases = Identifier.all | ||
if @identifier.uuid.identifiers.count.positive? | ||
@alias_id = identifier_params[:uuid] | ||
else | ||
@identifier.uuid.destroy | ||
@identifier.uuid = nil | ||
@aliases_id = 0 | ||
end | ||
render :edit | ||
end | ||
format.json { render json: @identifier.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
def destroy # rubocop:disable Metrics/AbcSize | ||
@identifier.uuid.identifiers.delete(@identifier) | ||
@identifier.uuid.destroy unless @identifier.uuid.identifiers.count.positive? | ||
@identifier.uuid = nil | ||
@identifier.destroy | ||
respond_to do |format| | ||
format.html { redirect_to identifiers_url, notice: 'Identifier was successfully destroyed.' } | ||
format.json { head :no_content } | ||
end | ||
end | ||
|
||
private | ||
|
||
def set_identifier | ||
@identifier = Identifier.find(params[:id]) | ||
end | ||
|
||
def identifier_params | ||
params.require(:identifier).permit(:name, :uuid) | ||
end | ||
|
||
def filtering_params(params) | ||
params.slice(:name_like) | ||
end | ||
end |
Oops, something went wrong.