-
-
Notifications
You must be signed in to change notification settings - Fork 11
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 #393 from Purple-Stock/staging
create crud to bling module situations
- Loading branch information
Showing
11 changed files
with
214 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
class BlingModuleSituationsController < ApplicationController | ||
before_action :set_bling_module_situation, only: [:show, :edit, :update, :destroy] | ||
|
||
def index | ||
@bling_module_situations = BlingModuleSituation.all.order(:module_id, :situation_id) | ||
end | ||
|
||
def show | ||
end | ||
|
||
def new | ||
@bling_module_situation = BlingModuleSituation.new | ||
end | ||
|
||
def create | ||
@bling_module_situation = BlingModuleSituation.new(bling_module_situation_params) | ||
if @bling_module_situation.save | ||
redirect_to @bling_module_situation, notice: t('bling_module_situations.create_success') | ||
else | ||
render :new | ||
end | ||
end | ||
|
||
def edit | ||
end | ||
|
||
def update | ||
if @bling_module_situation.update(bling_module_situation_params) | ||
redirect_to @bling_module_situation, notice: t('bling_module_situations.update_success') | ||
else | ||
render :edit | ||
end | ||
end | ||
|
||
def destroy | ||
@bling_module_situation.destroy | ||
redirect_to bling_module_situations_url, notice: t('bling_module_situations.destroy_success') | ||
end | ||
|
||
private | ||
|
||
def set_bling_module_situation | ||
@bling_module_situation = BlingModuleSituation.find(params[:id]) | ||
end | ||
|
||
def bling_module_situation_params | ||
params.require(:bling_module_situation).permit(:situation_id, :name, :module_id, :inherited_id, :color) | ||
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,42 @@ | ||
<%= form_with(model: bling_module_situation, local: true) do |form| %> | ||
<% if bling_module_situation.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(bling_module_situation.errors.count, "error") %> prohibited this bling_module_situation from being saved:</h2> | ||
|
||
<ul> | ||
<% bling_module_situation.errors.full_messages.each do |message| %> | ||
<li><%= message %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div class="field"> | ||
<%= form.label :module_id %> | ||
<%= form.number_field :module_id %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= form.label :situation_id %> | ||
<%= form.number_field :situation_id %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= form.label :name %> | ||
<%= form.text_field :name %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= form.label :inherited_id %> | ||
<%= form.number_field :inherited_id %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= form.label :color %> | ||
<%= form.color_field :color %> | ||
</div> | ||
|
||
<div class="actions"> | ||
<%= form.submit %> | ||
</div> | ||
<% 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,6 @@ | ||
<h1><%= t('bling_module_situations.edit') %></h1> | ||
|
||
<%= render 'form', bling_module_situation: @bling_module_situation %> | ||
|
||
<%= link_to t('show'), @bling_module_situation %> | | ||
<%= link_to t('back'), bling_module_situations_path %> |
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,35 @@ | ||
<h1><%= t('bling_module_situations.title') %></h1> | ||
|
||
<%= link_to t('bling_module_situations.new'), new_bling_module_situation_path %> | ||
|
||
<table class="table table-striped"> | ||
<thead> | ||
<tr> | ||
<th><%= BlingModuleSituation.human_attribute_name(:module_id) %></th> | ||
<th><%= BlingModuleSituation.human_attribute_name(:situation_id) %></th> | ||
<th><%= BlingModuleSituation.human_attribute_name(:name) %></th> | ||
<th><%= BlingModuleSituation.human_attribute_name(:inherited_id) %></th> | ||
<th><%= BlingModuleSituation.human_attribute_name(:color) %></th> | ||
<th><%= t('actions') %></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% @bling_module_situations.each do |situation| %> | ||
<tr> | ||
<td><%= situation.module_id %></td> | ||
<td><%= situation.situation_id %></td> | ||
<td><%= situation.name %></td> | ||
<td><%= situation.inherited_id %></td> | ||
<td> | ||
<span class="color-swatch" style="background-color: <%= situation.color %>; display: inline-block; width: 20px; height: 20px; margin-right: 5px;"></span> | ||
<%= situation.color %> | ||
</td> | ||
<td> | ||
<%= link_to t('show'), situation %> | ||
<%= link_to t('edit'), edit_bling_module_situation_path(situation) %> | ||
<%= link_to t('destroy'), situation, method: :delete, data: { confirm: t('bling_module_situations.confirm_destroy') } %> | ||
</td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> |
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,5 @@ | ||
<h1><%= t('bling_module_situations.new') %></h1> | ||
|
||
<%= render 'form', bling_module_situation: @bling_module_situation %> | ||
|
||
<%= link_to t('back'), bling_module_situations_path %> |
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,14 @@ | ||
<h1><%= t('bling_module_situations.title') %></h1> | ||
|
||
<p><strong><%= BlingModuleSituation.human_attribute_name(:module_id) %>:</strong> <%= @bling_module_situation.module_id %></p> | ||
<p><strong><%= BlingModuleSituation.human_attribute_name(:situation_id) %>:</strong> <%= @bling_module_situation.situation_id %></p> | ||
<p><strong><%= BlingModuleSituation.human_attribute_name(:name) %>:</strong> <%= @bling_module_situation.name %></p> | ||
<p><strong><%= BlingModuleSituation.human_attribute_name(:inherited_id) %>:</strong> <%= @bling_module_situation.inherited_id %></p> | ||
<p> | ||
<strong><%= BlingModuleSituation.human_attribute_name(:color) %>:</strong> | ||
<span class="color-swatch" style="background-color: <%= @bling_module_situation.color %>; display: inline-block; width: 20px; height: 20px; margin-right: 5px;"></span> | ||
<%= @bling_module_situation.color %> | ||
</p> | ||
|
||
<%= link_to t('edit'), edit_bling_module_situation_path(@bling_module_situation) %> | | ||
<%= link_to t('back'), bling_module_situations_path %> |
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 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