forked from saurabh/orbit4-5
Merge branch 'master' of gitlab.tp.rulingcom.com:saurabh/orbit4-5 into nccu
This commit is contained in:
commit
4b6c27de75
|
@ -318,7 +318,7 @@
|
|||
if( e.type == "keyup" && e.keyCode != 27) return;
|
||||
|
||||
// Make sure it's visible, and we're not modal
|
||||
if( $pageslide.is( ':visible' ) && !$pageslide.data( 'modal' ) ) {
|
||||
if( $pageslide.is( ':visible' ) && !$pageslide.data( 'modal' ) && !$("#modify_fields_to_show").is(":visible")) {
|
||||
$.pageslide.close();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -7,3 +7,38 @@
|
|||
.ui-helper-hidden-accessible{
|
||||
display: none;
|
||||
}
|
||||
|
||||
.current-roles {
|
||||
list-style: none;
|
||||
margin: 0 0 20px 0;
|
||||
padding: 0;
|
||||
}
|
||||
.current-roles > li {
|
||||
padding: 8px 10px;
|
||||
margin-bottom: 8px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #eee;
|
||||
-webkit-box-shadow: 0 0 2px 0 rgba(0,0,0,.2);
|
||||
box-shadow: 0 0 2px 0 rgba(0,0,0,.2);
|
||||
}
|
||||
.role-value {
|
||||
display: inline-block;
|
||||
margin-right: 8px;
|
||||
}
|
||||
.remove-role {
|
||||
cursor: pointer;
|
||||
float: right;
|
||||
padding-left: 16px;
|
||||
border-left: 2px solid #e6e6e6;
|
||||
}
|
||||
.remove-role > i {
|
||||
font-size: 1.125rem;
|
||||
}
|
||||
.remove-role:hover {
|
||||
color: #ff4444;
|
||||
}
|
||||
|
||||
.link-to-show {
|
||||
float: right;
|
||||
margin-right: 16px;
|
||||
}
|
|
@ -2,12 +2,14 @@ class MembersController < ApplicationController
|
|||
def index
|
||||
page_roles = OrbitHelper.page_categories
|
||||
page_role_status = OrbitHelper.page_role_status
|
||||
params = OrbitHelper.params
|
||||
page = Page.where(:page_id => params[:page_id]).first rescue nil
|
||||
fields_to_show = page.custom_array_field if !page.nil? rescue []
|
||||
fields_to_show = [
|
||||
{"key"=>"name", "type"=>"profile","sort_order"=>2,"link_to_show"=>true},
|
||||
{"key"=>"discipline", "type"=>"role", "max_length"=>12},
|
||||
{"key"=>"email", "type"=>"profile"},
|
||||
{"key"=>"office_tel", "type"=>"profile"}
|
||||
]
|
||||
] if fields_to_show.blank?
|
||||
|
||||
if OrbitHelper.member_sort_position
|
||||
sort = "data['list_order']"
|
||||
|
@ -35,16 +37,10 @@ class MembersController < ApplicationController
|
|||
|
||||
role_list = []
|
||||
roles.each do |role|
|
||||
attribute_field = AttributeField.where(:key => 'job_title', :role_id => role['id']).first
|
||||
if !attribute_field.blank?
|
||||
role_fields_to_show = [{"id"=> attribute_field.id.to_s, "key"=>"job_title", "type"=>"role","sort_order"=>1}] + fields_to_show
|
||||
else
|
||||
role_fields_to_show = fields_to_show
|
||||
end
|
||||
status_list = []
|
||||
if !role['status'].blank?
|
||||
role['status'].each do |status|
|
||||
member_profiles = get_members_by_status(status, sort, role_fields_to_show)
|
||||
member_profiles = get_members_by_status(status, sort, fields_to_show)
|
||||
status_list << { "status-title" => status.title, "members" => member_profiles } if !member_profiles.blank?
|
||||
end
|
||||
else
|
||||
|
@ -53,7 +49,7 @@ class MembersController < ApplicationController
|
|||
role_status_ids = role_status.collect{|status| status.id.to_s}
|
||||
|
||||
role_status.each do |status|
|
||||
member_profiles = get_members_by_status(status, sort, role_fields_to_show)
|
||||
member_profiles = get_members_by_status(status, sort, fields_to_show)
|
||||
next if member_profiles.blank?
|
||||
status_list << { "status-title" => status.title, "members" => member_profiles }
|
||||
end
|
||||
|
|
|
@ -173,6 +173,60 @@ class PagesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def get_member_attributes
|
||||
@page_id = params[:page_id]
|
||||
@selected_attribs = Page.find(@page_id).custom_array_field
|
||||
@selected_attribs = [
|
||||
{"key"=>"name", "type"=>"profile","sort_order"=>2,"link_to_show"=>true, "human_readable" => I18n.t("users.name")},
|
||||
{"key"=>"email", "type"=>"profile", "human_readable" => I18n.t("users.email")},
|
||||
{"key"=>"office_tel", "type"=>"profile", "human_readable" => I18n.t("users.office_tel")}
|
||||
] if @selected_attribs.blank?
|
||||
personal_attribs = [
|
||||
{"key" => "first_name", "human_readable" => I18n.t("users.first_name")},
|
||||
{"key" => "last_name", "human_readable" => I18n.t("users.last_name")},
|
||||
{"key" => "name", "human_readable" => I18n.t("users.name")},
|
||||
{"key" => "sex", "human_readable" => I18n.t("users.sex")},
|
||||
{"key" => "office_tel", "human_readable" => I18n.t("users.office_tel")},
|
||||
{"key" => "birthday", "human_readable" => I18n.t("users.birthday")},
|
||||
{"key" => "address", "human_readable" => I18n.t("users.address")},
|
||||
{"key" => "personal_website", "human_readable" => I18n.t("users.personal_website")},
|
||||
{"key" => "autobiography", "human_readable" => I18n.t("users.autobiography")},
|
||||
{"key" => "email", "human_readable" => I18n.t("users.email")}
|
||||
]
|
||||
|
||||
custom_attribs = MemberProfileField.all.collect do |mpf|
|
||||
{"key" => mpf.key, "human_readable" => mpf.title}
|
||||
end
|
||||
|
||||
role_attribs = AttributeField.all.collect do |af|
|
||||
{"key" => af.key, "human_readable" => af.title}
|
||||
end
|
||||
|
||||
@attribs = {
|
||||
"profile" => personal_attribs,
|
||||
"custom" => custom_attribs,
|
||||
"role" => role_attribs,
|
||||
"types" =>[
|
||||
{"key" => "profile", "human_readable" => "Profile"},
|
||||
{"key" => "custom", "human_readable" => "Custom"},
|
||||
{"key" => "role", "human_readable" => "Role"}
|
||||
]
|
||||
}
|
||||
render :partial => "member_frontend_field"
|
||||
end
|
||||
|
||||
def save_member_frontend_fields
|
||||
fields = params["fields"]
|
||||
array = []
|
||||
fields.each do |field|
|
||||
array << field.last
|
||||
end
|
||||
page = Page.find(params[:page_id])
|
||||
page.custom_array_field = array
|
||||
page.save
|
||||
render :json => {"success" => true}.to_json
|
||||
end
|
||||
|
||||
def get_categories
|
||||
module_app = ModuleApp.find_by_key(params[:module]);
|
||||
if module_app.key.eql?("member")
|
||||
|
|
|
@ -22,6 +22,8 @@ class Page
|
|||
field :member_sort_position, type: Boolean, :default => false
|
||||
field :enabled_for_sitemap, type: Array, :default => []
|
||||
field :rss2_id, type: String
|
||||
field :custom_string_field, type: String
|
||||
field :custom_array_field, type: Array, :default => []
|
||||
|
||||
has_many :page_parts, :autosave => true, :dependent => :destroy
|
||||
has_many :mobile_page_parts, :autosave => true, :dependent => :destroy
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
<%= render 'node_and_children', {node: node, level: 0} %>
|
||||
</ol>
|
||||
<% end %>
|
||||
<%= render :partial => "pages/modify_member_frontend_fields" %>
|
||||
<%##= render 'layouts/delete_modal', delete_options: {remote: true} %>
|
||||
<%#= render 'form_page' %>
|
||||
<%#= render 'form_link' %>
|
||||
|
|
|
@ -29,16 +29,36 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group" id="member_sort_setting">
|
||||
<% if @module_app and @module_app.key.eql?("member") %>
|
||||
<% if @module_app and @module_app.key.eql?("member") %>
|
||||
<div class="control-group" id="member_sort_setting">
|
||||
<label class="control-label"><%= t(:sort) %>:</label>
|
||||
<div class="controls">
|
||||
<%= f.radio_button :member_sort_position, false, checked: !@page.member_sort_position? %> <%= t(:sort_by_role_fields) %><br/>
|
||||
<%= f.radio_button :member_sort_position, true, checked: @page.member_sort_position?%> <%= t(:sort_manually) %>
|
||||
<a href="/admin/members/edit_order_list" target="_blank"> <%= t(:sort_edit_order) %> </a>
|
||||
<a href="/admin/members/edit_order_list" target="_blank"> <%= t(:sort_edit_order) %> </a><br />
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label"><%= t(:feilds_to_show_for_index) %>:</label>
|
||||
<div class="controls">
|
||||
<a href="" id="modify_fields_btn"> <%= t(:modify) %> </a>
|
||||
<script type="text/javascript">
|
||||
$("#modify_fields_btn").on("click",function(){
|
||||
var modal = $("#modify_fields_to_show");
|
||||
modal.modal("show");
|
||||
$.ajax({
|
||||
url : "/pages/get_member_attributes",
|
||||
data : {"page_id" : "<%= @page.id.to_s %>"},
|
||||
dataType : "html",
|
||||
}).done(function(data){
|
||||
modal.find("div.modal-body").html(data);
|
||||
})
|
||||
return false;
|
||||
})
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label"><%= t(:category)+" :" if params[:action] == "edit" && !@categories.blank? %></label>
|
||||
|
|
|
@ -0,0 +1,136 @@
|
|||
<form id="form_for_attribs" action="">
|
||||
<div class="form-inline">
|
||||
<ul class="current-roles">
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="form-inline controls-row">
|
||||
<label>Attribute Type: </label>
|
||||
<select class="role-selector" id="type_selector" style="width:100px;">
|
||||
|
||||
</select>
|
||||
<label> Attribute: </label>
|
||||
<select class="role-selector attrb-selector" id="profile_selector">
|
||||
|
||||
</select>
|
||||
<select class="role-selector hide attrb-selector" id="custom_selector">
|
||||
|
||||
</select>
|
||||
<select class="role-selector hide attrb-selector" id="role_selector">
|
||||
|
||||
</select>
|
||||
<a href="#" class="add-role btn btn-default">Add role</a>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-actions">
|
||||
<input type="hidden" value="<%= @page_id %>">
|
||||
<a href="#" id="form_for_attribs_btns" class="btn btn-primary">Save</a>
|
||||
<a href="#" class="btn" data-dismiss="modal">Cancel</a>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
var selected_attribs = <%= @selected_attribs.to_json.html_safe %>,
|
||||
attributes = <%= @attribs.to_json.html_safe %>;
|
||||
|
||||
|
||||
var render_default_attributes = function(){
|
||||
var html = "";
|
||||
$.each(selected_attribs,function(i,attrib){
|
||||
var collection = attributes[attrib.type],
|
||||
node = collection.filter(function(x){return x.key == attrib.key})[0];
|
||||
if(typeof node !== "undefined"){
|
||||
if(attrib.key != "email"){
|
||||
html+= '<li class="clearfix" data-attrib-key="' + attrib.key + '" data-attrib-type="' + attrib.type + '"><span class="role-value">' + node.human_readable + '</span><span class="remove-role"><i class="icon-remove-sign"></i></span><label class="checkbox link-to-show"><input type="checkbox" value="true" ' + (attrib.link_to_show ? "checked=checked" : "" ) + '> Link to show </label></li>';
|
||||
}else{
|
||||
html+= '<li class="clearfix" data-attrib-key="' + attrib.key + '" data-attrib-type="' + attrib.type + '"><span class="role-value">' + node.human_readable + '</span><span class="remove-role"><i class="icon-remove-sign"></i></span></li>';
|
||||
}
|
||||
}
|
||||
})
|
||||
$("#form_for_attribs ul.current-roles").html(html);
|
||||
}();
|
||||
|
||||
var render_default_type_selectors = function(){
|
||||
var html = "",
|
||||
keys = [];
|
||||
$.each(attributes.types,function(i, type){
|
||||
html+= "<option value='" + type.key + "'>" + type.human_readable + "</option>";
|
||||
keys.push(type.key);
|
||||
})
|
||||
$("#form_for_attribs select#type_selector").html(html).on("change",function(){
|
||||
var val = $(this).val();
|
||||
$("#form_for_attribs .attrb-selector").addClass("hide");
|
||||
$("#form_for_attribs #" + val + "_selector").removeClass("hide");
|
||||
});
|
||||
$.each(keys,function(i,key){
|
||||
var attribs = attributes[key],
|
||||
html = "";
|
||||
$.each(attribs,function(x,attrib){
|
||||
html+= "<option value='"+ attrib.key +"'>" + attrib.human_readable + "</option>";
|
||||
})
|
||||
$("#" + key + "_selector").html(html);
|
||||
})
|
||||
}();
|
||||
|
||||
$(document).ready(function(){
|
||||
// Add Role function, get the current selected item value and append it to select element
|
||||
function addRole( e ) {
|
||||
var type = $("#form_for_attribs #type_selector").val(),
|
||||
attrib_key = $("#form_for_attribs #"+type+"_selector").val(),
|
||||
attrib_text = $("#form_for_attribs #"+type+"_selector option[value="+attrib_key+"]").text();
|
||||
// If the select is empty, stop appending or it will keep appending blank content to select element
|
||||
if(attrib_key != "email"){
|
||||
$( ".current-roles" ).append( "<li class=\"clearfix\" data-attrib-key=\"" + attrib_key + "\" data-attrib-type=\"" + type + "\"><span class=\"role-value\">" + attrib_text + "</span><span class=\"remove-role\"><i class=\"icon-remove-sign\"></i></span><label class=\"checkbox link-to-show\"><input type=\"checkbox\" value=\"true\"> Link to show </label></li>" );
|
||||
}else{
|
||||
$( ".current-roles" ).append( "<li class=\"clearfix\" data-attrib-key=\"" + attrib_key + "\" data-attrib-type=\"" + type + "\"><span class=\"role-value\">" + attrib_text + "</span><span class=\"remove-role\"><i class=\"icon-remove-sign\"></i></span></li>" );
|
||||
}
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
// Remove the select role and append it back to select element
|
||||
function removeRole( e ) {
|
||||
var el = $( this ).closest( "li" ).remove();
|
||||
$( "select" ).append( "<option>" + el.find( ".role-value" ).text() + "</option>" );
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
// Add event listeners
|
||||
$( ".add-role" ).on( "click", addRole );
|
||||
$( ".current-roles" ).on( "click", ".remove-role", removeRole );
|
||||
$("#form_for_attribs ul.current-roles").sortable();
|
||||
|
||||
$("#form_for_attribs #form_for_attribs_btns").on("click",function(){
|
||||
var data = [];
|
||||
$("#form_for_attribs ul.current-roles li").each(function(i){
|
||||
var opts = {};
|
||||
opts["key"] = $(this).data("attrib-key");
|
||||
opts["type"] = $(this).data("attrib-type");
|
||||
opts["sort"] = i + 2;
|
||||
// opts["human_readable"] = $(this).find("span.role-value").text();
|
||||
if($(this).find("input[type=checkbox]").is(":checked")){
|
||||
opts["link_to_show"] = true;
|
||||
}
|
||||
if(opts["key"] == "discipline"){
|
||||
opts["max_length"] = 12;
|
||||
}
|
||||
data.push(opts);
|
||||
})
|
||||
$.ajax({
|
||||
url : "/pages/save_member_frontend_fields",
|
||||
data : {"fields" : data, "page_id" : $("#form_for_attribs input[type=hidden]").val()},
|
||||
type : "post",
|
||||
dataType : "json"
|
||||
}).done(function(){
|
||||
$("#modify_fields_to_show").modal("hide");
|
||||
})
|
||||
return false;
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<div id="modify_fields_to_show" class="modal hide fade" role="dialog">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3>Modify Fields</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<img src="/assets/preloader.gif" />
|
||||
</div>
|
||||
</div>
|
|
@ -650,6 +650,7 @@ en:
|
|||
first_name: First Name
|
||||
last_name: Last Name
|
||||
male: Male
|
||||
discipline: Discipline
|
||||
name: Name
|
||||
valid_old_password: Current password doesn't match confirmation
|
||||
new_password: New password
|
||||
|
|
Loading…
Reference in New Issue