Skip to content

Commit

Permalink
Merge pull request #393 from Purple-Stock/staging
Browse files Browse the repository at this point in the history
create crud to bling module situations
  • Loading branch information
puppe1990 authored Oct 23, 2024
2 parents 34b70be + 81b6a06 commit 38901ba
Show file tree
Hide file tree
Showing 11 changed files with 214 additions and 3 deletions.
49 changes: 49 additions & 0 deletions app/controllers/bling_module_situations_controller.rb
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
42 changes: 42 additions & 0 deletions app/views/bling_module_situations/_form.html.erb
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 %>
6 changes: 6 additions & 0 deletions app/views/bling_module_situations/edit.html.erb
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 %>
35 changes: 35 additions & 0 deletions app/views/bling_module_situations/index.html.erb
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>
5 changes: 5 additions & 0 deletions app/views/bling_module_situations/new.html.erb
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 %>
14 changes: 14 additions & 0 deletions app/views/bling_module_situations/show.html.erb
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 %>
12 changes: 11 additions & 1 deletion app/views/shared/_sidebar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,17 @@
</li>
<% end %>
<% end %>

<!-- Add this new dropdown menu item after the "Shein" dropdown -->
<%= render 'shared/sidebar_dropdown', title: t("bling_module_situations.two"), icon: 'fas fa-cogs' do %>
<li class="<%= active_nav_item('bling_module_situations', 'index') %>">
<%= link_to t("bling_module_situations.list"), bling_module_situations_path, class: 'nav-link' %>
</li>
<li class="<%= active_nav_item('bling_module_situations', 'new') %>">
<%= link_to t("bling_module_situations.create"), new_bling_module_situation_path, class: 'nav-link' %>
</li>
<% end %>
</ul>
</aside>
</div>
<% end %>
<% end %>
26 changes: 24 additions & 2 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,14 @@ en:
production_updated: "Production was successfully updated."
show:
price_per_piece: "Price per Piece"
production_card:
total_quantity: "Total Quantity"
missing_quantity: "Missing Quantity"
activerecord:
models:
production: "Production"
production_product: "Production Product"
bling_module_situation: "Bling Module Situation"
attributes:
production:
number: "Number"
Expand All @@ -98,6 +102,12 @@ en:
dirty: "Dirty"
error: "Error"
discard: "Discard"
bling_module_situation:
module_id: "Module ID"
situation_id: "Situation ID"
name: "Name"
inherited_id: "Inherited ID"
color: "Color"
errors:
models:
production:
Expand All @@ -107,11 +117,23 @@ en:
helpers:
submit:
update: "Update"
bling_module_situation:
create: "Create Bling Module Situation"
update: "Update Bling Module Situation"
links:
back: "Back"
edit: "Edit"
destroy: "Destroy"
cancel: "Cancel"
confirm: "Are you sure?"
actions:
remove: "Remove"
actions:
remove: "Remove"

bling_module_situations:
title: "Bling Module Situations"
new: "New Bling Module Situation"
edit: "Edit Bling Module Situation"
create_success: "Bling Module Situation was successfully created."
update_success: "Bling Module Situation was successfully updated."
destroy_success: "Bling Module Situation was successfully destroyed."
confirm_destroy: "Are you sure you want to delete this Bling Module Situation?"
21 changes: 21 additions & 0 deletions config/locales/pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ pt-BR:
notions_cost: "Custo de Aviamentos"
fabric_cost: "Custo de Tecido"
# Remove the total_material_cost line
models:
bling_module_situation: "Situação do Módulo Bling"
attributes:
bling_module_situation:
module_id: "ID do Módulo"
situation_id: "ID da Situação"
name: "Nome"
inherited_id: "ID Herdado"
color: "Cor"
actions:
remove_product: "Remover Produto"
errors:
Expand Down Expand Up @@ -232,6 +241,10 @@ pt-BR:
new: Criar %{model}
edit: Editar %{model}
actions: Ações
submit:
bling_module_situation:
create: "Criar Situação do Módulo Bling"
update: "Atualizar Situação do Módulo Bling"
number:
currency:
format:
Expand Down Expand Up @@ -341,3 +354,11 @@ helpers:
price_per_piece: "Preço por Peça"
production_card:
remaining: "Restante"
bling_module_situations:
title: "Situações dos Módulos Bling"
new: "Nova Situação do Módulo Bling"
edit: "Editar Situação do Módulo Bling"
create_success: "Situação do Módulo Bling criada com sucesso."
update_success: "Situação do Módulo Bling atualizada com sucesso."
destroy_success: "Situação do Módulo Bling excluída com sucesso."
confirm_destroy: "Tem certeza que deseja excluir esta Situação do Módulo Bling?"
5 changes: 5 additions & 0 deletions config/locales/sidebar.pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,8 @@ pt-BR:
other: Estimativas de Receita
bling_order_items:
list: Lista de Itens de Pedido Bling
bling_module_situations:
one: Situação
two: Situações Bling
list: Lista de Situações
create: Criar Situação
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,6 @@

get 'dashboards/status_summary', to: 'dashboards#status_summary', as: 'dashboards_status_summary'

resources :bling_module_situations

end

0 comments on commit 38901ba

Please sign in to comment.