Browse Source

Fix bug

master
Norore 4 years ago
parent
commit
fe926e7d30
  1. 90
      app/assets/javascripts/groupe.coffee
  2. 5
      app/controllers/groups_controller.rb
  3. 6
      app/views/groups/_target_fields.html.erb

90
app/assets/javascripts/groupe.coffee

@ -2,48 +2,48 @@
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
$(document).on 'keyup', "form", (event) ->
$("input:text[name='css']").each (index, event) ->
frominput = $(this).next().next()
toinput = $(frominput).next().next()
if $(this).val()
$(frominput).prop('disabled', true)
$(toinput).prop('disabled', true)
else
$(frominput).prop('disabled', false)
$(toinput).prop('disabled', false)
$("input:text[name='from']").each (index, event) ->
cssinput = $(this).prev().prev()
if $(this).val()
$(cssinput).prop('disabled', true)
else
$(cssinput).prop('disabled', false)
$("input:text[name='to']").each (index, event) ->
cssinput = $(this).prev().prev().prev().prev()
if $(this).val()
$(cssinput).prop('disabled', true)
else
$(cssinput).prop('disabled', false)
$("form").ready ->
$("input:text[name='css']").each (index, event) ->
frominput = $(this).next().next()
toinput = $(frominput).next().next()
if $(this).val()
$(frominput).prop('disabled', true)
$(toinput).prop('disabled', true)
else
$(frominput).prop('disabled', false)
$(toinput).prop('disabled', false)
$("input:text[name='from']").each (index, event) ->
cssinput = $(this).prev().prev()
if $(this).val()
$(cssinput).prop('disabled', true)
else
$(cssinput).prop('disabled', false)
$("input:text[name='to']").each (index, event) ->
cssinput = $(this).prev().prev().prev().prev()
if $(this).val()
$(cssinput).prop('disabled', true)
else
$(cssinput).prop('disabled', false)
# $(document).on 'keyup', "form", (event) ->
# $("input:text[name='css']").each (index, event) ->
# frominput = $(this).next().next()
# toinput = $(frominput).next().next()
# if $(this).val()
# $(frominput).prop('disabled', true)
# $(toinput).prop('disabled', true)
# else
# $(frominput).prop('disabled', false)
# $(toinput).prop('disabled', false)
# $("input:text[name='from']").each (index, event) ->
# cssinput = $(this).prev().prev()
# if $(this).val()
# $(cssinput).prop('disabled', true)
# else
# $(cssinput).prop('disabled', false)
# $("input:text[name='to']").each (index, event) ->
# cssinput = $(this).prev().prev().prev().prev()
# if $(this).val()
# $(cssinput).prop('disabled', true)
# else
# $(cssinput).prop('disabled', false)
#
# $("form").ready ->
# $("input:text[name='css']").each (index, event) ->
# frominput = $(this).next().next()
# toinput = $(frominput).next().next()
# if $(this).val()
# $(frominput).prop('disabled', true)
# $(toinput).prop('disabled', true)
# else
# $(frominput).prop('disabled', false)
# $(toinput).prop('disabled', false)
# $("input:text[name='from']").each (index, event) ->
# cssinput = $(this).prev().prev()
# if $(this).val()
# $(cssinput).prop('disabled', true)
# else
# $(cssinput).prop('disabled', false)
# $("input:text[name='to']").each (index, event) ->
# cssinput = $(this).prev().prev().prev().prev()
# if $(this).val()
# $(cssinput).prop('disabled', true)
# else
# $(cssinput).prop('disabled', false)

5
app/controllers/groups_controller.rb

@ -15,7 +15,6 @@ class GroupsController < ApplicationController
end
def edit
@group = Group.find(params[:id])
end
def update
@ -40,8 +39,8 @@ class GroupsController < ApplicationController
def group_params
params.require(:group).permit(
:id, :name, :template_id,
targets_attributes: [:id, :name, :css, :from, :to, :_destroy],
sites_attributes: [:id, :name, :url, :_destroy]
targets_attributes: %i[id name css from to group_id _destroy],
sites_attributes: %i[id name url reference group_id _destroy]
)
end

6
app/views/groups/_target_fields.html.erb

@ -4,13 +4,13 @@
<%= f.text_field :name %>
<%= f.label :css, :css %>:
<%= f.text_field :css, name: :css %>
<%= f.text_field :css %>
<%= f.label :from, :from %>:
<%= f.text_field :from, name: :from %>
<%= f.text_field :from %>
<%= f.label :to, :to %>:
<%= f.text_field :to, name: :to %>
<%= f.text_field :to %>
<%= f.hidden_field :_destroy %>
<%= link_to :delete, "#", class: "remove_fields" %>

Loading…
Cancel
Save