diff --git a/app/assets/javascripts/lib/list-check.js b/app/assets/javascripts/lib/list-check.js new file mode 100644 index 00000000..c21899fd --- /dev/null +++ b/app/assets/javascripts/lib/list-check.js @@ -0,0 +1,105 @@ +var ListCheck = function(element) { + this.element = $(element); + this.element.data('exists', true); + if(this.element.context.parentNode.tagName == "TD") { + this.elementWrap = $(this.element.context.parentNode); + this.elementWrap.addClass('listCheck'); + } else if(this.element.context.parentNode.tagName == "TH") { + this.elementWrap = $(this.element.context.parentNode); + this.elementWrap.addClass('listCheckHead'); + } + this.element.before(''); +}; + +$.fn.listCheck = function (callback) { + this.each(function (i) { + if(!$(this).data('exists')) { + new ListCheck(this); + }; + }); + this.on(clickEvent, function(e) { + if($(this).prop('checked')) { + $(this).siblings('i').addClass('icon-check').removeClass('icon-check-empty').closest('tr').addClass('checkHit'); + } else { + $(this).siblings('i').addClass('icon-check-empty').removeClass('icon-check').closest('tr').removeClass('checkHit'); + }; + if ($(this).closest('.listCheckHead').length) { + $('.listCheck .list-check').prop('checked', $(this).prop('checked')); + if($(this).prop('checked')) { + $('.listCheck i').addClass('icon-check').removeClass('icon-check-empty').closest('tr').addClass('checkHit'); + } else { + $('.listCheck i').addClass('icon-check-empty').removeClass('icon-check').closest('tr').removeClass('checkHit'); + } + }; + + var _isCheck = $('tbody .list-check').filter(':checked').length, + _defaultLength = $('tbody .list-check').length; + + if(_isCheck > 0 && _isCheck < _defaultLength) { + $('.listCheckHead i').removeClass('icon-check-empty icon-check').addClass('icon-minus'); + } else if(!_isCheck) { + $('.listCheckHead i').removeClass('icon-minus icon-check').addClass('icon-check-empty'); + } else { + $('.listCheckHead i').removeClass('icon-check-empty icon-minus').addClass('icon-check'); + } + _isCheck ? $('.list-active-btn').removeClass('disabled').data('actionable', true) : $('.list-active-btn').addClass('disabled').data('actionable', false); + }); +}; +function clearCheck() { + $('.list-check').each(function() { + $(this).prop('checked', false); + }) +} +function actionSuccess(e) { + $("tbody .list-check").each(function() { + switch(e) { + case 'list-be-hide': + $(this).filter(':checked').closest('tr').addClass('checkHide'); + break; + case 'list-be-show': + $(this).filter(':checked').closest('tr').removeClass('checkHide'); + break; + case 'list-be-remove': + $(this).filter(':checked').closest('tr').fadeOut(300, function() { + $(this).remove(); + }); + break; + }; + $('.list-check').siblings('i').removeAttr('class').addClass('icon-check-empty').closest('tr').removeClass('checkHit'); + }); + clearCheck(); +} +$(function() { + var $t = null, + _data = null; + clearCheck(); + $('.list-check').listCheck(); + $('.list-active-btn').data('actionable', false).on(clickEvent, function(e) { + $t = $(this) + _data = $(this).data() + _data.actionable ? $('#dialog').modal('show') : ""; + e.preventDefault(); + }); + + $("#dialog").on('show', function (e) { + $(this).find('.delete-item').on(clickEvent, function() { + var _v = []; + $("tbody .list-check").each(function() { + this.checked && _v.push("ids[]="+this.value) + }); + var _t = $t.attr("rel"); + if(_t.indexOf("?") > -1) { + $.ajax(_t + "&" + _v.join("&")).done(function() { + actionSuccess(_data.checkAction) + }); + } else { + $.ajax(_t + "?" + _v.join("&")).done(function() { + actionSuccess(_data.checkAction) + }); + } + $('#dialog').modal('hide'); + $('.list-active-btn').addClass('disabled').data('actionable', false); + e.preventDefault(); + }) + }); +}); \ No newline at end of file diff --git a/app/assets/stylesheets/lib/list-check.css b/app/assets/stylesheets/lib/list-check.css new file mode 100644 index 00000000..5e5e05b5 --- /dev/null +++ b/app/assets/stylesheets/lib/list-check.css @@ -0,0 +1,28 @@ +.table .listCheckHead, +.table .listCheck { + width: 30px; + vertical-align: middle; + padding: 0 0 0 10px!important; +} +.listCheckHead .list-check, +.listCheck .list-check { + position: absolute; + margin: -12px 0 0 -1px; + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; + filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0); + opacity: 0; +} +.listCheckHead i, +.listCheck i { + display: block; +} +.checkHide td { + background-color: #E6E6E6 !important; + color: #B9B9B9; +} +.checkHide a { + color: #B9B9B9; +} +.checkHit td { + background-color: #FFFEDB !important; +} \ No newline at end of file diff --git a/app/assets/stylesheets/lib/member.css b/app/assets/stylesheets/lib/member.css index a2bf3195..5a9c6cf2 100644 --- a/app/assets/stylesheets/lib/member.css +++ b/app/assets/stylesheets/lib/member.css @@ -3,9 +3,9 @@ color: #000; text-decoration: none; display: block; - overflow: hidden; width: 100%; text-overflow: ellipsis; + overflow: hidden; white-space: nowrap; } @@ -364,6 +364,9 @@ #profile #module-navbar { margin-left: 10px; } +#profile #module-navbar .navbar { + margin-bottom: 15px; +} #profile #member-module { margin-left: 360px; } @@ -372,9 +375,13 @@ } #profile #member-module #module-content .content { right: 10px; + padding-bottom: 10px; outline: none; } - +#profile #member-module #module-content .list-active { + padding-bottom: 8px; + /*border-bottom: 1px solid #DDD;*/ +} /* Responsive */ @media (max-width: 979px) { diff --git a/app/assets/stylesheets/lib/wrap-nav.css b/app/assets/stylesheets/lib/wrap-nav.css index a1bb13f7..80622262 100644 --- a/app/assets/stylesheets/lib/wrap-nav.css +++ b/app/assets/stylesheets/lib/wrap-nav.css @@ -26,6 +26,9 @@ margin-top: 4px; margin-left: 10px; } +.topnav .btn-group { + margin-left: 0; +} /* Bottom Nav */ .bottomnav { diff --git a/app/controllers/admin/personal_plugin_intros_controller.rb b/app/controllers/admin/personal_plugin_intros_controller.rb new file mode 100644 index 00000000..2d726f55 --- /dev/null +++ b/app/controllers/admin/personal_plugin_intros_controller.rb @@ -0,0 +1,83 @@ +class Admin::PersonalPluginIntrosController < OrbitMemberController + + include OrbitControllerLib::DivisionForDisable + + before_filter :authenticate_user! + before_filter :is_admin? + + + def index + + get_types + @plugin_intro = @types.where(:user_id => params[:user_id]).first + + if @plugin_intro.blank? + + @set_type = @types.new() + @url = eval("panel_#{@app_type_name}_back_end_#{@app_type}s_path(:user_id=>params[:user_id])") + @verb = :post + + else + + @set_type = @types.find(@plugin_intro.id) + @url = polymorphic_path(["panel_#{@app_type_name}_back_end", @plugin_intro]) + @verb = :put + + end + + end + + + def show + + end + + + def new + end + + + def edit + end + + def create + + get_types + + @plugin_intro = @types.new(params[:plugin_intro]) + + respond_to do |format| + if @plugin_intro.save + format.html { redirect_to(admin_users_new_interface_url(:id=>params[:plugin_intro][:user_id],:show_plugin_profile=>@reback_name)) } + end + end + + end + + + def update + + get_types + + @plugin_intro = @types.find(params[:id]) + + respond_to do |format| + + if @plugin_intro.update_attributes(params[:plugin_intro]) + format.html { redirect_to(admin_users_new_interface_url(:id=>params[:plugin_intro][:user_id],:show_plugin_profile=>@reback_name)) } + end + end + + end + + + def destroy + end + + protected + + def get_types + @types = @app_type.classify.constantize + end + +end diff --git a/app/controllers/admin/users_new_interface_controller.rb b/app/controllers/admin/users_new_interface_controller.rb index 4f4e352f..f7a1bdf4 100644 --- a/app/controllers/admin/users_new_interface_controller.rb +++ b/app/controllers/admin/users_new_interface_controller.rb @@ -98,9 +98,11 @@ class Admin::UsersNewInterfaceController < OrbitMemberController if(!params[:show_plugin_profile].nil?) - @right_partial = OrbitApp::Plugin::Registration.find_by_key(params[:show_plugin_profile]).profile_partial_path rescue 'plugin_summary' + @right_partial = OrbitApp::Plugin::Registration.find_by_app_name(params[:show_plugin_profile]).profile_partial_path rescue 'plugin_summary' + @plugin_app_name = OrbitApp::Plugin::Registration.find_by_app_name(params[:show_plugin_profile]).name rescue nil else @right_partial = "plugin_summary" + @plugin_app_name = '' end # @user.attribute_values.each{|att_val| diff --git a/app/models/user/personal_plugin_intro.rb b/app/models/user/personal_plugin_intro.rb new file mode 100644 index 00000000..8dec3b27 --- /dev/null +++ b/app/models/user/personal_plugin_intro.rb @@ -0,0 +1,28 @@ +class PersonalPluginIntro + + include Mongoid::Document + include Mongoid::Timestamps + # include OrbitCoreLib::ObjectAuthable + # include OrbitCoreLib::ObjectDisable + + # has_and_belongs_to_many :users + belongs_to :user + + field :text, localize: true + field :brief_intro, :type => Boolean, :default => false + field :complete_list, :type => Boolean, :default => true + + + def pp_object + brief_intro + end + + def self.from_id(id) + PersonalPluginIntro.find(id) rescue nil + end + + def self.is_localized?(field_name) + self.fields[field_name.to_s].localized? + end + +end \ No newline at end of file diff --git a/app/models/user/user.rb b/app/models/user/user.rb index c8a682c8..b726c0f3 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -38,12 +38,15 @@ class User has_and_belongs_to_many :sub_role_tags has_many :user_actions, :dependent => :destroy + + has_many :personal_plugin_intro # has_and_belongs_to_many :statuses has_and_belongs_to_many :roles has_and_belongs_to_many :sub_roles has_and_belongs_to_many :role_statuses has_and_belongs_to_many :role_categorys + accepts_nested_attributes_for :attribute_values, :allow_destroy => true before_create :initialize_desktop diff --git a/app/views/admin/personal_plugin_intros/index.html.erb b/app/views/admin/personal_plugin_intros/index.html.erb new file mode 100644 index 00000000..3c399fd5 --- /dev/null +++ b/app/views/admin/personal_plugin_intros/index.html.erb @@ -0,0 +1,117 @@ +<% # encoding: utf-8 %> + +<% content_for :side_bar do %> + <%= render :partial => 'layouts/side_bar', :locals => {:link_name => t(:user), :link_url => admin_site_site_info_path(@site), :icon => 'icons-users', :side_bar_content => 'admin/users_new_interface/side_bar'} %> +<% end %> + +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "lib/main-forms" %> + <%= stylesheet_link_tag "lib/fileupload" %> + <%= stylesheet_link_tag "lib/main-list" %> +<% end %> +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "lib/bootstrap-fileupload" %> + <%= javascript_include_tag "lib/file-type" %> +<% end %> + +<%= form_for(:plugin_intro, :url => @url, :method => @verb, html: {class: "form-horizontal main-forms previewable"} ) do |f| %> + +<%= f.error_messages %> + +
+ + +
+ + + + + + +
+ + +
+ + <% if !params[:user_id].blank? %> + +
+ +
+ <%= User.from_id(params[:user_id]).name rescue ''%> +
+
+ + <% end %> + + +
+ +
+ <%= f.check_box :brief_intro, :checked => @set_type.brief_intro %> <%= t("personal_plugins.brief_intro") %> + <%= f.check_box :complete_list, :checked => @set_type.complete_list %> <%= t("personal_plugins.complete_list") %> +
+
+ +
+ +
+ + + + + + +
+ + <% @site_valid_locales.each_with_index do |locale, i| %> + +
"> + + +
+ +
+
+ <%= f.fields_for :text_translations do |f| %> + <%= f.cktext_area locale, rows: 5, class: "input-block-level", :value => (@set_type.text_translations[locale] rescue nil) %> + <% end %> +
+
+
+ + +
+ + <% end %> + + + +
+ + + +
+ + +
+ <%= f.hidden_field :user_id, :value => params[:user_id] if !params[:user_id].blank? %> + <%= f.submit t('submit'), class: 'btn btn-primary' %> + <%= link_to t('cancel'), get_go_back, :class=>"btn" %> +
+ + +
+ +<% end %> \ No newline at end of file diff --git a/app/views/admin/users_new_interface/_plugin_summary.html.erb b/app/views/admin/users_new_interface/_plugin_summary.html.erb index 1c1c0589..3b3ef767 100644 --- a/app/views/admin/users_new_interface/_plugin_summary.html.erb +++ b/app/views/admin/users_new_interface/_plugin_summary.html.erb @@ -1,46 +1,46 @@ -
-

Module Name

-
- - - - - - - -
模組數量
-
-
-
-
-
-
-
-
-
-
- - - - - - - - - - - - - - - - - - - -
University2,304
Master783
Doctor45
Staff62
-
-
-
+
+

Module Name

+
+ + + + + + + +
<%= t(:module) %><%= t(:quantity) %>
+
+
+
+
+
-
\ No newline at end of file +
+
+
+
+ + + + <% + @plugins.each do |plugin| + + if is_admin? + @data = plugin.app_name.classify.constantize.where(:create_user_id=>@user.id).count + else + @data = plugin.app_name.classify.constantize.where(:is_hidden=>false , :create_user_id=>@user.id).count + end + %> + + + + + <% end -%> + + +
<%= plugin.name %><%= @data %>
+
+
+
+
+
\ No newline at end of file diff --git a/app/views/admin/users_new_interface/index.html.erb b/app/views/admin/users_new_interface/index.html.erb index d639725e..b72e62d4 100644 --- a/app/views/admin/users_new_interface/index.html.erb +++ b/app/views/admin/users_new_interface/index.html.erb @@ -5,7 +5,8 @@ <%= render :partial => "js_and_css"%> -
+<% content_for :right_nav do %> +
<%= text_field_tag 'mq',( params[:mq] ? params[:mq] : '' ), {:id=>'filter-input', :class => "search-query input-medium", :placeholder => 'Search'} %> @@ -34,8 +35,8 @@
-
- + +<% end %>
diff --git a/app/views/admin/users_new_interface/index_summary.html.erb b/app/views/admin/users_new_interface/index_summary.html.erb index aaa34db5..0bd2e430 100644 --- a/app/views/admin/users_new_interface/index_summary.html.erb +++ b/app/views/admin/users_new_interface/index_summary.html.erb @@ -5,8 +5,9 @@ <%= render :partial => "js_and_css"%> -
-
+<% content_for :right_nav do %> + +
<%= text_field_tag 'mq',( params[:mq] ? params[:mq] : '' ), {:id=>'filter-input', :class => "search-query input-medium", :placeholder => 'Search'} %> @@ -35,7 +36,8 @@
-
+ +<% end %>
    diff --git a/app/views/admin/users_new_interface/index_thumbnail.html.erb b/app/views/admin/users_new_interface/index_thumbnail.html.erb index 6b303c27..df37ddf5 100644 --- a/app/views/admin/users_new_interface/index_thumbnail.html.erb +++ b/app/views/admin/users_new_interface/index_thumbnail.html.erb @@ -5,8 +5,9 @@ <%= render :partial => "js_and_css"%> -
    -
    +<% content_for :right_nav do %> + +
    <%= text_field_tag 'mq',( params[:mq] ? params[:mq] : '' ), {:id=>'filter-input', :class => "search-query input-medium", :placeholder => 'Search'} %> @@ -35,7 +36,8 @@
    -
    + +<% end %>
      diff --git a/app/views/admin/users_new_interface/show.html.erb b/app/views/admin/users_new_interface/show.html.erb index 07a59cfd..bcdc4be1 100644 --- a/app/views/admin/users_new_interface/show.html.erb +++ b/app/views/admin/users_new_interface/show.html.erb @@ -43,7 +43,7 @@