forked from saurabh/orbit4-5
Role Fields working
This commit is contained in:
parent
d80c5eb0d8
commit
40aa1adbfc
|
@ -98,21 +98,21 @@ function inputAppendLength() {
|
|||
function setData(l, type, ol) {
|
||||
var fields = $('#info').length ? "member_profile_field" : $('#sub_role').length ? "sub_role[attribute_fields]" : "role[attribute_fields]",
|
||||
data = {
|
||||
_add_more: ["add_more_" +l, fields+"["+type+"][add_more]"],
|
||||
_calendar: ["calendar_" +l, fields+"["+type+"][calendar]"],
|
||||
_cross_lang: ["cross_lang_" +l, fields+"["+type+"][cross_lang]"],
|
||||
_disabled: ["disabled_" +l, fields+"[disabled]"],
|
||||
_format: ["format_" +l, fields+"["+type+"][format]"],
|
||||
_initial: ["initial_" +l, fields+"["+type+"][initial]"],
|
||||
_is_range: ["is_range_" +l, fields+"["+type+"][is_range]"],
|
||||
_key: ["key_" +l, fields+"[key]"],
|
||||
_markup: fields+"[markup]",
|
||||
_option_list: ["option_list_"+l+"_"+ol, fields+"["+type+"][option_list]["+ol+"]", "option_list_"+ol],
|
||||
_placeholder: ["placeholder_" +l, fields+"["+type+"][placeholder]"],
|
||||
_title_translations: ["title_translations_" +l, fields+"[title_translations]"],
|
||||
_to_delete: ["to_delete_" +l, fields+"[to_delete]"],
|
||||
_to_search: ["to_search_" +l, fields+"[to_search]"],
|
||||
_to_show: ["to_show_" +l, fields+"[to_show]"],
|
||||
_add_more: ["add_more_" +l, fields+"["+l+"]["+type+"][add_more]"],
|
||||
_calendar: ["calendar_" +l, fields+"["+l+"]["+type+"][calendar]"],
|
||||
_cross_lang: ["cross_lang_" +l, fields+"["+l+"]["+type+"][cross_lang]"],
|
||||
_disabled: ["disabled_" +l, fields+"["+l+"][disabled]"],
|
||||
_format: ["format_" +l, fields+"["+l+"]["+type+"][format]"],
|
||||
_initial: ["initial_" +l, fields+"["+l+"]["+type+"][initial]"],
|
||||
_is_range: ["is_range_" +l, fields+"["+l+"]["+type+"][is_range]"],
|
||||
_key: ["key_" +l, fields+"["+l+"][key]"],
|
||||
_markup: fields+"["+l+"][markup]",
|
||||
_option_list: ["option_list_"+l+"_"+ol, fields+"["+l+"]["+type+"][option_list]["+ol+"]", "option_list_"+ol],
|
||||
_placeholder: ["placeholder_" +l, fields+"["+l+"]["+type+"][placeholder]"],
|
||||
_title_translations: ["title_translations_" +l, fields+"["+l+"][title_translations]"],
|
||||
_to_delete: ["to_delete_" +l, fields+"["+l+"][to_delete]"],
|
||||
_to_search: ["to_search_" +l, fields+"["+l+"][to_search]"],
|
||||
_to_show: ["to_show_" +l, fields+"["+l+"][to_show]"],
|
||||
};
|
||||
return data;
|
||||
}
|
||||
|
@ -488,4 +488,4 @@ $(function() {
|
|||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
|
@ -1,5 +1,7 @@
|
|||
class Admin::RolesController < OrbitMemberController
|
||||
before_action :set_role, only: [:show, :edit , :update, :destroy]
|
||||
before_action :set_attribute, only: [:role_field]
|
||||
helper Admin::AttributeValuesViewHelper
|
||||
|
||||
def index
|
||||
@roles = Role.all.asc("_id").entries
|
||||
|
@ -29,12 +31,25 @@ class Admin::RolesController < OrbitMemberController
|
|||
end
|
||||
|
||||
def update
|
||||
if @role.update_attributes(role_params)
|
||||
@role.role_fields.each{|t| t.destroy if t["to_delete"] == true}
|
||||
redirect_to admin_roles_url
|
||||
if params[:role][:attribute_fields]
|
||||
role_params[:attribute_fields].each do |a|
|
||||
@field_name = 'role'
|
||||
field_status = a.last[:id].present?
|
||||
@attribute_field = AttributeField.add_attribute_field(@role, a.last, a.last[:id], field_status)
|
||||
@attribute = @role
|
||||
end
|
||||
flash.now[:notice] = "Updated Fields"
|
||||
respond_to do |format|
|
||||
format.js { render 'add_attribute_field' }
|
||||
end
|
||||
else
|
||||
flash.now[:error] = t('update.error.category')
|
||||
render action: :edit
|
||||
if @role.update_attributes(role_params)
|
||||
@role.attribute_fields.each{|t| t.destroy if t["to_delete"] == true}
|
||||
redirect_to admin_roles_url
|
||||
else
|
||||
flash.now[:error] = t('update.error.category')
|
||||
render action: :edit
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -53,6 +68,10 @@ class Admin::RolesController < OrbitMemberController
|
|||
redirect_to action: :index
|
||||
end
|
||||
|
||||
def role_field
|
||||
@field_name = 'role'
|
||||
@attribute = Role.find(params[:role_id])
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
|
@ -65,4 +84,11 @@ class Admin::RolesController < OrbitMemberController
|
|||
params.require(:role).permit!
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def set_attribute
|
||||
@attribute_type = 'role'
|
||||
@class = 'roles'
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -0,0 +1,156 @@
|
|||
class AttributeField
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
include Mongoid::Attributes::Dynamic
|
||||
include ::AttributeFieldsHelper
|
||||
|
||||
field :key, type: String
|
||||
field :af_count
|
||||
field :title, type: String, localize: true
|
||||
field :markup, default: "text_field"
|
||||
field :option_list, type: Hash,default: {}
|
||||
field :markup_options, type: Hash
|
||||
field :built_in, type: Boolean, default: false
|
||||
field :disabled, type: Boolean, default: false
|
||||
field :to_delete, type: Boolean,default: false
|
||||
|
||||
field :to_search, type: Boolean, default: false
|
||||
field :to_show,type: Boolean,default: true
|
||||
|
||||
field :typeA, type: Hash, default: {cross_lang: false}
|
||||
field :typeB, type: Hash, default: {}
|
||||
field :typeC, type: Hash, default: {calendar: "west_calendar", format: "format3"}
|
||||
field :typeD, type: Hash, default: {cross_lang: false}
|
||||
field :typeE, type: Hash, default: {}
|
||||
|
||||
belongs_to :role
|
||||
has_many :attribute_values, autosave: true, dependent: :destroy
|
||||
before_save :check_option_list
|
||||
|
||||
def markup_value
|
||||
get_data["option_list"]
|
||||
end
|
||||
|
||||
def add_more
|
||||
(get_data["add_more"] == "true" ? true : false) rescue false
|
||||
end
|
||||
|
||||
def locale
|
||||
get_data["cross_lang"] == "true" ? false : true
|
||||
end
|
||||
|
||||
def self_defined_markup_options?
|
||||
(self.role.method(self[:key].pluralize.to_sym) && self.role.method(self[:key].pluralize+"_for_"+markup)) rescue false
|
||||
end
|
||||
|
||||
def option_list
|
||||
if self_defined_markup_options?
|
||||
#Class need to have corresponding field and value agent
|
||||
# Ex: For "status" the class must have field called "statuses" for the relation and "statuses_for_select" for the select function
|
||||
method = self.role.method(self[:key].pluralize+"_for_"+markup)
|
||||
return (method.call rescue {})
|
||||
elsif self[:option_list].nil? || (self[:option_list].empty?)
|
||||
return {}
|
||||
else
|
||||
return self[:option_list]
|
||||
end
|
||||
end
|
||||
|
||||
def markup_options=(var)
|
||||
self[:markup_options] = (eval(var) rescue {})
|
||||
end
|
||||
|
||||
def markup_options
|
||||
if self[:markup_options].nil?
|
||||
return {}
|
||||
else
|
||||
Hash[self[:markup_options].map{|key,val|[key.to_sym,val]}] rescue {}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def role
|
||||
self.attribute.role
|
||||
end
|
||||
|
||||
def panel
|
||||
panel = LIST[:markups][self[:markup]]["panel"]
|
||||
end
|
||||
|
||||
def get_data
|
||||
self[panel]
|
||||
end
|
||||
|
||||
def typeA=(var)
|
||||
check_add_more_convert(var)
|
||||
check_cross_lang_convert(var,"typeA")
|
||||
self["typeA"] = var
|
||||
end
|
||||
|
||||
def typeD=(var)
|
||||
check_cross_lang_convert(var,"typeD")
|
||||
self["typeD"] = var
|
||||
end
|
||||
|
||||
def is_built_in?
|
||||
self.built_in
|
||||
end
|
||||
|
||||
def is_disabled?
|
||||
self.disabled
|
||||
end
|
||||
|
||||
def self.add_attribute_field(role,role_param, attribute_field_id=nil,field_status)
|
||||
@field_name = 'role'
|
||||
if field_status.eql?(true)
|
||||
@attribute_field_counter = role.attribute_fields.count rescue nil
|
||||
@attribute_field = self.find(attribute_field_id) rescue nil
|
||||
@attribute_field.update(role_param)
|
||||
@attribute_field.save
|
||||
@attribute_field[:af_count] = @attribute_field_counter
|
||||
else
|
||||
@attribute_field_counter = role.attribute_fields.count rescue nil
|
||||
@attribute_field = role.attribute_fields.build(role_param) rescue nil
|
||||
@attribute_field.save
|
||||
@attribute_field[:af_count] = @attribute_field_counter
|
||||
end
|
||||
return @attribute_field
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def check_cross_lang_convert(var,field)
|
||||
if self[field]["cross_lang"] != var["cross_lang"]
|
||||
case var["cross_lang"]
|
||||
when "true" #from no-add_more to add_more
|
||||
cross_lang_convert(:to_cross_lang)
|
||||
else #from add_more to no-add_more
|
||||
cross_lang_convert(:to_no_cross_lang)
|
||||
end # of case
|
||||
end # of if
|
||||
end
|
||||
|
||||
def check_add_more_convert(var)
|
||||
if self["typeA"]["add_more"] != var["add_more"]
|
||||
case var["add_more"]
|
||||
when "true" #from no-add_more to add_more
|
||||
add_more_convert(:to_add_more)
|
||||
else #from add_more to no-add_more
|
||||
add_more_convert(:to_no_add_more)
|
||||
end # of case
|
||||
end # of if
|
||||
end
|
||||
|
||||
def cross_lang_convert(opt)
|
||||
|
||||
end
|
||||
|
||||
def check_option_list
|
||||
self[:option_list] = self[panel]["option_list"] rescue nil
|
||||
end
|
||||
|
||||
def add_more_convert(opt)
|
||||
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,161 @@
|
|||
class AttributeValue
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
include Mongoid::Attributes::Dynamic
|
||||
include AttributeValuesHelper
|
||||
|
||||
field :key, type: String
|
||||
|
||||
belongs_to :attribute_field
|
||||
belongs_to :member_profile
|
||||
|
||||
before_save :check_key
|
||||
before_save :data_proc
|
||||
|
||||
def add_more_counter
|
||||
index_max = self["val"].count rescue 0
|
||||
index_max == 0 ? 1 : index_max
|
||||
end
|
||||
|
||||
def value(index = nil)
|
||||
site = Site.first
|
||||
result = case self.attribute_field.markup
|
||||
when 'text_field','text_area'
|
||||
if self.attribute_field.add_more and (self.attribute_field.markup == "text_field")
|
||||
index.nil? ? self["val"] : self["val"][index]
|
||||
else
|
||||
self.attribute_field.get_data["cross_lang"] =="true" ? self["val"] : Hash[site.valid_locales.collect{|lang| [lang,self[lang.to_sym]]}]
|
||||
end
|
||||
when 'select','radio_button','address'
|
||||
self["val"]
|
||||
when 'date'
|
||||
if !self["val"].blank? and !self["val"]['(1i)'].blank?
|
||||
"#{self["val"]['(1i)']}/#{self["val"]['(2i)']}/#{self["val"]['(3i)']}"
|
||||
else
|
||||
self["val"]
|
||||
end
|
||||
when 'checkbox'
|
||||
self["val"]
|
||||
end #end of case self.attribute_field.markup
|
||||
end
|
||||
|
||||
def value=(value)
|
||||
#save everything to temp_data waiting for futher process
|
||||
self[:temp_data] = value
|
||||
end
|
||||
|
||||
|
||||
def get_value_by_locale(locale,add_more_index=nil)
|
||||
|
||||
case self.attribute_field.markup
|
||||
when "text_field"
|
||||
case self.attribute_field.add_more
|
||||
when true
|
||||
if self.attribute_field.locale
|
||||
add_more_index.nil? ? self.value.collect{|t| t[locale.to_s]}.join(",") : self.value(add_more_index)[locale]
|
||||
else
|
||||
add_more_index.nil? ? self.value.join(",") : self.value(add_more_index)
|
||||
end
|
||||
|
||||
when false
|
||||
self.attribute_field.locale ? self[locale.to_s] : self.value
|
||||
end
|
||||
|
||||
when "select"
|
||||
markup_values = self.attribute_field.self_defined_markup_options? ? self.attribute_field.markup_value : self.attribute_field.markup_value
|
||||
markup_values[self.value][locale.to_s] rescue 'NoData'
|
||||
|
||||
when "text_area"
|
||||
self.attribute_field.locale ? self[locale.to_s] : self.value
|
||||
|
||||
when "date"
|
||||
if self.attribute_field.date_is_range?
|
||||
get_date_by_format(:from) + ' ~ ' + get_date_by_format(:to)
|
||||
# self.value["from"] + ' ~ ' + self.value["to"]
|
||||
else
|
||||
get_date_by_format
|
||||
# self.value
|
||||
end
|
||||
|
||||
when "address"
|
||||
self.value[locale.to_s]
|
||||
|
||||
when "radio_button"
|
||||
markup_values = self.attribute_field.markup_value
|
||||
markup_values[self.value][locale.to_s]
|
||||
|
||||
when "checkbox"
|
||||
markup_values = self.attribute_field.markup_value
|
||||
self.value.collect{|key| markup_values[key][locale.to_s]}.join(",")
|
||||
|
||||
when "date_durnation"
|
||||
self.value
|
||||
|
||||
else
|
||||
self.attribute_field.locale ? self[locale.to_s] : self.value
|
||||
end
|
||||
end
|
||||
|
||||
def get_date(item = nil)
|
||||
case item
|
||||
when :from
|
||||
# data = self[:val]["from"]
|
||||
data = self.value["from"]
|
||||
when :to
|
||||
# data = self[:val]["to"]
|
||||
data = self.value["to"]
|
||||
when nil
|
||||
# data = self[:val]
|
||||
data = self.value
|
||||
end
|
||||
|
||||
# Date.new(data["(1i)"].to_i,data["(2i)"].to_i,data["(3i)"].to_i) rescue nil
|
||||
end
|
||||
|
||||
|
||||
protected
|
||||
|
||||
def unset_all_lang_values
|
||||
VALID_LOCALES.each{|t| self.unset t}
|
||||
end
|
||||
|
||||
def data_proc
|
||||
unless self[:temp_data].nil?
|
||||
case self.attribute_field.markup
|
||||
when "address"
|
||||
self["val"] = self["temp_data"]
|
||||
when 'text_field','text_area'
|
||||
if self.attribute_field.add_more
|
||||
self["val"] = self["temp_data"]
|
||||
else # if not add_more
|
||||
if self.attribute_field.can_muti_lang_input?
|
||||
self[:temp_data].each do |key,val|
|
||||
self[key] = val
|
||||
end if(!self.attribute_field.get_data[:cross_lang])
|
||||
else
|
||||
self["val"] = self[:temp_data]
|
||||
end
|
||||
end # of self.attribute_field.add_more
|
||||
|
||||
when 'select','date','radio_button'
|
||||
self["val"] = self[:temp_data]
|
||||
when 'checkbox'
|
||||
self["val"] = self[:temp_data].keys
|
||||
end #end of case self.attribute_field.markup
|
||||
end # of self[:temp_data].nil?
|
||||
self.unset('temp_data')
|
||||
self.unset('temp')
|
||||
end #of data_proc
|
||||
|
||||
def check_key
|
||||
self.key = attribute_field.key
|
||||
end
|
||||
|
||||
def method_missing(*field)
|
||||
if field.size < 1
|
||||
self[field[0]]
|
||||
else
|
||||
self[(field[0].to_s.delete "=")] = field[1]
|
||||
end
|
||||
end
|
||||
end
|
|
@ -22,6 +22,7 @@ class MemberProfile
|
|||
|
||||
has_one :user
|
||||
has_and_belongs_to_many :roles
|
||||
has_many :role_field_values
|
||||
has_and_belongs_to_many :role_statuses
|
||||
|
||||
has_many :member_profile_field_values
|
||||
|
|
|
@ -1,13 +1,18 @@
|
|||
class Role
|
||||
include Mongoid::Document
|
||||
include Mongoid::Attributes::Dynamic
|
||||
|
||||
field :key, type: String
|
||||
field :title, type: String, localize: true
|
||||
field :built_in, type: Boolean, :default => false
|
||||
field :disabled, :type => Boolean, :default => false
|
||||
field :built_in, type: Boolean, default: false
|
||||
field :disabled, type: Boolean, default: false
|
||||
|
||||
has_and_belongs_to_many :member_profiles
|
||||
has_many :authorizations
|
||||
embeds_many :role_fields
|
||||
|
||||
has_many :attribute_fields
|
||||
accepts_nested_attributes_for :attribute_fields
|
||||
|
||||
has_many :role_statuses
|
||||
|
||||
def is_built_in?
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
class RoleField
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
field :key, type: String
|
||||
field :title, type: String, localize: true
|
||||
|
||||
embedded_in :role
|
||||
end
|
|
@ -0,0 +1,141 @@
|
|||
<div class="attributes default <%= attribute_field.disabled ? 'disabled' : ''%>">
|
||||
<%
|
||||
attribute_field.af_count ? @af_counter = attribute_field_counter + attribute_field.af_count : @af_counter = attribute_field_counter
|
||||
%>
|
||||
<div class="attributes-header clearfix">
|
||||
<div class="toggle-control" style="float: right;">
|
||||
<div class="togglebox <%= attribute_field.disabled ? 'disabled' : ''%>">
|
||||
<%= hidden_field "#{@field_name}[attribute_fields][#{@af_counter}]","disabled",:value=>attribute_field.disabled,:class=>"toggle-check", :data=>{:deploy=>"right"} %>
|
||||
<label><b></b></label>
|
||||
</div>
|
||||
</div>
|
||||
<a class="btn btn-mini pull-right btn-danger delete" href="#"><i class="icon-trash"></i> <%= t(:delete_)%></a>
|
||||
<%= hidden_field "#{@field_name}[attribute_fields][#{@af_counter}]","to_delete",:value=>false,:class=>"attribute_field_to_delete"%>
|
||||
<a class="btn btn-mini pull-right btn-inverse reply hide" href="#"><i class="icons-reply"></i> Reset</a>
|
||||
<h4>Attributes <span><%= @af_counter + 1 %></span></h4>
|
||||
</div>
|
||||
<div class="attributes-body">
|
||||
<div class="control-group">
|
||||
<label class="control-label muted" for="key_<%= @af_counter %>"><%= t(:key) %></label>
|
||||
<div class="controls">
|
||||
<%= text_field "#{@field_name}[attribute_fields][#{@af_counter}]","key",:value=>attribute_field.key, :data=>{:type=>"key"} %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:values=>attribute_field.title_translations,:class_ext=>"pull-left",:label_ext=>t(:name),:field_name=>"#{@field_name}[attribute_fields][#{@af_counter}][title_translations]"}%>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label muted" for=""><%= t(:to_search) %></label>
|
||||
<div class="controls">
|
||||
<label class="radio inline">
|
||||
<%= radio_button("#{@field_name}[attribute_fields][#{@af_counter}]", "to_search", "true",:checked => (attribute_field.to_search == true ? true : false), :data=>{:type=>"search_true"}) %><%= t(:yes_)%>
|
||||
</label>
|
||||
<label class="radio inline">
|
||||
<%= radio_button("#{@field_name}[attribute_fields][#{@af_counter}]", "to_search", "false",:checked => (attribute_field.to_search == false ? true : false), :data=>{:type=>"search_false"}) %><%= t(:no_)%>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label muted" for=""><%= t(:to_show) %></label>
|
||||
<div class="controls">
|
||||
<label class="radio inline">
|
||||
<%= radio_button("#{@field_name}[attribute_fields][#{@af_counter}]", "to_show", "true",:checked => (attribute_field.to_show == true ? true : false), :data=>{:type=>"search_true"}) %><%= t(:yes_)%>
|
||||
</label>
|
||||
<label class="radio inline">
|
||||
<%= radio_button("#{@field_name}[attribute_fields][#{@af_counter}]", "to_show", "false",:checked => (attribute_field.to_show == false ? true : false), :data=>{:type=>"search_false"}) %><%= t(:no_)%>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label muted" for=""><%= t(:type)%></label>
|
||||
<div class="controls">
|
||||
<select class="dataType" data-type="select" name=<%= "#{@field_name}[attribute_fields][#{@af_counter}][markup]"%>>
|
||||
<%LIST[:markups].each do |key,val|%>
|
||||
<option value="<%= key %>" <%= attribute_field.markup == key ? 'selected="selected"' : '' %> ref="<%=val["panel"]%>"><%=t("lists.markups."+key)%></option >
|
||||
<% end %>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field-type fade"></div>
|
||||
|
||||
<%= content_tag :div,:class=>"field-type default fade in #{show_type_panel(attribute_field,"typeA")}" do%>
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t(:enabled_for)%></label>
|
||||
<div class="controls">
|
||||
<label class="checkbox inline">
|
||||
<%= check_box_tag("#{@field_name}[attribute_fields][#{@af_counter}][typeA][cross_lang]","true",attribute_field["typeA"]["cross_lang"],:data=>{:type=>"cross_lang"}) %>
|
||||
<%= t(:cross_lang) %>
|
||||
</label>
|
||||
<label class="checkbox inline">
|
||||
<%= check_box_tag("#{@field_name}[attribute_fields][#{@af_counter}][typeA][add_more]","true",attribute_field["typeA"]["add_more"],:data=>{:type=>"add_more"}) %>
|
||||
<%= t(:add_more)%>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:values=>attribute_field["typeA"]["placeholder"],:field_name=>"#{@field_name}[attribute_fields][#{@af_counter}][typeA][placeholder]"}%>
|
||||
<% end if show_type_panel(attribute_field,"typeA") != 'typeA hide' %>
|
||||
|
||||
<%= content_tag :div,:class=>"field-type default fade in #{show_type_panel(attribute_field,"typeB")}" do %>
|
||||
<%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:label_ext=>t(:initial),:values=>attribute_field["typeB"]["initial"],:field_name=>"#{@field_name}[attribute_fields][#{@af_counter}][typeB][initial]"}%>
|
||||
|
||||
<% if attribute_field.self_defined_markup_options?%>
|
||||
<%= render :partial=>"shared/attribute_field/list_block",:locals=>{:values=>attribute_field["option_list"],:field_name=> "#{@field_name}[attribute_fields][#{@af_counter}][attribute][role][statuses]"} %>
|
||||
<%else #normal list%>
|
||||
<%= render :partial=>"shared/attribute_field/list_block",:locals=>{:values=>attribute_field["option_list"],:field_name=> "#{@field_name}[attribute_fields][#{@af_counter}][typeB][option_list]"} %>
|
||||
<% end #of self_defined_markup_options?%>
|
||||
|
||||
<% end if show_type_panel(attribute_field,"typeB") != 'typeB hide' %>
|
||||
|
||||
<%= content_tag :div,:class=>"field-type default fade in #{show_type_panel(attribute_field,"typeC")}" do %>
|
||||
<div class="control-group">
|
||||
<label class="control-label"><%= t("date.format")%></label>
|
||||
<div class="controls">
|
||||
<%= select "#{@field_name}[attribute_fields][#{@af_counter}][typeC]","format",Admin::AttributeValuesViewHelper::OPT,:class=>"dataType",:selected=>attribute_field["typeC"]["format"] %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label"><%= t("date.range")%></label>
|
||||
<div class="controls">
|
||||
<label class="radio inline">
|
||||
<%= radio_button("#{@field_name}[attribute_fields][#{@af_counter}][typeC]", "is_range", "false",:checked => (!attribute_field.date_is_range? ? true : false)) %><%= t(:yes_)%>
|
||||
</label>
|
||||
<label class="radio inline">
|
||||
<%= radio_button("#{@field_name}[attribute_fields][#{@af_counter}][typeC]", "is_range", "true",:checked => (attribute_field.date_is_range? ? true : false)) %><%= t(:no_)%>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label"><%= t("date.calendar")%></label>
|
||||
<div class="controls">
|
||||
<label class="radio inline">
|
||||
<%= radio_button("#{@field_name}[attribute_fields][#{@af_counter}][typeC]", "calendar", "west_calendar",:checked =>(attribute_field["typeC"]["calendar"]== "west_calendar" ? true : false)) %><%= t("date.west_calendar")%>
|
||||
</label>
|
||||
<label class="radio inline">
|
||||
<%= radio_button("#{@field_name}[attribute_fields][#{@af_counter}][typeC]", "calendar", "tw_calendar",:checked =>(attribute_field["typeC"]["calendar"]== "tw_calendar" ? true : false)) %><%= t("date.tw_calendar")%>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<% end if show_type_panel(attribute_field,"typeC") != 'typeC hide' %>
|
||||
|
||||
<%= content_tag :div,:class=>"field-type default fade in #{show_type_panel(attribute_field,"typeD")}" do%>
|
||||
<div class="control-group">
|
||||
<label class="control-label"><%= t(:enabled_for)%></label>
|
||||
<div class="controls">
|
||||
<label class="checkbox inline">
|
||||
<%= check_box_tag("#{@field_name}[attribute_fields][#{@af_counter}][typeD][cross_lang]","true",attribute_field["typeD"]["cross_lang"]) %>
|
||||
<%= t(:cross_lang)%>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:field_name=>"#{@field_name}[attribute_fields][#{@af_counter}][typeD][placeholder]",:values=>attribute_field["typeD"]["placeholder"]} %>
|
||||
<% end if show_type_panel(attribute_field,"typeD") != 'typeD hide' %>
|
||||
|
||||
<%= content_tag :div,:class=>"field-type default fade in #{show_type_panel(attribute_field,"typeE")}" do%>
|
||||
<%= render :partial=>"shared/attribute_field/list_block",:locals=>{:field_name=>"#{@field_name}[attribute_fields][#{@af_counter}][typeE][option_list]",:values=>attribute_field["option_list"]}%>
|
||||
<% end if show_type_panel(attribute_field,"typeE") != 'typeE hide' %>
|
||||
|
||||
<%= hidden_field "#{@field_name}[attribute_fields][#{@af_counter}]","id",:value=>attribute_field.id%>
|
||||
|
||||
</div>
|
|
@ -5,7 +5,7 @@
|
|||
<div class="quick-edit">
|
||||
<ul class="nav nav-pills">
|
||||
<li><%= link_to t(:edit), edit_admin_role_path(role), :class=>"open-slide" %></li>
|
||||
<li><%= link_to t(:role_field) %></li>
|
||||
<li><%= link_to t(:role_field), admin_role_role_field_path(role) %></li>
|
||||
<li><%= link_to t(:status), admin_role_statuses_path(role_id: role.id) %></li>
|
||||
<li></li>
|
||||
</ul>
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
$('<%= j render :partial => 'attribute_field', :collection => [@attribute_field] %>').appendTo('#attribute_field_list').hide().fadeIn();
|
|
@ -0,0 +1,41 @@
|
|||
<% content_for :side_bar do %>
|
||||
<%= render :partial => 'admin/members/side_bar' %>
|
||||
<% end %>
|
||||
|
||||
<% content_for :page_specific_css do -%>
|
||||
<%= stylesheet_link_tag "lib/wrap-nav.css" %>
|
||||
<%= stylesheet_link_tag "lib/pageslide.css" %>
|
||||
<%= stylesheet_link_tag "lib/main-forms.css" %>
|
||||
<%= stylesheet_link_tag "lib/togglebox.css" %>
|
||||
<% end -%>
|
||||
|
||||
<% content_for :page_specific_javascript do -%>
|
||||
<%= javascript_include_tag "lib/jquery.tmpl.min.js" %>
|
||||
<%= javascript_include_tag "lib/member/role-forms.js" %>
|
||||
<% end -%>
|
||||
|
||||
<%= form_for @attribute,:url => eval("admin_#{@attribute_type}_path(@attribute)") , :html => { :class=> "form-horizontal main-forms", remote: true } do |f| %>
|
||||
<% if flash.now[:notice].present? %>
|
||||
<%= flash.now[:notice]%>
|
||||
<% end %>
|
||||
|
||||
<h3><%= @attribute.title + t(:role)%></h3>
|
||||
<fieldset>
|
||||
|
||||
<div id="attributes-area" class="input-area">
|
||||
<%= render partial: "attribute_field",collection: @attribute.attribute_fields.asc(:_id)%>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<button type="button" class="btn btn-success add-attributes"><%= t(:add_attribute_field) %></button>
|
||||
<%= hidden_field_tag 'id', params[:role_id] if !params[:role_id].blank? %>
|
||||
<%= f.submit t(:submit),:class=>"btn btn-primary"%>
|
||||
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
|
||||
</div>
|
||||
</fieldset>
|
||||
<% end %>
|
||||
|
||||
|
||||
<% content_for :page_specific_javascript do -%>
|
||||
<%= render 'js/support_member_form_js' %>
|
||||
<% end -%>
|
|
@ -0,0 +1,71 @@
|
|||
<div id="address-field" class="modal hide fade">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3><%= (field_name rescue nil) || t("address_modal.default_title") %></h3>
|
||||
</div>
|
||||
<div class="modal-body form-horizontal address-modal">
|
||||
<div class="tabbable">
|
||||
<ul class="nav nav-tabs">
|
||||
<% VALID_LOCALES.each do |locale|%>
|
||||
<% active = (locale == I18n.locale.to_s ? ["active"] : [] ) %>
|
||||
<%= content_tag :li,:class=>active,:for=>locale do%>
|
||||
<%= link_to I18nVariable.from_locale(locale),".#{btn_class}.address_modal.#{locale}",:data=>{:toggle=>"tab"}%>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
|
||||
<% VALID_LOCALES.each do |locale|%>
|
||||
<!-- start of lang tab context -->
|
||||
<% active = (locale == I18n.locale.to_s ? "active" : "" ) %>
|
||||
<div class="tab-pane fade <%= active %> in %>" for="<%= locale %>">
|
||||
<div class="control-group">
|
||||
<label class="control-label muted" for="street_address"><%= t("address_modal.street_address") %></label>
|
||||
<div class="controls">
|
||||
|
||||
<%= text_area_tag("#{field_name_basic}[temp][address_ext][#{locale}][street_address]",nil,:rows=>3,:func=>'street_address', :class=>"input-xlarge") %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label muted" for="city"><%= t("address_modal.city") %></label>
|
||||
<div class="controls">
|
||||
<%= text_field_tag("#{field_name_basic}[temp][address_ext][#{locale}][city]",'',:func=>'city', :class=>"input-xlarge") %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label muted" for="counties"><%= t("address_modal.county") %></label>
|
||||
<div class="controls">
|
||||
<%= text_field_tag("#{field_name_basic}[temp][address_ext][#{locale}][county]",'',:func=>'county', :class=>"input-xlarge") %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label muted" for="zip"><%= t("address_modal.zip") %></label>
|
||||
<div class="controls">
|
||||
<%= text_field_tag("#{field_name_basic}[temp][address_ext][#{locale}][zip]",nil,:class=>"input-mini",:func=>'zip', :class=>"input-xlarge") %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label muted" for="country"><%= t("address_modal.country") %></label>
|
||||
<div class="controls">
|
||||
<%= text_field_tag("#{field_name_basic}[temp][address_ext][#{locale}][country]",'',:func=>'country', :class=>"input-xlarge") %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group hide">
|
||||
<label class="control-label muted" for="indicator"><%= t("address_modal.Indicator") %></label>
|
||||
<div class="controls">
|
||||
<%= text_field_tag("#{field_name_basic}[temp][address_ext][#{locale}][indicator]",'',:func=>'country', :class=>"input-xlarge") %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end of tab context -->
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a class="btn" data-dismiss="modal" aria-hidden="true"><%=t(:close)%></a>
|
||||
<a class="btn btn-primary returnDecide" data-dismiss="modal" aria-hidden="true"><%=t(:save_and_close)%></a>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,141 @@
|
|||
<div class="attributes default <%= attribute_field.disabled ? 'disabled' : ''%>">
|
||||
<%
|
||||
attribute_field.af_count ? @af_counter = attribute_field_counter + attribute_field.af_count : @af_counter = attribute_field_counter
|
||||
%>
|
||||
<div class="attributes-header clearfix">
|
||||
<div class="toggle-control" style="float: right;">
|
||||
<div class="togglebox <%= attribute_field.disabled ? 'disabled' : ''%>">
|
||||
<%= hidden_field "info[attribute_fields][#{@af_counter}]","disabled",:value=>attribute_field.disabled,:class=>"toggle-check", :data=>{:deploy=>"right"} %>
|
||||
<label><b></b></label>
|
||||
</div>
|
||||
</div>
|
||||
<a class="btn btn-mini pull-right btn-danger delete" href="#"><i class="icon-trash"></i> <%= t(:delete_)%></a>
|
||||
<%= hidden_field "info[attribute_fields][#{@af_counter}]","to_delete",:value=>false,:class=>"attribute_field_to_delete"%>
|
||||
<a class="btn btn-mini pull-right btn-inverse reply hide" href="#"><i class="icons-reply"></i> Reset</a>
|
||||
<h4>Attributes <span><%= @af_counter + 1 %></span></h4>
|
||||
</div>
|
||||
<div class="attributes-body">
|
||||
<div class="control-group">
|
||||
<label class="control-label muted" for="key_<%= @af_counter %>"><%= t(:key) %></label>
|
||||
<div class="controls">
|
||||
<%= text_field "info[attribute_fields][#{@af_counter}]","key",:value=>attribute_field.key, :data=>{:type=>"key"} %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:values=>attribute_field.title_translations,:class_ext=>"pull-left",:label_ext=>t(:name),:field_name=>"info[attribute_fields][#{@af_counter}][title_translations]"}%>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label muted" for=""><%= t(:to_search) %></label>
|
||||
<div class="controls">
|
||||
<label class="radio inline">
|
||||
<%= radio_button("info[attribute_fields][#{@af_counter}]", "to_search", "true",:checked => (attribute_field.to_search == true ? true : false), :data=>{:type=>"search_true"}) %><%= t(:yes_)%>
|
||||
</label>
|
||||
<label class="radio inline">
|
||||
<%= radio_button("info[attribute_fields][#{@af_counter}]", "to_search", "false",:checked => (attribute_field.to_search == false ? true : false), :data=>{:type=>"search_false"}) %><%= t(:no_)%>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label muted" for=""><%= t(:to_show) %></label>
|
||||
<div class="controls">
|
||||
<label class="radio inline">
|
||||
<%= radio_button("info[attribute_fields][#{@af_counter}]", "to_show", "true",:checked => (attribute_field.to_show == true ? true : false), :data=>{:type=>"search_true"}) %><%= t(:yes_)%>
|
||||
</label>
|
||||
<label class="radio inline">
|
||||
<%= radio_button("info[attribute_fields][#{@af_counter}]", "to_show", "false",:checked => (attribute_field.to_show == false ? true : false), :data=>{:type=>"search_false"}) %><%= t(:no_)%>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label muted" for=""><%= t(:type)%></label>
|
||||
<div class="controls">
|
||||
<select class="dataType" data-type="select" name=<%= "info[attribute_fields][#{@af_counter}][markup]"%>>
|
||||
<%LIST[:markups].each do |key,val|%>
|
||||
<option value="<%= key %>" <%= attribute_field.markup == key ? 'selected="selected"' : '' %> ref="<%=val["panel"]%>"><%=t("lists.markups."+key)%></option >
|
||||
<% end %>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field-type fade"></div>
|
||||
|
||||
<%= content_tag :div,:class=>"field-type default fade in #{show_type_panel(attribute_field,"typeA")}" do%>
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t(:enabled_for)%></label>
|
||||
<div class="controls">
|
||||
<label class="checkbox inline">
|
||||
<%= check_box_tag("info[attribute_fields][#{@af_counter}][typeA][cross_lang]","true",attribute_field["typeA"]["cross_lang"],:data=>{:type=>"cross_lang"}) %>
|
||||
<%= t(:cross_lang) %>
|
||||
</label>
|
||||
<label class="checkbox inline">
|
||||
<%= check_box_tag("info[attribute_fields][#{@af_counter}][typeA][add_more]","true",attribute_field["typeA"]["add_more"],:data=>{:type=>"add_more"}) %>
|
||||
<%= t(:add_more)%>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:values=>attribute_field["typeA"]["placeholder"],:field_name=>"info[attribute_fields][#{@af_counter}][typeA][placeholder]"}%>
|
||||
<% end if show_type_panel(attribute_field,"typeA") != 'typeA hide' %>
|
||||
|
||||
<%= content_tag :div,:class=>"field-type default fade in #{show_type_panel(attribute_field,"typeB")}" do %>
|
||||
<%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:label_ext=>t(:initial),:values=>attribute_field["typeB"]["initial"],:field_name=>"info[attribute_fields][#{@af_counter}][typeB][initial]"}%>
|
||||
|
||||
<% if attribute_field.self_defined_markup_options?%>
|
||||
<%= render :partial=>"shared/attribute_field/list_block",:locals=>{:values=>attribute_field["option_list"],:field_name=> "info[attribute_fields][#{@af_counter}][attribute][role][statuses]"} %>
|
||||
<%else #normal list%>
|
||||
<%= render :partial=>"shared/attribute_field/list_block",:locals=>{:values=>attribute_field["option_list"],:field_name=> "info[attribute_fields][#{@af_counter}][typeB][option_list]"} %>
|
||||
<% end #of self_defined_markup_options?%>
|
||||
|
||||
<% end if show_type_panel(attribute_field,"typeB") != 'typeB hide' %>
|
||||
|
||||
<%= content_tag :div,:class=>"field-type default fade in #{show_type_panel(attribute_field,"typeC")}" do %>
|
||||
<div class="control-group">
|
||||
<label class="control-label"><%= t("date.format")%></label>
|
||||
<div class="controls">
|
||||
<%= select "info[attribute_fields][#{@af_counter}][typeC]","format",Admin::AttributeValuesViewHelper::OPT,:class=>"dataType",:selected=>attribute_field["typeC"]["format"] %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label"><%= t("date.range")%></label>
|
||||
<div class="controls">
|
||||
<label class="radio inline">
|
||||
<%= radio_button("info[attribute_fields][#{@af_counter}][typeC]", "is_range", "false",:checked => (!attribute_field.date_is_range? ? true : false)) %><%= t(:yes_)%>
|
||||
</label>
|
||||
<label class="radio inline">
|
||||
<%= radio_button("info[attribute_fields][#{@af_counter}][typeC]", "is_range", "true",:checked => (attribute_field.date_is_range? ? true : false)) %><%= t(:no_)%>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label"><%= t("date.calendar")%></label>
|
||||
<div class="controls">
|
||||
<label class="radio inline">
|
||||
<%= radio_button("info[attribute_fields][#{@af_counter}][typeC]", "calendar", "west_calendar",:checked =>(attribute_field["typeC"]["calendar"]== "west_calendar" ? true : false)) %><%= t("date.west_calendar")%>
|
||||
</label>
|
||||
<label class="radio inline">
|
||||
<%= radio_button("info[attribute_fields][#{@af_counter}][typeC]", "calendar", "tw_calendar",:checked =>(attribute_field["typeC"]["calendar"]== "tw_calendar" ? true : false)) %><%= t("date.tw_calendar")%>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<% end if show_type_panel(attribute_field,"typeC") != 'typeC hide' %>
|
||||
|
||||
<%= content_tag :div,:class=>"field-type default fade in #{show_type_panel(attribute_field,"typeD")}" do%>
|
||||
<div class="control-group">
|
||||
<label class="control-label"><%= t(:enabled_for)%></label>
|
||||
<div class="controls">
|
||||
<label class="checkbox inline">
|
||||
<%= check_box_tag("info[attribute_fields][#{@af_counter}][typeD][cross_lang]","true",attribute_field["typeD"]["cross_lang"]) %>
|
||||
<%= t(:cross_lang)%>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:field_name=>"info[attribute_fields][#{@af_counter}][typeD][placeholder]",:values=>attribute_field["typeD"]["placeholder"]} %>
|
||||
<% end if show_type_panel(attribute_field,"typeD") != 'typeD hide' %>
|
||||
|
||||
<%= content_tag :div,:class=>"field-type default fade in #{show_type_panel(attribute_field,"typeE")}" do%>
|
||||
<%= render :partial=>"shared/attribute_field/list_block",:locals=>{:field_name=>"info[attribute_fields][#{@af_counter}][typeE][option_list]",:values=>attribute_field["option_list"]}%>
|
||||
<% end if show_type_panel(attribute_field,"typeE") != 'typeE hide' %>
|
||||
|
||||
<%= hidden_field "info[attribute_fields][#{@af_counter}]","id",:value=>attribute_field.id%>
|
||||
|
||||
</div>
|
|
@ -0,0 +1,41 @@
|
|||
<% temp_field_name = field_name.gsub /\[\D*\]$/,'[temp]'%>
|
||||
<div class="control-group">
|
||||
<%= hidden_field_tag "#{temp_field_name}[count]",((values.keys.collect{|t| t.to_i}.max rescue nil) || 0 ),:class=>"list_count"%>
|
||||
<%= hidden_field_tag "#{temp_field_name}[name]",field_name,:class=>"field_name"%>
|
||||
<label class="control-label muted" for=""><%= t(:options)%></label>
|
||||
<div class="controls add-input">
|
||||
<div class="add-target single">
|
||||
|
||||
<%if values.blank? %>
|
||||
<%= content_tag :div,:class=>"input-append" do%>
|
||||
<% @site_in_use_locales.each do |locale| %>
|
||||
<% last = (locale == @site_in_use_locales.last ? true : false) %>
|
||||
<% p_value = value[locale.to_s] rescue nil%>
|
||||
<%= text_field("#{field_name}[0]", locale,:placeholder=>I18nVariable.from_locale(locale),:class=>"input-medium",:data=>{:type=>"option_lang_0_#{locale}"}) %>
|
||||
<% if last %>
|
||||
<a href="#" class="btn remove-input"> <i class="icon-trash"></i> </a>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%else%>
|
||||
<%values.each do |index,value|%>
|
||||
|
||||
<%= content_tag :div,:class=>"input-append" do%>
|
||||
<% @site_in_use_locales.each do |locale| %>
|
||||
<% last = (locale == @site_in_use_locales.last ? true : false) %>
|
||||
<% p_value = value[locale.to_s] rescue nil%>
|
||||
<%= text_field("#{field_name}[#{index}]", locale,:value=>p_value,:placeholder=>I18nVariable.from_locale(locale),:class=>"input-medium", :data=>{:type=>"option_lang_#{index}_#{locale}"}) %>
|
||||
<% if last %>
|
||||
<a href="#" class="btn remove-input"> <i class="icon-trash"></i> </a>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
|
||||
<p class="add-btn"> <a href="#" class="typeB trigger btn btn-mini btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a> </p>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,25 @@
|
|||
<% values ||=[]%>
|
||||
<%= content_tag :div,:class=>"control-group" do%>
|
||||
<label class="control-label muted" for=""><%= (defined? label_ext) ? label_ext : t(:placeholder) %></label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<div class="tab-content">
|
||||
<% @site_in_use_locales.each do |locale| %>
|
||||
<% active = (locale == @site_in_use_locales.first ? "active in" : "'") %>
|
||||
<%= content_tag :div,:class=>"tab-pane fade #{active}",:id=>"#{name_to_id(field_name)}_#{locale}" do%>
|
||||
<% locale_value = values[locale.to_s] rescue nil%>
|
||||
<%= text_field(field_name, locale,:value=>locale_value,:placeholder=>I18nVariable.from_locale(locale),:data=>{:type=>"lang_#{locale}"}) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="btn-group" data-toggle="buttons-radio">
|
||||
<% @site_in_use_locales.each do |locale| %>
|
||||
<% active = (locale == @site_in_use_locales.first ? "active" : "") %>
|
||||
<%= link_to I18nVariable.from_locale(locale),"##{name_to_id(field_name)}_#{locale}",:class=>"btn #{active}",:data=>{:toggle=>"tab"}%>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
|
@ -100,6 +100,7 @@ Orbit::Application.routes.draw do
|
|||
|
||||
resources :roles do
|
||||
get 'role_field'
|
||||
get 'add_attribute_field'
|
||||
post 'toggle'
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
key: MyString
|
||||
|
||||
two:
|
||||
key: MyString
|
|
@ -0,0 +1,7 @@
|
|||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
key: MyString
|
||||
|
||||
two:
|
||||
key: MyString
|
|
@ -0,0 +1,7 @@
|
|||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
key: MyString
|
||||
|
||||
two:
|
||||
key: MyString
|
|
@ -0,0 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class AttributeFieldTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class AttributeValueTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RoleFieldValueTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
Loading…
Reference in New Issue