This repository has been archived by the owner on Jun 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
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 #267 from omu/develop
Merge develop into master
- Loading branch information
Showing
31 changed files
with
1,060 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# frozen_string_literal: true | ||
|
||
class LanguagesController < ApplicationController | ||
include Pagy::Backend | ||
|
||
before_action :set_language, only: %i[show edit update destroy] | ||
|
||
def index | ||
languages = Language.all | ||
|
||
@pagy, @languages = if params[:term].present? | ||
pagy(languages.search(params[:term])) | ||
else | ||
pagy(languages) | ||
end | ||
end | ||
|
||
def show; end | ||
|
||
def new | ||
@language = Language.new | ||
end | ||
|
||
def create | ||
@language = Language.new(language_params) | ||
@language.save ? redirect_to(@language, notice: t('.success')) : render(:new) | ||
end | ||
|
||
def edit; end | ||
|
||
def update | ||
@language.update(language_params) ? redirect_to(@language, notice: t('.success')) : render(:edit) | ||
end | ||
|
||
def destroy | ||
@language.destroy ? redirect_to(languages_path, notice: t('.success')) : redirect_with('warning') | ||
end | ||
|
||
private | ||
|
||
def set_language | ||
@language = Language.find(params[:id]) | ||
end | ||
|
||
def language_params | ||
params.require(:language).permit(:name, :iso, :yoksis_code) | ||
end | ||
end |
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,22 @@ | ||
# frozen_string_literal: true | ||
|
||
class Language < ApplicationRecord | ||
# search | ||
include PgSearch | ||
pg_search_scope( | ||
:search, | ||
against: %i[name iso yoksis_code], | ||
using: { tsearch: { prefix: true } } | ||
) | ||
|
||
# validations | ||
validates :name, presence: true, uniqueness: true | ||
validates :iso, presence: true, uniqueness: true | ||
validates :yoksis_code, uniqueness: true, allow_nil: true | ||
|
||
# callbacks | ||
before_save do | ||
self.name = name.capitalize_all | ||
self.iso = iso.upcase_tr | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<div class='row'> | ||
<div class='col-sm-12'> | ||
<div class='card'> | ||
<div class='card-header'> | ||
<%= fa_icon 'calendar' %> | ||
<strong><%= form_title %></strong> | ||
</div> | ||
<div class='card-body'> | ||
<%= simple_form_for(language) do |f| %> | ||
<div class='row'> | ||
<div class='form-group col-sm-12'> | ||
<%= f.error_notification %> | ||
</div> | ||
<div class='form-group col-sm-4'> | ||
<%= f.input :name, required: true %> | ||
</div> | ||
<div class='form-group col-sm-4'> | ||
<%= f.input :iso, required: true %> | ||
</div> | ||
<div class='form-group col-sm-4'> | ||
<%= f.input :yoksis_code, required: true %> | ||
</div> | ||
<div class='form-group col-sm-12'> | ||
<%= f.button :submit, class: 'btn btn-outline-success btn-sm' %> | ||
<%= link_to_back(:back) %> | ||
</div> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
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 @@ | ||
<%= render 'form', language: @language, form_title: t('.form_title') %> |
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,51 @@ | ||
<div class='alert alert-light'> | ||
<%= link_to_new new_language_path, t('.new_language_link') %> | ||
</div> | ||
|
||
<div class='row'> | ||
<div class='col-lg-12'> | ||
<div class='card'> | ||
<div class='card-header'> | ||
<%= fa_icon 'language', text: t('.card_header') %> | ||
</div> | ||
<div class='card-body'> | ||
<%= form_tag languages_path, method: :get do %> | ||
<div class="form-group"> | ||
<%= text_field_tag 'term', params[:term], placeholder: t('.name'), class: 'form-control' %> | ||
</div> | ||
<%= submit_tag t('search'), class: 'btn btn-primary' %> | ||
<% end %> | ||
<hr \> | ||
<table class='table table-responsive-sm table-striped'> | ||
<thead> | ||
<tr> | ||
<th><%= t('.name') %></th> | ||
<th><%= t('.iso') %></th> | ||
<th><%= t('.yoksis_code') %></th> | ||
<th><%= t('actions') %></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% @languages.each do |language| %> | ||
<tr> | ||
<td><%= language.name %></td> | ||
<td><%= language.iso %></td> | ||
<td><%= language.yoksis_code %></td> | ||
<td> | ||
<%= link_to_show(language_path(language)) %> | ||
<%= link_to_edit(edit_language_path(language)) %> | ||
<%= link_to_destroy(language) %> | ||
</td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
<nav aria-label='pagination'> | ||
<ul class='pagination justify-content-center'> | ||
<%== pagy_nav_bootstrap(@pagy) %> | ||
</ul> | ||
</nav> | ||
</div> | ||
</div> |
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 @@ | ||
<%= render 'form', language: @language, form_title: t('.form_title') %> |
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,36 @@ | ||
<div class="row"> | ||
<div class="col-sm-12"> | ||
<div class="card"> | ||
<div class="card-header"> | ||
<%= fa_icon 'language' %><strong><%= @language.name %></strong> | ||
<div class="card-header-actions"> | ||
<%= link_to_edit(edit_language_path(@language)) %> | ||
<%= link_to_destroy(@language) %> | ||
</div> | ||
</div> | ||
|
||
<div class="card-body"> | ||
<table class="table table-responsive-sm"> | ||
<tbody> | ||
<tr> | ||
<td><%= t('.name') %></td> | ||
<td><%= @language.name %></td> | ||
</tr> | ||
<tr> | ||
<td><%= t('.iso') %></td> | ||
<td><%= @language.iso %></td> | ||
</tr> | ||
<tr> | ||
<td><%= t('.yoksis_code') %></td> | ||
<td><%= @language.yoksis_code %></td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
|
||
<div class="card-footer"> | ||
<%= link_to_back(languages_path) %> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
en: | ||
activerecord: | ||
attributes: | ||
language: &language_attributes | ||
name: Name | ||
iso: ISO Code | ||
yoksis_code: YOKSIS Code | ||
helpers: | ||
submit: | ||
language: | ||
create: Create Language | ||
update: Update Language | ||
languages: | ||
common: | ||
languages: Languages | ||
show: | ||
<<: *language_attributes | ||
index: | ||
<<: *language_attributes | ||
new_language_link: Create a New Language | ||
card_header: Languages | ||
new: | ||
form_title: Create a Language | ||
edit: | ||
form_title: Update the Language | ||
update: | ||
success: Language successfully updated. | ||
create: | ||
success: Language successfully created. | ||
destroy: | ||
success: Language successfully deleted! | ||
warning: Language can not be deleted. |
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,32 @@ | ||
tr: | ||
activerecord: | ||
attributes: | ||
language: &language_attributes | ||
name: Ad | ||
iso: ISO Kodu | ||
yoksis_code: YOKSIS Kodu | ||
helpers: | ||
submit: | ||
language: | ||
create: Dil Oluştur | ||
update: Dil Güncelle | ||
languages: | ||
common: | ||
languages: Diller | ||
show: | ||
<<: *language_attributes | ||
index: | ||
<<: *language_attributes | ||
new_language_link: Yeni Dil Oluştur | ||
card_header: Diller | ||
new: | ||
form_title: Dil Oluştur | ||
edit: | ||
form_title: Dil Güncelle | ||
update: | ||
success: Dil başarıyla güncellendi. | ||
create: | ||
success: Dil başarıyla oluşturuldu. | ||
destroy: | ||
success: Dil başarıyla silindi! | ||
warning: Dil silinemedi. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class CreateLanguages < ActiveRecord::Migration[5.2] | ||
def change | ||
create_table :languages do |t| | ||
t.string :name, null: false, unique: true | ||
t.string :iso, null: false, unique: true | ||
t.integer :yoksis_code | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
Oops, something went wrong.