Listing for Module-apps
This commit is contained in:
parent
3d9fd359ed
commit
c0efb5d1bc
|
@ -4,14 +4,15 @@ class Admin::AppAuthsController < ApplicationController
|
||||||
before_filter :is_admin?
|
before_filter :is_admin?
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@roles = Role.all.entries
|
# @roles = Role.all.entries
|
||||||
apps = Purchase.where(:type =>"App")
|
# apps = Purchase.where(:type =>"App")
|
||||||
@app_auth_data = apps.entries.map do |app|
|
# @app_auth_data = apps.entries.map do |app|
|
||||||
app_c = eval(app.app_controller)
|
# app_c = eval(app.app_controller)
|
||||||
obj = app_c.new
|
# obj = app_c.new
|
||||||
obj_auth = obj.send "auth"
|
# obj_auth = obj.send "auth"
|
||||||
[:app_obj => app,:auth_field => obj_auth]
|
# [:app_obj => app,:auth_field => obj_auth]
|
||||||
end
|
# end
|
||||||
|
@module_apps = ModuleApp.all
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
|
@ -12,4 +12,22 @@ class Admin::ModuleAppsController < ApplicationController
|
||||||
format.js {}
|
format.js {}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
@module_app = ModuleApp.find(params[:id])
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
@module_app = ModuleApp.find(params[:id])
|
||||||
|
unless params['module_app']['enable_frontend'].nil?
|
||||||
|
@module_app.update_attribute('enable_frontend',params['module_app']['enable_frontend'])
|
||||||
|
@module_app.save!
|
||||||
|
end
|
||||||
|
@attribute = @module_app
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { redirect_to :action => :index }
|
||||||
|
format.js { render 'admin/attributes/toggle_enable' }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
|
@ -0,0 +1,6 @@
|
||||||
|
module Admin::AppAuthHelper
|
||||||
|
def on_off_switch(attribute,attribute_type)
|
||||||
|
link_to t(:enable), eval("admin_#{attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :#{attribute_type} => {:disabled => true})"), :remote => true, :method => :put, :id => "disable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? 'none' : ''}", :class => 'switch'
|
||||||
|
link_to t(:disable), eval("admin_#{attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :#{attribute_type} => {:disabled => false})"), :remote => true, :method => :put, :id => "enable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? '' : 'none'}", :class => 'switch'
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,32 +1,52 @@
|
||||||
<% content_for :secondary do %>
|
<% content_for :secondary do %>
|
||||||
<div id='user_list'>
|
<% #render 'side_bar' %>
|
||||||
<div class="role_list">
|
<% end %>
|
||||||
<h1>User Role</h1>
|
|
||||||
<ul class="list">
|
<div class="main_list">
|
||||||
<% @roles.each do |role| %>
|
<%= flash_messages %>
|
||||||
<li class="set_1"><%= link_to content_tag(:span, "Role") %></li>
|
<div class="button_bar up">
|
||||||
<% end -%>
|
<% #link_to t('admin.new_user'), new_admin_user_path, :class => 'new' %>
|
||||||
</ul>
|
</div>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td><%= t('admin.app.title') %></td>
|
||||||
|
<td><%= t('admin.app.description') %></td>
|
||||||
|
<td><%= t('admin.app.use_status') %></td>
|
||||||
|
<td><%= t('admin.app.autdor') %></td>
|
||||||
|
<td><%= t('admin.app.organization') %></td>
|
||||||
|
<td><%= t('admin.app.version') %></td>
|
||||||
|
<td class="action"><%= t('admin.action') %></td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% @module_apps.each do |module_app| %>
|
||||||
|
<tr class="have" id="attribute_<%= module_app.id %>" class="have <%= "#{module_app.enable_frontend? ? 'disable' : ''}" %>">
|
||||||
|
<td class="name"><%= module_app.title %></td>
|
||||||
|
<td class="name"><%= module_app.intro %></td>
|
||||||
|
<td>
|
||||||
|
<% attribute_type = "module_app" %>
|
||||||
|
<% attribute = module_app %>
|
||||||
|
<%= link_to t(:enable), admin_module_app_path(attribute, :authenticity_token => form_authenticity_token, :module_app => {:enable_frontend => true}), :remote => true, :method => :put, :id => "disable_#{attribute.id}", :style => "display:#{attribute.enable_frontend ? 'none' : ''}", :class => 'switch' %>
|
||||||
|
<%= link_to t(:disable), admin_module_app_path(attribute, :authenticity_token => form_authenticity_token, :module_app => {:enable_frontend => false}), :remote => true, :method => :put, :id => "enable_#{attribute.id}", :style => "display:#{attribute.enable_frontend ? '' : 'none'}", :class => 'switch' %>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td class="email"><%= module_app.author %></td>
|
||||||
|
<td class="email"><%= module_app.organization %></td>
|
||||||
|
<td class="admin"><%= module_app.version %></td>
|
||||||
|
<td class="action">
|
||||||
|
<%= link_to t(:show), admin_module_app_path(module_app), :class => 'show' %>
|
||||||
|
<%= link_to t(:edit), edit_admin_module_app_path(module_app), :class => 'edit' %>
|
||||||
|
<%= link_to t(:delete), admin_module_app_path(module_app), :class => 'delete', :confirm => t('sure?'), :method => :delete %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="5"></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<div class="button_bar">
|
||||||
|
<%# link_to t('admin.new_user'), new_admin_user_path, :class => 'new' %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end -%>
|
|
||||||
|
|
||||||
<h1><%= t('admin.list_app_auths') %></h1>
|
|
||||||
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<th><%= t('admin.app.name') %></th>
|
|
||||||
<th><%= t('admin.description') %></th>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<% @app_auth_data.each do |app| %>
|
|
||||||
<tr>
|
|
||||||
<td><%= app[0][:app_obj].title %></td>
|
|
||||||
<% app[0][:auth_field].each do |unit| %>
|
|
||||||
<td>
|
|
||||||
<%= render :partial => "auth_unit",:locals => {:unit => unit } %>
|
|
||||||
</td>
|
|
||||||
<%end%>
|
|
||||||
</tr>
|
|
||||||
<% end %>
|
|
||||||
</table>
|
|
||||||
|
|
Loading…
Reference in New Issue