diff --git a/app/assets/javascripts/admin/role_statuses.js.coffee b/app/assets/javascripts/admin/role_statuses.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/admin/role_statuses.js.coffee @@ -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/ diff --git a/app/assets/stylesheets/admin/role_statuses.css.scss b/app/assets/stylesheets/admin/role_statuses.css.scss new file mode 100644 index 0000000..cf7895d --- /dev/null +++ b/app/assets/stylesheets/admin/role_statuses.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the admin/role_statuses controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/admin/role_statuses_controller.rb b/app/controllers/admin/role_statuses_controller.rb new file mode 100644 index 0000000..f62b950 --- /dev/null +++ b/app/controllers/admin/role_statuses_controller.rb @@ -0,0 +1,54 @@ +class Admin::RoleStatusesController < OrbitMemberController + before_action :set_role_status, only: [:show, :edit , :update, :destroy] + + def index + @role = Role.find(params[:role_id]) + @role_statuses = RoleStatus.where(role_id: @role.id) + + respond_to do |format| + format.html # index.html.erb + format.js + end + end + + def show + end + + def new + @role_status = RoleStatus.new + render layout: false + end + + def create + @role_status = RoleStatus.new(role_status_params) + if @role_status.save + redirect_to action: :index + else + redirect_to action: :new + end + end + + def edit + render layout: false + end + + def update + end + + def toggle + end + + def destroy + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_role_status + @role_status = RoleStatus.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def role_status_params + params.require(:role_status).permit! + end +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4c37e7f..cece132 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -6,7 +6,7 @@ class UsersController < ApplicationController def create @user = User.new(user_params) - @member = MemberProfile.new(email: params[:email]) + @member = MemberProfile.new(email: params[:email], first_name: params[:first_name], last_name: params[:last_name]) if @user.save @member.save @user.update_attributes(member_profile_id: @member.id) @@ -35,6 +35,6 @@ class UsersController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def user_params - params.require(:user).permit(:password, :password_confirmation, :user_name, :member_profile_id, :email) + params.require(:user).permit(:password, :password_confirmation, :user_name, :member_profile_id, :email, :first_name, :last_name) end end diff --git a/app/helpers/admin/role_statuses_helper.rb b/app/helpers/admin/role_statuses_helper.rb new file mode 100644 index 0000000..3a93582 --- /dev/null +++ b/app/helpers/admin/role_statuses_helper.rb @@ -0,0 +1,2 @@ +module Admin::RoleStatusesHelper +end diff --git a/app/models/role.rb b/app/models/role.rb index c209791..bb207d8 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -8,6 +8,7 @@ class Role has_and_belongs_to_many :member_profiles has_many :authorizations embeds_many :role_fields + has_many :role_statuses def is_built_in? self.built_in diff --git a/app/models/role_status.rb b/app/models/role_status.rb new file mode 100644 index 0000000..32b3cd5 --- /dev/null +++ b/app/models/role_status.rb @@ -0,0 +1,16 @@ +class RoleStatus + include Mongoid::Document + field :key, type: String + field :title, type: String, localize: true + field :disable, type: Boolean, default: false + + scope :can_display, ->{ where(disable: false) } + + has_and_belongs_to_many :member_profile + belongs_to :role + + def self.get_role_data(role_key) + @role = Role.find_by(key: role_key) + return @role.id + end +end diff --git a/app/models/user.rb b/app/models/user.rb index ec297b2..6ada238 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -23,7 +23,7 @@ class User validates :password, presence: true, :on => :create, length: {:in => 8..20} #Add getter and setter for email virtual field - attr_accessor :email + attr_accessor :email, :first_name, :last_name def generate_confirmation_token self.confirmation_token = SecureRandom.hex(5) diff --git a/app/views/admin/member_infos/edit.html.erb b/app/views/admin/member_infos/edit.html.erb index df66b88..41720ba 100644 --- a/app/views/admin/member_infos/edit.html.erb +++ b/app/views/admin/member_infos/edit.html.erb @@ -20,7 +20,7 @@
- +
diff --git a/app/views/admin/role_statuses/_form.html.erb b/app/views/admin/role_statuses/_form.html.erb new file mode 100644 index 0000000..d5c4789 --- /dev/null +++ b/app/views/admin/role_statuses/_form.html.erb @@ -0,0 +1,10 @@ +<%= label_tag "key","key", :class=>"muted" %> +<%= f.text_field :key, :class=>"input-large" %> + +<%= f.fields_for :title_translations do |f| %> + <% @site_in_use_locales.each do |locale| %> + <%= label_tag "name-#{locale}", "#{t(:name)} (#{I18nVariable.from_locale(locale)})" %> + <%= f.text_field locale, :class => 'input-large', :value => (@role_filter.title_translations[locale] rescue ''), placeholder: t(:name) %> + <% end %> +<% end %> +<%= f.hidden_field :role_id, :value => params[:role_id] if !params[:role_id].blank? %> \ No newline at end of file diff --git a/app/views/admin/role_statuses/_index.html.erb b/app/views/admin/role_statuses/_index.html.erb new file mode 100644 index 0000000..c5523c9 --- /dev/null +++ b/app/views/admin/role_statuses/_index.html.erb @@ -0,0 +1,16 @@ + + + + + <% @site_in_use_locales.each do |locale| %> + + <% end %> + + + + + <%= render :partial => 'role_status', :collection => @role_status %> + +
Key<%= I18nVariable.from_locale(locale) %>
+ + diff --git a/app/views/admin/role_statuses/_new.html.erb b/app/views/admin/role_statuses/_new.html.erb new file mode 100644 index 0000000..538424b --- /dev/null +++ b/app/views/admin/role_statuses/_new.html.erb @@ -0,0 +1,10 @@ +<%= form_for @role_status, url: admin_role_status_path(id: @role_status.id), remote: true, :html => { :id => 'form_role_filter' } do |f| %> +
+ Add + <%= render :partial => 'form', :locals => {:f => f} %> +
+
+ <%= t(:cancel) %> + <%= f.submit t(:create_), class: 'btn btn-primary btn-small' %> +
+<% end %> \ No newline at end of file diff --git a/app/views/admin/role_statuses/_role_status.html.erb b/app/views/admin/role_statuses/_role_status.html.erb new file mode 100644 index 0000000..89fb94b --- /dev/null +++ b/app/views/admin/role_statuses/_role_status.html.erb @@ -0,0 +1,19 @@ + + <%= role_status.key %> + <% @site_in_use_locales.each_with_index do |locale, i| %> + + <%= role_status.title_translations[locale] rescue nil %> + <% if i == 0 %> +
+ +
+ <% end %> + + <% end %> + + + <%= check_box_tag 'accept', role_status.disable ? 'fasle' : 'true', false ,{ :class => 'toggle-check role_status_checked', :data=>{:deploy=>"right"}, :data=>{:path=> eval("admin_role_status_toggle_path(role_status)")}, :checked=> role_status.disable} %> + + \ No newline at end of file diff --git a/app/views/admin/role_statuses/index.html.erb b/app/views/admin/role_statuses/index.html.erb new file mode 100644 index 0000000..b7ed513 --- /dev/null +++ b/app/views/admin/role_statuses/index.html.erb @@ -0,0 +1,20 @@ +<% 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-list.css" %> + <%= stylesheet_link_tag "lib/togglebox.css" %> +<% end -%> + +
+
+ <%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add), eval("new_admin_role_status_path(role_id: params[:role_id])"), class: "btn btn-primary open-slide" %> +
+
+ +
+ <%= render 'index' %> +
\ No newline at end of file diff --git a/app/views/admin/role_statuses/new.html.erb b/app/views/admin/role_statuses/new.html.erb new file mode 100644 index 0000000..e3355a9 --- /dev/null +++ b/app/views/admin/role_statuses/new.html.erb @@ -0,0 +1 @@ +<%= render 'new' %> \ No newline at end of file diff --git a/app/views/admin/role_statuses/new.js.erb b/app/views/admin/role_statuses/new.js.erb new file mode 100644 index 0000000..40061b9 --- /dev/null +++ b/app/views/admin/role_statuses/new.js.erb @@ -0,0 +1 @@ +$("#form > form").replaceWith("<%= j render "form" %>"); diff --git a/app/views/admin/roles/_role.html.erb b/app/views/admin/roles/_role.html.erb index 985a60f..79c6db1 100644 --- a/app/views/admin/roles/_role.html.erb +++ b/app/views/admin/roles/_role.html.erb @@ -6,6 +6,7 @@
diff --git a/app/views/member/new.html.erb b/app/views/member/new.html.erb deleted file mode 100644 index d4ab3fd..0000000 --- a/app/views/member/new.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -

Member#new

-

Find me in app/views/member/new.html.erb

diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb index 32f7ff3..bbf41af 100644 --- a/app/views/users/new.html.erb +++ b/app/views/users/new.html.erb @@ -22,6 +22,26 @@ +
+ +
+ <%= text_field_tag :first_name, "", class: "availibility", id: "user_first_name", placeholder: t("users.first_name") %> + + Not Available + Available +
+
+ +
+ +
+ <%= text_field_tag :last_name, "", class: "availibility", id: "user_last_name", placeholder: t("users.last_name") %> + + Not Available + Available +
+
+
diff --git a/config/routes.rb b/config/routes.rb index dd8de08..f77518b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -49,8 +49,6 @@ Orbit::Application.routes.draw do resources :passwords - - namespace :admin do resources :dashboards do collection do @@ -70,6 +68,10 @@ Orbit::Application.routes.draw do end resources :member_infos + + resources :role_statuses do + post 'toggle' + end resources :module_apps do resources :categories do diff --git a/test/controllers/admin/role_statuses_controller_test.rb b/test/controllers/admin/role_statuses_controller_test.rb new file mode 100644 index 0000000..974e26d --- /dev/null +++ b/test/controllers/admin/role_statuses_controller_test.rb @@ -0,0 +1,9 @@ +require 'test_helper' + +class Admin::RoleStatusesControllerTest < ActionController::TestCase + test "should get index" do + get :index + assert_response :success + end + +end diff --git a/test/fixtures/role_statuses.yml b/test/fixtures/role_statuses.yml new file mode 100644 index 0000000..ddd653b --- /dev/null +++ b/test/fixtures/role_statuses.yml @@ -0,0 +1,9 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + key: MyString + title: MyString + +two: + key: MyString + title: MyString diff --git a/test/helpers/admin/role_statuses_helper_test.rb b/test/helpers/admin/role_statuses_helper_test.rb new file mode 100644 index 0000000..de90517 --- /dev/null +++ b/test/helpers/admin/role_statuses_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class Admin::RoleStatusesHelperTest < ActionView::TestCase +end diff --git a/test/models/role_status_test.rb b/test/models/role_status_test.rb new file mode 100644 index 0000000..9c374e0 --- /dev/null +++ b/test/models/role_status_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class RoleStatusTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end