Announcement modifications and tags

This commit is contained in:
Christophe Vilayphiou committed 2012-02-15 00:34:22 +08:00
1 parent f57e9f19f7
commit 3e70634add
38 files changed
+615 -143

No files matched your search

+1 -1
View File
@@ -16,7 +16,7 @@ $(document).ready(function(){
$(function() {
var $role = $('.select-role');
$('[name="privacy"]').each(function($i) {
$('.privacy').each(function($i) {
$(this).click(function() {
switch ($i) {
case 0:
+48
View File
@@ -0,0 +1,48 @@
class Admin::TagsController < ApplicationController
layout 'new_admin'
before_filter :authenticate_user!
before_filter :is_admin?
before_filter :set_module_app
def index
get_tags
@module_app_id = @module_app.id rescue nil
end
def new
end
def edit
@tag = Tag.find(params[:id])
end
def create
@tag = Tag.create(params[:tag])
end
def update
@tag = Tag.find(params[:id])
@tag.update_attributes(params[:tag])
end
def destroy
@tag = Tag.find(params[:id])
@tag.destroy
respond_to do |format|
format.js { render 'js/remove_element', :locals => {:id => "#{dom_id @tag}"} }
end
end
protected
def set_module_app
@module_app ||= ModuleApp.first(:conditions => {:key => @app_title.underscore}) rescue nil
end
def get_tags
@tags = (@module_app ? @module_app.tags : Tag.all)
end
end
+4
View File
@@ -17,4 +17,8 @@ class I18nVariable
end
end
def self.from_locale(locale)
I18nVariable.first(:conditions => {:key => locale})[I18n.locale]
end
end
+2
View File
@@ -18,6 +18,8 @@ class ModuleApp
has_many :managers,as: :managing_app ,:class_name => "AppManager" #,:dependent => :destroy,:foreign_key => "managing_app_id",:inverse_of => :managing_app
has_many :sub_managers,as: :sub_managing_app ,:class_name => "AppManager"#, :dependent => :destroy,:foreign_key => "sub_managing_app_id",:inverse_of => :sub_managing_app
has_many :tags
has_one :app_auth,dependent: :delete
before_save :set_key
+9
View File
@@ -0,0 +1,9 @@
class Tag
include Mongoid::Document
include Mongoid::Timestamps
belongs_to :module_app
has_and_belongs_to_many :bulletins
end
+7
View File
@@ -0,0 +1,7 @@
<%= form_for :tag, :url => admin_tags_path, :remote => true, :html => {:id => 'tag_form'} do |f| %>
<% @site_valid_locales.each do |locale| %>
<%= I18nVariable.from_locale(locale) %>:<%= f.text_field locale %>
<% end %>
<%= f.hidden_field :module_app_id, :value => @module_app_id %>
<%= f.submit %>
<% end %>
+7
View File
@@ -0,0 +1,7 @@
<%= form_for tag, :url => admin_tag_path(tag), :remote => true do |f| %>
<% @site_valid_locales.each do |locale| %>
<%= I18nVariable.from_locale(locale) %>:<%= f.text_field locale %>
<% end %>
<%= f.hidden_field :module_app_id, :value => tag.module_app_id %>
<%= f.submit %>
<% end %>
+8
View File
@@ -0,0 +1,8 @@
<div id="<%= dom_id tag %>" >
<% @site_valid_locales.each do |locale| %>
<%= I18nVariable.from_locale(locale) %>:
<%= tag[locale] %>
<% end %>
<%= link_to t(:edit), edit_admin_tag_path(tag), :remote => true %>
<%= link_to t(:delete), admin_tag_path(tag), :confirm => t('sure?'), :method => :delete, :remote => true %>
</div>
+4
View File
@@ -0,0 +1,4 @@
$('#tag_form').each(function(){
this.reset();
});
$('#tags').append("<%= j render :partial => 'tag', :object => @tag %>")
+1
View File
@@ -0,0 +1 @@
$('#<%= dom_id @tag %>').html("<%= j render :partial => 'form', :locals => {:tag => @tag} %>")
+6
View File
@@ -0,0 +1,6 @@
<div id='tags'>
<%= render :partial => 'tag', :collection => @tags %>
</div>
-------------------------
<br/>
<%= render 'add' %>
+1
View File
@@ -0,0 +1 @@
$('#<%= dom_id @tag %>').html("<%= j render :partial => 'tag', :object => @tag %>")
+11
View File
@@ -0,0 +1,11 @@
<%# Link to the "First" page
- available local variables
url: url to the first page
current_page: a page object for the currently displayed page
num_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<span class="first">
<%= link_to_unless current_page.first?, raw(t 'views.pagination.first'), url, :remote => remote %>
</span>
+8
View File
@@ -0,0 +1,8 @@
<%# Non-link tag that stands for skipped pages...
- available local variables
current_page: a page object for the currently displayed page
num_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<span class="page gap"><%= raw(t 'views.pagination.truncate') %></span>
+11
View File
@@ -0,0 +1,11 @@
<%# Link to the "Last" page
- available local variables
url: url to the last page
current_page: a page object for the currently displayed page
num_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<span class="last">
<%= link_to_unless current_page.last?, raw(t 'views.pagination.last'), url, {:remote => remote} %>
</span>
+11
View File
@@ -0,0 +1,11 @@
<%# Link to the "Next" page
- available local variables
url: url to the next page
current_page: a page object for the currently displayed page
num_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<span class="next">
<%= link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, :rel => 'next', :remote => remote %>
</span>
+12
View File
@@ -0,0 +1,12 @@
<%# Link showing page number
- available local variables
page: a page object for "this" page
url: url to this page
current_page: a page object for the currently displayed page
num_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<span class="page<%= ' current' if page.current? %>">
<%= link_to_unless page.current?, page, url, opts = {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil} %>
</span>
+23
View File
@@ -0,0 +1,23 @@
<%# The container tag
- available local variables
current_page: a page object for the currently displayed page
num_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
paginator: the paginator that renders the pagination tags inside
-%>
<%= paginator.render do -%>
<nav class="pagination">
<%= first_page_tag unless current_page.first? %>
<%= prev_page_tag unless current_page.first? %>
<% each_page do |page| -%>
<% if page.left_outer? || page.right_outer? || page.inside_window? -%>
<%= page_tag page %>
<% elsif !page.was_truncated? -%>
<%= gap_tag %>
<% end -%>
<% end -%>
<%= next_page_tag unless current_page.last? %>
<%= last_page_tag unless current_page.last? %>
</nav>
<% end -%>
+11
View File
@@ -0,0 +1,11 @@
<%# Link to the "Previous" page
- available local variables
url: url to the previous page
current_page: a page object for the currently displayed page
num_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<span class="prev">
<%= link_to_unless current_page.first?, raw(t 'views.pagination.previous'), url, :rel => 'prev', :remote => remote %>
</span>