Personal Plugin Registration

This commit is contained in:
Saurabh Bhatia 2014-06-04 16:46:29 +08:00
parent 72a027c91c
commit bc4b687c42
17 changed files with 120 additions and 15 deletions

View File

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@ -0,0 +1,3 @@
// Place all the styles related to the admin/personal_plugins controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -74,6 +74,20 @@ class Admin::MembersController < OrbitMemberController
def show
@custom_fields = @member.member_profile_field_values rescue nil
@plugins = OrbitApp::Plugin::Registration.all rescue nil
@ppname = Array.new
@plugins.each do |aa|
@ppname << [aa.sort_number.to_i, [aa.name, aa.app_name, aa.intro_app_name, aa.front_partial_path]]
end
@plugin_shows = @ppname.sort.collect {|v| {"name"=>v[1][0],"app_name"=>v[1][1],"intro_app_name"=>v[1][2],"front_partial_path"=>v[1][3]} }
if(!params[:show_plugin_profile].nil?)
@plugin_app_name = OrbitApp::Plugin::Registration.find_by(app_name: params[:show_plugin_profile]).name rescue nil
else
@plugin_app_name = ''
end
get_info_and_roles
end
def new

View File

@ -0,0 +1,5 @@
class Admin::PersonalPluginsController < OrbitMemberController
def index
@plugins = OrbitApp::Plugin::Registration.all rescue nil
end
end

View File

@ -0,0 +1,2 @@
module Admin::PersonalPluginsHelper
end

View File

@ -48,8 +48,14 @@ class MemberProfile
end
end
def new_attribute_values=(fields)
fields.each do |key,field|
self.member_profile_field_values.build(field)
end
end
def get_attribute_value(attribute_field)
attribute_values.find_by(attribute_field_id: attribute_field.id)
MemberProfileFieldValue.find_by(member_profile_field_id: attribute_field.id.to_s)
end
def get_attribute_values

View File

@ -10,12 +10,12 @@
<% content_for :page_specific_javascript do -%>
<% ( params[:id].blank? ? @fname = 'new_attribute_values' : @fname = 'attribute_values' ) %>
<% ( params[:id].blank? ? @fname = 'new_attribute_values' : @fname = 'member_profile_field_values' ) %>
console.log(<%= @fname%>);
<!-- Text -->
<script id="template-text" type="text/x-tmpl">
<div class="input-append">
<input type="text" id="${roleType+'_text_'+appendIndex}" name="${'user[<%= @fname %>]['+nameNumber+'][value][]'}" class="input-medium" placeholder="">
<input type="text" id="${roleType+'_text_'+appendIndex}" name="${'member_profile[<%= @fname %>]['+nameNumber+'][value][]'}" class="input-medium" placeholder="">
<a href="#" class="btn remove-input">
<i class="icon-trash"></i>
</a>
@ -31,7 +31,7 @@
<% active = (locale == @site_in_use_locales.first ? "active" : "") %>
<div class="tab-pane fade <%= active %> in" id="${roleType+'_text_language_<%= locale %>_'+appendIndex}">
<input type="text" name="${'user[<%= @fname %>]['+nameNumber+'][value][][<%= locale %>]'}" placeholder="<%= I18nVariable.from_locale(locale) %>" value="">
<input type="text" name="${'member_profile[<%= @fname %>]['+nameNumber+'][value][][<%= locale %>]'}" placeholder="<%= I18nVariable.from_locale(locale) %>" value="">
</div>
<% end %>

View File

@ -25,7 +25,7 @@
<div class="sub-nav-block-list">
<div class="sub-nav-block" data-icons="&#xe00d;">
<h4><%= t(:member_) %></h4>
<%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('members', 'roles','member_infos')) do -%>
<%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('members', 'roles','member_infos', 'personal_plugins')) do -%>
<%= content_tag :li, link_to((content_tag(:span, t(:all_member))), admin_members_path), :class => active_for_action('members', 'index') %>
<%= content_tag :li, link_to((content_tag(:span, t(:add_member))), new_admin_member_path), :class => active_for_action('members', 'new') if (current_user.is_admin? rescue nil) %>
<%= content_tag :li, link_to((content_tag(:span, t(:member_role))),admin_roles_path ), :class => active_for_action('roles', 'index') if (current_user.is_admin? rescue nil) %>
@ -36,7 +36,7 @@
<div class="sub-nav-block" data-icons="&#xe070;">
<h4><%= t(:academic_info) %></h4>
<%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('members', 'roles','member_infos')) do -%>
<%= content_tag :li, link_to((content_tag(:span, t(:list_)))), :class => active_for_action('members', 'index') %>
<%= content_tag :li, link_to((content_tag(:span, t(:list_))), admin_personal_plugins_path), :class => active_for_action('members', 'index') %>
<% end -%>
</div>
<div class="sub-nav-block" data-icons="&#xe070;">

View File

@ -34,10 +34,30 @@
</div>
<div id="member-module">
<div id="module-navbar">
<div class="navbar">
<div class="navbar-inner">
<span class="brand">
<%= @plugin_app_name.nil? ? t(:all_plugin_summary) : @plugin_app_name %>
</span>
<ul class="nav pull-right">
<li class="divider-vertical"></li>
<li class="dropdown">
<a data-toggle="dropdown" class="dropdown-toggle" href="#">Module List <b class="caret"></b></a>
<ul class="dropdown-menu">
<% @plugin_shows.each do |plugin| %>
<%= content_tag :li, :class=>(params[:show_plugin_profile] == plugin["app_name"] ? "active" : nil) do %>
<%= link_to plugin["name"], :show_plugin_profile => plugin["app_name"] %>
<% end -%>
<% end -%>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,18 @@
<div id="module-nav">
<div class="arrow_next pull-right"><i class="icon-chevron-right"></i></div>
<div class="arrow_prev pull-left"><i class="icon-chevron-left"></i></div>
<div class="module-nav-view">
<ul class="nav nav-pills">
<%= content_tag :li, :class=>(params[:show_plugin_profile].nil? ? "active" : nil) do %>
<%= link_to t(:all_plugin_summary)%>
<% end -%>
<% @plugins.each do |plugin| %>
<%= content_tag :li, :class=>(params[:show_plugin_profile] == plugin.app_name ? "active" : nil) do %>
<%= link_to plugin.name, admin_personal_plugins_path(:show_plugin_profile => plugin.app_name) %>
<% end -%>
<% end -%>
</ul>
</div>
</div>

View File

@ -0,0 +1,7 @@
<% content_for :side_bar do %>
<%= render :partial => 'admin/members/side_bar' %>
<% end %>
<div id="isotope" class="user-data">
<%= render :partial => 'plugin_list' %>
</div>

View File

@ -5,6 +5,13 @@ gem 'gallery', git: 'git@gitlab.tp.rulingcom.com:saurabh/gallery.git'
gem 'links', git: 'git@gitlab.tp.rulingcom.com:saurabh/links.git'
gem 'page_content', git: 'git@gitlab.tp.rulingcom.com:saurabh/pagecontent.git'
gem 'faq', git: 'git@gitlab.tp.rulingcom.com:saurabh/faq.git'
#Personal Plugins
gem 'personal_journal', git: 'git@gitlab.tp.rulingcom.com:saurabh/personal-journal.git'
gem 'personal_lab', git: 'git@gitlab.tp.rulingcom.com:saurabh/personal-lab.git'
gem 'personal_conference', git: 'git@gitlab.tp.rulingcom.com:saurabh/personal-conference.git'
gem 'personal_experience', git: 'git@gitlab.tp.rulingcom.com:saurabh/personal-experience.git'
gem 'personal_diploma', git: 'git@gitlab.tp.rulingcom.com:saurabh/personal-diploma.git'
gem 'personal_honor', git: 'git@gitlab.tp.rulingcom.com:saurabh/personal-honor.git'
gem 'personal_patent', git: 'git@gitlab.tp.rulingcom.com:saurabh/personal-patent.git'
gem 'personal_project', git: 'git@gitlab.tp.rulingcom.com:saurabh/personal-project.git'
gem 'personal_research', git: 'git@gitlab.tp.rulingcom.com:saurabh/personal-research.git'

View File

@ -97,6 +97,8 @@ Orbit::Application.routes.draw do
match "edit_privilege" => "members#edit_privilege" ,:as => :edit_privilege, via: [:get, :post]
end
resources :personal_plugins
resources :roles do
get 'role_field'
post 'toggle'

View File

@ -31,7 +31,7 @@ module OrbitApp
end
class RegisteredModule
attr_reader :name,:key,:module_label,:widget_methods,:authorizable_models,:is_authorizable, :data_count, :widget_settings
attr_reader :name,:key,:base_path, :module_label,:widget_methods,:authorizable_models,:is_authorizable, :data_count, :widget_settings
def initialize(name,&block)
@name = name
@ -159,6 +159,10 @@ module OrbitApp
def get_data_count
@data_count
end
def personal_plugin(params) #setter for personal_plugin from init
Plugin::Registration.new_from_module_app(@name,@key,@base_path,params)
end
end
end
end

View File

@ -4,6 +4,7 @@ module OrbitApp
Version = "0.5"
module ClassMethods
cattr_accessor :registrations
self.registrations = []
def new(name ,&block)
@ -11,7 +12,7 @@ module OrbitApp
end
def new_from_module_app(name,key,base_path,*args)
self.registrations << DataSheet.new(name,args,:base_path=>base_path)
self.registrations << DataSheet.new(name,args,base_path: base_path)
end
def find_by_app_name(name)

View File

@ -0,0 +1,9 @@
require 'test_helper'
class Admin::PersonalPluginsControllerTest < ActionController::TestCase
test "should get index" do
get :index
assert_response :success
end
end

View File

@ -0,0 +1,4 @@
require 'test_helper'
class Admin::PersonalPluginsHelperTest < ActionView::TestCase
end