Menu Item Attribute

This commit is contained in:
Nweni
2017-04-20 19:22:30 +06:30
parent d60ee09ff2
commit 037eb1f0f2
6 changed files with 93 additions and 61 deletions

View File

@@ -4,7 +4,7 @@ class Settings::MenuItemAttributesController < ApplicationController
# GET /settings/menu_item_attributes # GET /settings/menu_item_attributes
# GET /settings/menu_item_attributes.json # GET /settings/menu_item_attributes.json
def index def index
@settings_menu_item_attributes = Settings::MenuItemAttribute.all @settings_menu_item_attributes = MenuItemAttribute.all
end end
# GET /settings/menu_item_attributes/1 # GET /settings/menu_item_attributes/1
@@ -14,7 +14,7 @@ class Settings::MenuItemAttributesController < ApplicationController
# GET /settings/menu_item_attributes/new # GET /settings/menu_item_attributes/new
def new def new
@settings_menu_item_attribute = Settings::MenuItemAttribute.new @settings_menu_item_attribute = MenuItemAttribute.new
end end
# GET /settings/menu_item_attributes/1/edit # GET /settings/menu_item_attributes/1/edit
@@ -24,11 +24,11 @@ class Settings::MenuItemAttributesController < ApplicationController
# POST /settings/menu_item_attributes # POST /settings/menu_item_attributes
# POST /settings/menu_item_attributes.json # POST /settings/menu_item_attributes.json
def create def create
@settings_menu_item_attribute = Settings::MenuItemAttribute.new(settings_menu_item_attribute_params) @settings_menu_item_attribute = MenuItemAttribute.new(settings_menu_item_attribute_params)
respond_to do |format| respond_to do |format|
if @settings_menu_item_attribute.save if @settings_menu_item_attribute.save
format.html { redirect_to @settings_menu_item_attribute, notice: 'Menu item attribute was successfully created.' } format.html { redirect_to settings_menu_item_attributes_path, notice: 'Menu item attribute was successfully created.' }
format.json { render :show, status: :created, location: @settings_menu_item_attribute } format.json { render :show, status: :created, location: @settings_menu_item_attribute }
else else
format.html { render :new } format.html { render :new }
@@ -42,7 +42,7 @@ class Settings::MenuItemAttributesController < ApplicationController
def update def update
respond_to do |format| respond_to do |format|
if @settings_menu_item_attribute.update(settings_menu_item_attribute_params) if @settings_menu_item_attribute.update(settings_menu_item_attribute_params)
format.html { redirect_to @settings_menu_item_attribute, notice: 'Menu item attribute was successfully updated.' } format.html { redirect_to settings_menu_item_attribute_path(@settings_menu_item_attribute), notice: 'Menu item attribute was successfully updated.' }
format.json { render :show, status: :ok, location: @settings_menu_item_attribute } format.json { render :show, status: :ok, location: @settings_menu_item_attribute }
else else
format.html { render :edit } format.html { render :edit }
@@ -56,7 +56,7 @@ class Settings::MenuItemAttributesController < ApplicationController
def destroy def destroy
@settings_menu_item_attribute.destroy @settings_menu_item_attribute.destroy
respond_to do |format| respond_to do |format|
format.html { redirect_to settings_menu_item_attributes_url, notice: 'Menu item attribute was successfully destroyed.' } format.html { redirect_to settings_menu_item_attributes_path, notice: 'Menu item attribute was successfully destroyed.' }
format.json { head :no_content } format.json { head :no_content }
end end
end end
@@ -64,11 +64,11 @@ class Settings::MenuItemAttributesController < ApplicationController
private private
# Use callbacks to share common setup or constraints between actions. # Use callbacks to share common setup or constraints between actions.
def set_settings_menu_item_attribute def set_settings_menu_item_attribute
@settings_menu_item_attribute = Settings::MenuItemAttribute.find(params[:id]) @settings_menu_item_attribute = MenuItemAttribute.find(params[:id])
end end
# Never trust parameters from the scary internet, only allow the white list through. # Never trust parameters from the scary internet, only allow the white list through.
def settings_menu_item_attribute_params def settings_menu_item_attribute_params
params.require(:settings_menu_item_attribute).permit(:attribute_type, :name, :value) params.require(:menu_item_attribute).permit(:attribute_type, :name, :value)
end end
end end

View File

@@ -1,4 +1,4 @@
<%= simple_form_for([:settings, @settings_menu_item]) do |f| %> <%= simple_form_for([:settings, @settings_menu_item_attribute]) do |f| %>
<%= f.error_notification %> <%= f.error_notification %>
<div class="form-inputs"> <div class="form-inputs">

View File

@@ -1,6 +1,11 @@
<h1>Editing Settings Menu Item Attribute</h1>
<%= render 'form', settings_menu_item_attribute: @settings_menu_item_attribute %> <div class="span12">
<div class="page-header">
<%= link_to 'Show', @settings_menu_item_attribute %> | <ul class="breadcrumb">
<%= link_to 'Back', settings_menu_item_attributes_path %> <li><a href="<%= root_path %>">Home</a></li>
<li><a href="<%= settings_menu_item_attributes_path %>">Menu Item Attribute</a></li>
<li>Edit</li>
</ul>
</div>
<%= render 'form', employee: @employee %>
</div>

View File

@@ -1,31 +1,35 @@
<p id="notice"><%= notice %></p>
<h1>Settings Menu Item Attributes</h1> <div class="page-header">
<ul class="breadcrumb">
<table> <li><a href="<%= %>">Home</a></li>
<thead> <li>Menu Item Attributes</li>
<tr> <span style="float: right">
<th>Attribute type</th> <%= link_to t('.new', :default => t("helpers.links.new")),new_settings_menu_item_attribute_path,:class => 'btn btn-primary btn-sm' %>
<th>Name</th> </span>
<th>Value</th> </ul>
<th colspan="3"></th> </div>
</tr>
</thead>
<tbody>
<% @settings_menu_item_attributes.each do |settings_menu_item_attribute| %>
<tr>
<td><%= settings_menu_item_attribute.attribute_type %></td>
<td><%= settings_menu_item_attribute.name %></td>
<td><%= settings_menu_item_attribute.value %></td>
<td><%= link_to 'Show', settings_menu_item_attribute %></td>
<td><%= link_to 'Edit', edit_settings_menu_item_attribute_path(settings_menu_item_attribute) %></td>
<td><%= link_to 'Destroy', settings_menu_item_attribute, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
<br> <br>
<div class="card">
<table class="table table-striped">
<thead>
<tr>
<th>Attribute type</th>
<th>Name</th>
<th>Value</th>
</tr>
</thead>
<%= link_to 'New Settings Menu Item Attribute', new_settings_menu_item_attribute_path %> <tbody>
<% @settings_menu_item_attributes.each do |settings_menu_item_attribute| %>
<tr>
<td><%= link_to settings_menu_item_attribute.attribute_type, settings_menu_item_attribute_path(settings_menu_item_attribute) %></td>
<td><%= settings_menu_item_attribute.name %></td>
<td><%= settings_menu_item_attribute.value %></td>
<td><%= link_to 'Edit', edit_settings_menu_item_attribute_path(settings_menu_item_attribute) %>
| <%= link_to 'Destroy', settings_menu_item_attribute_path(settings_menu_item_attribute), method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
</div>

View File

@@ -1,5 +1,11 @@
<h1>New Settings Menu Item Attribute</h1>
<%= render 'form', settings_menu_item_attribute: @settings_menu_item_attribute %> <div class="span12">
<div class="page-header">
<%= link_to 'Back', settings_menu_item_attributes_path %> <ul class="breadcrumb">
<li><a href="<%= root_path %>">Home</a></li>
<li><a href="<%= settings_menu_item_attributes_path %>">Menu Item Attribute</a></li>
<li>New</li>
</ul>
</div>
<%= render 'form', settings_menu_item_attribute: @settings_menu_item_attribute %>
</div>

View File

@@ -1,19 +1,36 @@
<p id="notice"><%= notice %></p>
<p> <div class="page-header">
<strong>Attribute type:</strong> <ul class="breadcrumb">
<%= @settings_menu_item_attribute.attribute_type %> <li><a href="<%= %>">Home</a></li>
</p> <li>Settings</li>
<li>Menu Item Attribute</li>
<span style="float: right">
</span>
</ul>
</div>
<div class="card">
<div class="card-block">
<h4 class="card-title">Menu Item Attribute</h4>
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>Value</th>
<th>Created At</th>
<th>Action</th>
</tr>
</thead>
<p> <tbody>
<strong>Name:</strong> <tr>
<%= @settings_menu_item_attribute.name %> <td><%= @settings_menu_item_attribute.name %></td>
</p> <td><%= @settings_menu_item_attribute.value rescue "-" %></td>
<td><%=l @settings_menu_item_attribute.created_at, format: :short %></td>
<td><%= link_to 'Edit', edit_settings_menu_item_attribute_path(@settings_menu_item_attribute, @settings_menu_item_attribute) %></td>
</tr>
</tbody>
</table>
</div>
</div>
<p> </div>
<strong>Value:</strong>
<%= @settings_menu_item_attribute.value %>
</p>
<%= link_to 'Edit', edit_settings_menu_item_attribute_path(@settings_menu_item_attribute) %> |
<%= link_to 'Back', settings_menu_item_attributes_path %>