From 81b6a068320eb82887d897d1cf962293c2e949ec Mon Sep 17 00:00:00 2001 From: puppe1990 Date: Wed, 23 Oct 2024 16:17:09 -0300 Subject: [PATCH] create crud to bling module situations --- .../bling_module_situations_controller.rb | 49 +++++++++++++++++++ .../bling_module_situations/_form.html.erb | 42 ++++++++++++++++ .../bling_module_situations/edit.html.erb | 6 +++ .../bling_module_situations/index.html.erb | 35 +++++++++++++ .../bling_module_situations/new.html.erb | 5 ++ .../bling_module_situations/show.html.erb | 14 ++++++ app/views/shared/_sidebar.html.erb | 12 ++++- config/locales/en.yml | 26 +++++++++- config/locales/pt-BR.yml | 21 ++++++++ config/locales/sidebar.pt-BR.yml | 5 ++ config/routes.rb | 2 + 11 files changed, 214 insertions(+), 3 deletions(-) create mode 100644 app/controllers/bling_module_situations_controller.rb create mode 100644 app/views/bling_module_situations/_form.html.erb create mode 100644 app/views/bling_module_situations/edit.html.erb create mode 100644 app/views/bling_module_situations/index.html.erb create mode 100644 app/views/bling_module_situations/new.html.erb create mode 100644 app/views/bling_module_situations/show.html.erb diff --git a/app/controllers/bling_module_situations_controller.rb b/app/controllers/bling_module_situations_controller.rb new file mode 100644 index 00000000..4573fb75 --- /dev/null +++ b/app/controllers/bling_module_situations_controller.rb @@ -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 diff --git a/app/views/bling_module_situations/_form.html.erb b/app/views/bling_module_situations/_form.html.erb new file mode 100644 index 00000000..46b1d8c0 --- /dev/null +++ b/app/views/bling_module_situations/_form.html.erb @@ -0,0 +1,42 @@ +<%= form_with(model: bling_module_situation, local: true) do |form| %> + <% if bling_module_situation.errors.any? %> +
+

<%= pluralize(bling_module_situation.errors.count, "error") %> prohibited this bling_module_situation from being saved:

+ + +
+ <% end %> + +
+ <%= form.label :module_id %> + <%= form.number_field :module_id %> +
+ +
+ <%= form.label :situation_id %> + <%= form.number_field :situation_id %> +
+ +
+ <%= form.label :name %> + <%= form.text_field :name %> +
+ +
+ <%= form.label :inherited_id %> + <%= form.number_field :inherited_id %> +
+ +
+ <%= form.label :color %> + <%= form.color_field :color %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/bling_module_situations/edit.html.erb b/app/views/bling_module_situations/edit.html.erb new file mode 100644 index 00000000..2270fe15 --- /dev/null +++ b/app/views/bling_module_situations/edit.html.erb @@ -0,0 +1,6 @@ +

<%= t('bling_module_situations.edit') %>

+ +<%= render 'form', bling_module_situation: @bling_module_situation %> + +<%= link_to t('show'), @bling_module_situation %> | +<%= link_to t('back'), bling_module_situations_path %> diff --git a/app/views/bling_module_situations/index.html.erb b/app/views/bling_module_situations/index.html.erb new file mode 100644 index 00000000..2659f629 --- /dev/null +++ b/app/views/bling_module_situations/index.html.erb @@ -0,0 +1,35 @@ +

<%= t('bling_module_situations.title') %>

+ +<%= link_to t('bling_module_situations.new'), new_bling_module_situation_path %> + + + + + + + + + + + + + + <% @bling_module_situations.each do |situation| %> + + + + + + + + + <% end %> + +
<%= BlingModuleSituation.human_attribute_name(:module_id) %><%= BlingModuleSituation.human_attribute_name(:situation_id) %><%= BlingModuleSituation.human_attribute_name(:name) %><%= BlingModuleSituation.human_attribute_name(:inherited_id) %><%= BlingModuleSituation.human_attribute_name(:color) %><%= t('actions') %>
<%= situation.module_id %><%= situation.situation_id %><%= situation.name %><%= situation.inherited_id %> + + <%= situation.color %> + + <%= 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') } %> +
diff --git a/app/views/bling_module_situations/new.html.erb b/app/views/bling_module_situations/new.html.erb new file mode 100644 index 00000000..7c6a8c2f --- /dev/null +++ b/app/views/bling_module_situations/new.html.erb @@ -0,0 +1,5 @@ +

<%= t('bling_module_situations.new') %>

+ +<%= render 'form', bling_module_situation: @bling_module_situation %> + +<%= link_to t('back'), bling_module_situations_path %> diff --git a/app/views/bling_module_situations/show.html.erb b/app/views/bling_module_situations/show.html.erb new file mode 100644 index 00000000..97ec9be1 --- /dev/null +++ b/app/views/bling_module_situations/show.html.erb @@ -0,0 +1,14 @@ +

<%= t('bling_module_situations.title') %>

+ +

<%= BlingModuleSituation.human_attribute_name(:module_id) %>: <%= @bling_module_situation.module_id %>

+

<%= BlingModuleSituation.human_attribute_name(:situation_id) %>: <%= @bling_module_situation.situation_id %>

+

<%= BlingModuleSituation.human_attribute_name(:name) %>: <%= @bling_module_situation.name %>

+

<%= BlingModuleSituation.human_attribute_name(:inherited_id) %>: <%= @bling_module_situation.inherited_id %>

+

+ <%= BlingModuleSituation.human_attribute_name(:color) %>: + + <%= @bling_module_situation.color %> +

+ +<%= link_to t('edit'), edit_bling_module_situation_path(@bling_module_situation) %> | +<%= link_to t('back'), bling_module_situations_path %> diff --git a/app/views/shared/_sidebar.html.erb b/app/views/shared/_sidebar.html.erb index de37db78..e3b975a4 100644 --- a/app/views/shared/_sidebar.html.erb +++ b/app/views/shared/_sidebar.html.erb @@ -196,7 +196,17 @@ <% end %> <% end %> + + + <%= render 'shared/sidebar_dropdown', title: t("bling_module_situations.two"), icon: 'fas fa-cogs' do %> +
  • + <%= link_to t("bling_module_situations.list"), bling_module_situations_path, class: 'nav-link' %> +
  • +
  • + <%= link_to t("bling_module_situations.create"), new_bling_module_situation_path, class: 'nav-link' %> +
  • + <% end %> -<% end %> \ No newline at end of file +<% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 885e30fd..f9c99fea 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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" @@ -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: @@ -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?" diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index 85d387d7..26e450b8 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -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: @@ -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: @@ -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?" diff --git a/config/locales/sidebar.pt-BR.yml b/config/locales/sidebar.pt-BR.yml index f6602aa0..1042bfb3 100644 --- a/config/locales/sidebar.pt-BR.yml +++ b/config/locales/sidebar.pt-BR.yml @@ -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 diff --git a/config/routes.rb b/config/routes.rb index 65ba9601..b6b95a59 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -171,4 +171,6 @@ get 'dashboards/status_summary', to: 'dashboards#status_summary', as: 'dashboards_status_summary' + resources :bling_module_situations + end