Commit dae0cb6b authored by gwendal's avatar gwendal
Browse files

refactorization + bugfix add mac address

parent 4e5f310b
......@@ -6,7 +6,12 @@ class ServiceMacsController < WebController
# GET /service_macs/new
# GET /service_macs/new.json
def new
@service_mac = ServiceMac.new(service_id: params[:service_id])
begin
service = Service.find(params[:service_id])
@service_mac.service = service
@service_mac.addr = "00:00:00:00:00:00"
rescue
end
respond_to do |format|
format.html
format.json { render json: @service_mac }
......
......@@ -29,7 +29,7 @@
<div class="col-md-12">
<h3> <%= t('invoicing.invoicing_details') %></h3>
<% if can? :edit, ServiceSaleTemplate %>
<% if can? :create, ServiceSaleTemplate %>
<%= link_to t("service_sale_template.new.link"), new_service_sale_template_path(service: @service) %>
<% end %>
<%= render "table_service_sale_templates" %>
......
......@@ -17,13 +17,17 @@
<%= f.input :password, as: :string, readonly: true %>
<%= pre_submit_button(f, :regenerate_password, t('services.edit.edit_technical.generate_new_password')) %>
<% end %>
<% if @service.authenticate_by_mac? %>
<% @service.service_macs.each do |service_mac| %>
<%= f.simple_fields_for :service_macs, service_mac do |service_mac_form| %>
<%= service_mac_form.input :addr %>
<div class="service_macs">
<b><%= t('service_macs.index.title') %> :</b>
<% if can? :create, ServiceMac %>
<%= link_to t("service_macs.new.title"), new_service_mac_path(service_id: @service) %>
<% end %>
<% end %>
<%= render 'table_service_mac' %>
</div>
<% end %>
<%# <% form_block.call(f) unless form_block.nil? %>
<%= f.input(
......@@ -32,6 +36,7 @@
hint: I18n.t("simple_form.hint.expired_at")
)%>
<%= f.full_error :service_ips, {class: 'alert alert-error', id: 'flash_error'} %>
<div class="form-actions">
<%= f.button :submit %>
......
......@@ -32,33 +32,13 @@
<% if @service.authenticate_by_mac? %>
<div class="service_macs">
<b><%= t('service_macs.index.title') %> :</b>
<br />
<% unless @service.service_macs.empty? %>
<table class="table" id="t_list_mac">
<% @service.service_macs.each do |service_mac| %>
<tr>
<td>
<%= service_mac.addr %>
</td>
<td>
<%= link_to(
t('service_macs.destroy.link'),
service_mac,
method: :delete,
data: { confirm: 'Are you sure?' }
) %>
</td>
</tr>
<% end %>
</table>
<% if can? :create, ServiceMac %>
<%= link_to t("service_macs.new.title"), new_service_mac_path(service_id: @service) %>
<% end %>
<% if @new_service_mac and can? :create, @new_service_mac then %>
<b><%= t('service_macs.new.title') %> :</b>
<div class="small_form">
<%= render partial: 'service_macs/form', locals: {service_mac: @new_service_mac, show_service: false} %>
</div>
<% unless @service.service_macs.empty? %>
<%= render 'table_service_mac' %>
<% end %>
</p>
</div>
<% end %>
<p class="service_first_started_at">
......
<table class="table">
<tbody>
<% @service.service_macs.each do |service_mac| %>
<tr>
<td><%= service_mac.addr %></td>
<td><%= link_to t('service_macs.destroy.link'), service_mac, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment