forked from saurabh/orbit4-5
Merge branch 'development' of gitlab.tp.rulingcom.com:saurabh/orbit4-5 into development
This commit is contained in:
commit
f9ed19def0
|
@ -539,6 +539,14 @@
|
|||
#sideset blockquote {
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
.downloaded_times{
|
||||
display: inline-block;
|
||||
font-size: 14px;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
padding-left: 10px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
/* Responsive */
|
||||
@media (min-width: 768px) and (max-width: 979px) {
|
||||
|
|
|
@ -1,9 +1,56 @@
|
|||
class Admin::GroupsController < OrbitMemberController
|
||||
|
||||
def index
|
||||
@groups = Group.all
|
||||
end
|
||||
|
||||
def categories
|
||||
@categories = GroupCategory.all
|
||||
end
|
||||
|
||||
def create_category
|
||||
gc = GroupCategory.new(category_params)
|
||||
gc.save
|
||||
@categories = GroupCategory.all
|
||||
render :partial => "group_categories"
|
||||
end
|
||||
|
||||
def create
|
||||
group = Group.new(group_params)
|
||||
group.save
|
||||
redirect_to admin_groups_path
|
||||
end
|
||||
|
||||
def new
|
||||
@group = Group.new
|
||||
@categories = GroupCategory.all.collect{|gc| [gc.title,gc.id]}
|
||||
@members = []
|
||||
MemberProfile.all.each do |mp|
|
||||
user = mp.user rescue nil
|
||||
if !user.nil? && user.id.to_s != current_user.id.to_s && user.user_name != "rulingcom"
|
||||
avatar = (mp.avatar.thumb.url == "thumb_person.png" ? "/assets/thumb_person.png" : mp.avatar.thumb.url rescue "/assets/thumb_person.png")
|
||||
@members << {
|
||||
"id" => user.id.to_s,
|
||||
"user_name" => (user.user_name rescue ""),
|
||||
"avatar" => avatar,
|
||||
"name" => (mp.name_translations rescue {"en" => "","zh_tw" => ""})
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def category_params
|
||||
params.require(:category).permit!
|
||||
end
|
||||
|
||||
def group_params
|
||||
p = params.require(:group).permit!
|
||||
p["user_ids"] << current_user.id.to_s
|
||||
p["admins"] = []
|
||||
p["admins"] << current_user.id.to_s
|
||||
p
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
class Group
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
include Slug
|
||||
|
||||
field :title, as: :slug_title, type: String, localize: true
|
||||
field :description, localize: true
|
||||
field :admins, type: Array, default: []
|
||||
field :privacy, default: "closed"
|
||||
mount_uploader :image, ImageUploader
|
||||
|
||||
belongs_to :group_category
|
||||
has_and_belongs_to_many :users
|
||||
|
||||
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
class GroupCategory
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
field :title, localize: true
|
||||
|
||||
has_many :groups
|
||||
end
|
|
@ -52,6 +52,13 @@ class MemberProfile
|
|||
end
|
||||
end
|
||||
|
||||
def name_translations
|
||||
{
|
||||
"en" => "#{self.first_name_translations["en"]} #{self.last_name_translations["zh_tw"]}",
|
||||
"zh_tw" => "#{self.last_name_translations["zh_tw"]} #{self.first_name_translations["zh_tw"]}"
|
||||
}
|
||||
end
|
||||
|
||||
def disable_role=(var)
|
||||
var[:id].each do |id,val|
|
||||
if (val=="true")
|
||||
|
|
|
@ -20,6 +20,7 @@ class User
|
|||
belongs_to :workgroup
|
||||
has_many :authorizations
|
||||
belongs_to :member_profile
|
||||
has_and_belongs_to_many :groups
|
||||
has_one :facebook, :autosave => true, :dependent => :destroy
|
||||
has_one :google, :autosave => true, :dependent => :destroy
|
||||
# has_one :desktop, :dependent => :destroy
|
||||
|
|
|
@ -0,0 +1,164 @@
|
|||
<% content_for :page_specific_css do %>
|
||||
<%= stylesheet_link_tag "lib/main-forms" %>
|
||||
<%= stylesheet_link_tag "lib/fileupload" %>
|
||||
<%= stylesheet_link_tag "lib/main-list" %>
|
||||
<%= stylesheet_link_tag "select2/select2" %>
|
||||
<style>
|
||||
.select2-container{
|
||||
width : 600px;
|
||||
}
|
||||
.img-avatar{
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
}
|
||||
</style>
|
||||
<% end %>
|
||||
<% content_for :page_specific_javascript do %>
|
||||
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
|
||||
<%= javascript_include_tag "lib/file-type" %>
|
||||
<%= javascript_include_tag "lib/module-area" %>
|
||||
<%= javascript_include_tag "select2/select2.min" %>
|
||||
<% end %>
|
||||
|
||||
<div class="input-area">
|
||||
|
||||
<!-- Module Tabs -->
|
||||
<ul class="nav nav-pills module-nav">
|
||||
<li class="active"><a href="#basic" data-toggle="tab"><%= t(:basic) %></a></li>
|
||||
</ul>
|
||||
<!-- Module -->
|
||||
<div class="tab-content module-area">
|
||||
|
||||
<!-- Basic Module -->
|
||||
<div class="tab-pane fade in active" id="basic">
|
||||
|
||||
<!-- Category -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t(:category) %></label>
|
||||
<div class="controls">
|
||||
<%= f.select :group_category_id, @categories %>
|
||||
</div>
|
||||
</div>
|
||||
<!-- group banner image -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t(:image) %></label>
|
||||
<div class="controls">
|
||||
<div class="fileupload fileupload-new clearfix <%= 'fileupload-edit' if @group.image.file %>" data-provides="fileupload">
|
||||
<div class="fileupload-new thumbnail pull-left">
|
||||
<% if @group.image.file %>
|
||||
<%= image_tag @group.image %>
|
||||
<% else %>
|
||||
<img src="http://www.placehold.it/50x50/EFEFEF/AAAAAA" />
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="fileupload-preview fileupload-exists thumbnail pull-left"></div>
|
||||
<span class="btn btn-file">
|
||||
<span class="fileupload-new"><%= t(:select_image) %></span>
|
||||
<span class="fileupload-exists"><%= t(:change) %></span>
|
||||
<%= f.file_field :image %>
|
||||
</span>
|
||||
<a href="#" class="btn fileupload-exists" data-dismiss="fileupload"><%= t(:cancel) %></a>
|
||||
<div class="controls" data-toggle="buttons-checkbox">
|
||||
<label class="checkbox inline btn btn-danger fileupload-remove">
|
||||
<%= f.check_box :remove_image %><%= t(:remove) %>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- privacy settings -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted">Privacy</label>
|
||||
<div class="controls">
|
||||
<input type="radio" name="group[privacy]" value="open" /> Open
|
||||
<input type="radio" name="group[privacy]" value="closed" checked="checked" /> Closed
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t(:members) %></label>
|
||||
<div class="controls">
|
||||
<select class="member_selection" multiple="multiple" name="group[user_ids][]">
|
||||
<% @members.each do |member| %>
|
||||
<%
|
||||
name = member["name"][I18n.locale.to_s] == "" ? member["name"]["zh_tw"] : member["name"][I18n.locale.to_s]
|
||||
name = "" if name.nil?
|
||||
user_name = "(#{member["user_name"]})"
|
||||
text = "#{name} #{user_name}"
|
||||
%>
|
||||
<option value="<%= member["id"] %>" data-member="<%= member.to_json %>"><%= text %></option>
|
||||
<% end %>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!-- Language Tabs -->
|
||||
<div class="nav-name"><strong><%= t(:language) %></strong></div>
|
||||
<ul class="nav nav-pills language-nav">
|
||||
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
||||
<li class="<%= 'active' if i == 0 %>">
|
||||
<a data-toggle="tab" href=".<%= locale %>"><%= t(locale) %></a>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
<!-- Language -->
|
||||
<div class="tab-content language-area">
|
||||
|
||||
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
||||
|
||||
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>">
|
||||
|
||||
<!-- Title-->
|
||||
<div class="control-group input-title">
|
||||
<label class="control-label muted"><%= t(:title) %></label>
|
||||
<div class="controls">
|
||||
<%= f.fields_for :title_translations do |f| %>
|
||||
<%= f.text_field locale, class: "input-block-level", placeholder: t(:title), value: (@group.title_translations[locale] rescue nil) %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Sub Title -->
|
||||
<div class="control-group input-subtitle">
|
||||
<label class="control-label muted"><%= t(:description) %></label>
|
||||
<div class="controls">
|
||||
<div class="textarea">
|
||||
<%= f.fields_for :description_translations do |f| %>
|
||||
<%= f.text_area locale, rows: 2, class: "input-block-level", value: (@group.description_translations[locale] rescue nil) %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Form Actions -->
|
||||
|
||||
<div class="form-actions">
|
||||
<%= f.submit t('submit'), class: 'btn btn-primary' %>
|
||||
<%= link_to t('cancel'), admin_groups_path, :class=>"btn" %>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var locale = "<%= I18n.locale.to_s %>";
|
||||
$(".member_selection").select2({
|
||||
formatResult: function (el) {
|
||||
var $el = $(el.element),
|
||||
member = $el.data("member"),
|
||||
name = (member.name[locale] == "" ? member.name.zh_tw : member.name[locale]),
|
||||
user_name = "(" + member.user_name + ")",
|
||||
text = name + " " + user_name;
|
||||
if (!el.id) { return el.text; }
|
||||
var $state = $(
|
||||
'<span><img src="' + member.avatar + '" class="img-avatar" /> ' + text + '</span>'
|
||||
);
|
||||
return $state;
|
||||
},
|
||||
placeholder: "Add Members"
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<% current_user_is_group_admin = group.admins.include?(current_user.id.to_s) ? true : false %>
|
||||
<li>
|
||||
<div class="member-avatar">
|
||||
|
||||
<p class="<%= current_user_is_group_admin ? "gender-man" : "gender-none" %>"></p>
|
||||
<div class="action">
|
||||
<%= link_to(content_tag(:i, nil, :class => 'icon-edit'),"#",:class=>"edit" ) if current_user_is_group_admin %>
|
||||
</div>
|
||||
<%= image_tag(group.image) %>
|
||||
</div>
|
||||
<div class="member-info">
|
||||
<h4 class="member-name"><%= link_to group.title, "#" %></h4>
|
||||
<%
|
||||
author = ""
|
||||
group.admins.each_with_index do |admin,i|
|
||||
user = User.find(admin) rescue nil
|
||||
if !user.nil?
|
||||
author = author + (user.member_profile.name == "" ? user.user_name : user.member_profile.name rescue "")
|
||||
author = author + ", " if i != group.admins.count - 1
|
||||
end
|
||||
end
|
||||
%>
|
||||
<div class="member-mail muted">Admin : <%= author %></div>
|
||||
<hr>
|
||||
<ul class="member-roles">
|
||||
<li>
|
||||
<%= group.description %>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
|
@ -0,0 +1,5 @@
|
|||
<% @categories.each do |cat| %>
|
||||
<div>
|
||||
<%= cat.title_translations["en"] %> / <%= cat.title_translations["zh_tw"] %>
|
||||
</div>
|
||||
<% end %>
|
|
@ -1 +1,83 @@
|
|||
this is category.
|
||||
<div id="group_categories">
|
||||
<%= render :partial => "group_categories" %>
|
||||
</div>
|
||||
<a href="" class="btn btn-primary" data-toggle="modal" data-target="#categoryModal">+</a>
|
||||
<div class="modal fade" id="categoryModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title" id="myModalLabel"><%= t(:new_category) %></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<% @site_in_use_locales.each do |locale| %>
|
||||
<div class="control-group">
|
||||
<label class="control-label"><%= "#{t(:name)} (#{t(locale)})" %></label>
|
||||
<div class="controls">
|
||||
<input class="input-large" id="<%=locale%>" name="category[title_translations][<%=locale%>]" placeholder="<%=t(:name)%>" type="text">
|
||||
<span class="help-inline hide">Please enter category title</span>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="text-error text-center"><%= t(:category_notice) %></div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default pull-left" data-dismiss="modal"><%= t(:close) %></button>
|
||||
<button type="button" class="btn btn-primary" id="add_category"><%= t(:add) %></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
$("#add_category").click(createCategory);
|
||||
|
||||
$("#categoryModal .modal-body").keypress(function(e) {
|
||||
if(e.which == 13) {
|
||||
createCategory();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$.each($('#categoryModal .input-large'),function(){
|
||||
$(this).blur(function(){
|
||||
if($(this).val()==""){
|
||||
$(this).parent().parent().addClass('error');
|
||||
$(this).next().removeClass('hide');
|
||||
}else{
|
||||
$(this).parent().parent().removeClass('error');
|
||||
$(this).next().addClass('hide');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
var createCategory = function(){
|
||||
var valid = true;
|
||||
$.each($('#categoryModal .input-large'),function(){
|
||||
if($(this).val()==""){
|
||||
$(this).parent().parent().addClass('error');
|
||||
$(this).next().removeClass('hide');
|
||||
valid = false;
|
||||
}else{
|
||||
$(this).parent().parent().removeClass('error');
|
||||
$(this).next().addClass('hide');
|
||||
}
|
||||
});
|
||||
|
||||
if(valid){
|
||||
$.ajax({
|
||||
url : "/admin/groups/create_category",
|
||||
type : "post",
|
||||
data: $("input[name^='category']").serialize(),
|
||||
}).done(function(data){
|
||||
$.each($('#categoryModal .input-large'),function(){
|
||||
$(this).val("");
|
||||
});
|
||||
$("#group_categories").html(data);
|
||||
$('#categoryModal').modal('hide');
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -1 +1,17 @@
|
|||
this is my group page
|
||||
<% content_for :page_specific_css do -%>
|
||||
|
||||
<%= stylesheet_link_tag "lib/wrap-nav" %>
|
||||
<%= stylesheet_link_tag "lib/main-list" %>
|
||||
<%= stylesheet_link_tag "lib/filter" %>
|
||||
<%= stylesheet_link_tag "lib/member" %>
|
||||
|
||||
<% end -%>
|
||||
<% content_for :page_specific_javascript do -%>
|
||||
<%= javascript_include_tag "lib/jquery.lite.image.resize.js" %>
|
||||
<%= javascript_include_tag "lib/member/list-view.js" %>
|
||||
<% end -%>
|
||||
<div id="list-view">
|
||||
<ul id="member-abstract" class="clearfix">
|
||||
<%= render :partial=>"group",:collection=> @groups %>
|
||||
</ul>
|
||||
</div>
|
|
@ -0,0 +1,5 @@
|
|||
<%= form_for @group, :url => admin_groups_path, :html => { :multipart => true , :class=>"form-horizontal main-forms"} do |f| %>
|
||||
<fieldset>
|
||||
<%= render :partial => "create_group_form", locals: {f: f} %>
|
||||
</fieldset>
|
||||
<% end %>
|
|
@ -52,6 +52,7 @@
|
|||
<%= content_tag :ul, :class => ("nav nav-list ") do -%>
|
||||
<%= content_tag :li, link_to((content_tag(:span, "My Groups")), admin_groups_path), :class => active_for_action('groups', 'index') %>
|
||||
<%= content_tag :li, link_to((content_tag(:span, "Categories")), admin_groups_categories_path), :class => active_for_action('groups','categories') %>
|
||||
<%= content_tag :li, link_to((content_tag(:span, "Create New Group")), new_admin_group_path), :class => active_for_action('groups','new') %>
|
||||
<% end -%>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/<%= locale.to_s %>/admin/members">
|
||||
<a href="/<%= locale.to_s %>/admin/members?at=thumbnail">
|
||||
<i class="icons-users"></i> <%= t(:member_) %>
|
||||
</a>
|
||||
</li>
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
OmniAuth.config.logger = Rails.logger
|
||||
|
||||
site = Site.first rescue nil
|
||||
if !site.nil?
|
||||
client_id = site.google_client_id
|
||||
client_secret = site.google_client_secret
|
||||
|
||||
site = Site.first
|
||||
client_id = site.google_client_id
|
||||
client_secret = site.google_client_secret
|
||||
|
||||
if !client_id.nil? && !client_secret.nil?
|
||||
Rails.application.config.middleware.use OmniAuth::Builder do
|
||||
provider :google_oauth2, client_id, client_secret,{ access_type: "offline", approval_prompt: "" }
|
||||
if !client_id.nil? && !client_secret.nil?
|
||||
Rails.application.config.middleware.use OmniAuth::Builder do
|
||||
provider :google_oauth2, client_id, client_secret,{ access_type: "offline", approval_prompt: "" }
|
||||
end
|
||||
else
|
||||
site.google_oauth_enabled = false
|
||||
site.save
|
||||
end
|
||||
else
|
||||
site.google_oauth_enabled = false
|
||||
site.save
|
||||
end
|
|
@ -122,6 +122,7 @@ Orbit::Application.routes.draw do
|
|||
|
||||
# GROUPS START HERE
|
||||
get "groups/categories" => 'groups#categories'
|
||||
post "groups/create_category" => 'groups#create_category'
|
||||
|
||||
resources :groups do
|
||||
|
||||
|
|
Loading…
Reference in New Issue