forked from saurabh/orbit4-5
Tag
This commit is contained in:
parent
a3f5977b74
commit
7f32588551
1
Gemfile
1
Gemfile
|
@ -31,6 +31,7 @@ gem "mini_magick", github: 'minimagick/minimagick'
|
|||
gem 'carrierwave'
|
||||
gem 'carrierwave-mongoid', :require => 'carrierwave/mongoid'
|
||||
gem 'mongoid-grid_fs', github: 'ahoward/mongoid-grid_fs'
|
||||
gem "impressionist"
|
||||
|
||||
#built in modules
|
||||
eval(File.read(File.dirname(__FILE__) + '/built_in_extensions.rb'))
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
//= require lib/tags
|
||||
|
||||
$(function() {
|
||||
$.pageslide.closeCallback(function(pageslide, item) {
|
||||
$('.filter-item').removeClass("active");
|
||||
});
|
||||
$.pageslide.loadComplete(function(pageslide, item) {
|
||||
$('.filter-item').removeClass("active");
|
||||
item.closest('li').addClass('active');
|
||||
if(item.data('id') == 'new') {
|
||||
resetForm();
|
||||
pageslide.find('form').attr('action', '/admin/tags/');
|
||||
pageslide.find('form').attr('method', 'post');
|
||||
}
|
||||
else {
|
||||
setForm(item.data('form'));
|
||||
pageslide.find('form').attr('action', '/admin/tags/' + item.data('id'));
|
||||
pageslide.find('form').attr('method', 'put');
|
||||
}
|
||||
});
|
||||
})
|
|
@ -1 +1,6 @@
|
|||
//= require basic
|
||||
//= require lib/footable-0.1.js
|
||||
//= require lib/all-list
|
||||
//= require lib/jquery.fastLiveFilter.js
|
||||
//= require lib/checkbox.card.js
|
||||
//= require lib/jquery.form.js
|
|
@ -71,14 +71,14 @@ function checkedLength() {
|
|||
$defaultTags.each(function(i) {
|
||||
ids.push($defaultTags.eq(i).parent().siblings('.tag_id').val());
|
||||
});
|
||||
$('#removeDefaults').attr('rel', "<%= Rails.application.routes.url_helpers.remove_default_admin_module_tags_path %>" + "?module_app_id=" + $('#module_app_id').val() + "&ids=" + ids);
|
||||
$('#removeDefaults').attr('rel', "<%= Rails.application.routes.url_helpers.remove_default_admin_tags_path %>" + "?module_app_id=" + $('#module_app_id').val() + "&ids=" + ids);
|
||||
$('#removeDefaults').removeClass('hide');
|
||||
} else {
|
||||
var ids = new Array();
|
||||
$moduleTags.each(function(i) {
|
||||
ids.push($moduleTags.eq(i).parent().siblings('.tag_id').val());
|
||||
});
|
||||
$('#deleteTags').attr('rel', "<%= Rails.application.routes.url_helpers.delete_tags_admin_module_tags_path %>" + "?module_app_id=" + $('#module_app_id').val() + "&ids=" + ids);
|
||||
$('#deleteTags').attr('rel', "<%= Rails.application.routes.url_helpers.delete_tags_admin_tags_path %>" + "?module_app_id=" + $('#module_app_id').val() + "&ids=" + ids);
|
||||
$('#deleteTags').removeClass('hide');
|
||||
if($moduleTags.length > 1) {
|
||||
$('#mergerTags').removeClass('hide');
|
||||
|
|
|
@ -0,0 +1,104 @@
|
|||
class Admin::TagsController < ApplicationController
|
||||
before_filter :setup_vars
|
||||
|
||||
layout "back_end"
|
||||
|
||||
def index
|
||||
@tag = Tag.new
|
||||
@tags = Tag.where(:is_default=>true)
|
||||
@module_apps = ModuleApp.where(taggable: true)
|
||||
end
|
||||
|
||||
def new
|
||||
@tag = Tag.new
|
||||
render layout: false
|
||||
end
|
||||
|
||||
def edit
|
||||
@tag = Tag.find(params[:id])
|
||||
render layout: false
|
||||
end
|
||||
|
||||
def create
|
||||
@tag = Tag.new(tag_params.merge(is_default: true))
|
||||
if @tag.save
|
||||
redirect_to admin_tags_url
|
||||
else
|
||||
@tag = Tag.new(tag_params)
|
||||
flash.now[:error] = t('create.error.tag')
|
||||
render :action => "new"
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@tag = Tag.find(params[:id])
|
||||
if @tag.update_attributes(tag_params)
|
||||
redirect_to action: :index, :status => 303
|
||||
else
|
||||
flash.now[:error] = t('update.error.tag')
|
||||
render :action => "edit"
|
||||
end
|
||||
end
|
||||
|
||||
def delete_tags
|
||||
tags = Tag.find(params[:ids].split(',')) rescue nil
|
||||
if tags
|
||||
tags.each(&:destroy)
|
||||
end
|
||||
redirect_to admin_tags_url
|
||||
end
|
||||
|
||||
def add_to_default
|
||||
tags = Tag.find(params[:ids].split(',')) rescue nil
|
||||
if tags
|
||||
tags.each do |tag|
|
||||
tag.update_attribute(:is_default, true)
|
||||
end
|
||||
end
|
||||
redirect_to admin_tags_url
|
||||
end
|
||||
|
||||
def merge
|
||||
tags = Tag.find(params[:ids])
|
||||
new_tag = Tag.new tag_params
|
||||
|
||||
mods = []
|
||||
|
||||
tags.each do |tag|
|
||||
new_tag.is_default = true if tag.is_default
|
||||
|
||||
tag.taggings.each do |tagging|
|
||||
taggable = tagging.taggable
|
||||
taggable.tags = taggable.tags - [tag] + [new_tag]
|
||||
taggable.save
|
||||
end
|
||||
|
||||
unless tag.module_app.nil?
|
||||
tag.module_app.each do |mod|
|
||||
mods << mod
|
||||
mod.tags = mod.tags - [tag] + [new_tag]
|
||||
mod.save
|
||||
end
|
||||
end
|
||||
|
||||
tag.destroy
|
||||
end
|
||||
|
||||
new_tag.is_default = true if mods.flatten.uniq.size > 1
|
||||
|
||||
new_tag.save
|
||||
|
||||
redirect_to admin_tags_url
|
||||
end
|
||||
|
||||
def tag_params
|
||||
params.require(:tag).permit!
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def setup_vars
|
||||
@module_app = ModuleApp.where(:key=>"tag").first
|
||||
end
|
||||
|
||||
end
|
|
@ -22,13 +22,13 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def current_site
|
||||
@current_site = Site.find_by(site_active: true)
|
||||
@current_site = Site.first
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def current_user
|
||||
@current_user ||= User.find(session[:user_id]) if session[:user_id]
|
||||
@current_user ||= User.find(session[:user_id]) if session[:user_id] rescue nil
|
||||
end
|
||||
|
||||
protected
|
||||
|
@ -36,7 +36,9 @@ class ApplicationController < ActionController::Base
|
|||
def authenticate_user
|
||||
if session[:user_id]
|
||||
# set current user object to @current_user object variable
|
||||
@current_user = User.find(session[:user_id])
|
||||
@current_user = User.find(session[:user_id]) rescue nil
|
||||
|
||||
redirect_to new_session_path if @current_user.nil?
|
||||
return true
|
||||
else
|
||||
redirect_to new_session_path
|
||||
|
|
|
@ -5,7 +5,7 @@ class SessionsController < ApplicationController
|
|||
end
|
||||
|
||||
def create
|
||||
user = User.find_by(user_name: params[:user_name])
|
||||
user = User.find_by(user_name: params[:user_name]) rescue nil
|
||||
if user && user.authenticate(params[:password])
|
||||
session[:user_id] = user.id
|
||||
redirect_to admin_dashboards_path, :notice => "Logged in!"
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
module Admin::TagsHelper
|
||||
|
||||
end
|
|
@ -44,4 +44,42 @@ module OrbitHelper
|
|||
[module_app.title, module_app.get_registration.icon_class]
|
||||
end
|
||||
end
|
||||
|
||||
# ===============================================================
|
||||
# Breadcrumbs
|
||||
# ===============================================================
|
||||
def back_end_breadcrumb
|
||||
res = ''
|
||||
divider = "<span class='divider'>/</span>"
|
||||
res << "<li><a href='#{admin_dashboards_path}'>#{t(:dashboard_)}</a>#{divider}</li>"
|
||||
case controller.controller_name
|
||||
when 'authorizations'
|
||||
res << "<li><a href='/#{params[:controller]}/#{@module_app.key}'>#{@module_app.title}</a>#{divider}</li>"
|
||||
case params[:type]
|
||||
when 'approval'
|
||||
res << "<li class='active'>#{t(:approval_)}</li>"
|
||||
when 'category'
|
||||
res << "<li class='active'>#{t(:category_auth)}</li>"
|
||||
when nil
|
||||
res << "<li class='active'>#{t(:module_authorization)}</li>"
|
||||
else
|
||||
res << "<li class='active'>#{params[:type].underscore.humanize.capitalize} #{t(:authorization_)}</li>"
|
||||
end
|
||||
when 'categories'
|
||||
res << "<li>#{@module_app.title}#{divider}</li>"
|
||||
res << "<li class='active'>#{t(:categories)}</li>"
|
||||
when 'module_tags'
|
||||
res << "<li>#{@module_app.title}#{divider}</li>"
|
||||
res << "<li class='active'>#{t(:tags)}</li>"
|
||||
else
|
||||
if params[:action].eql?('index')
|
||||
res << "<li>#{@module_app.title}</li>"
|
||||
else
|
||||
res << "<li><a href='/#{params[:controller]}'>#{@module_app.title}</a>#{divider}</li>"
|
||||
res << "<li class='active'>#{t(params[:action], scope: 'restful_actions')}</li>"
|
||||
end
|
||||
end
|
||||
res.html_safe
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -4,9 +4,17 @@ class ModuleApp
|
|||
|
||||
field :title, type: String
|
||||
field :key, type: String
|
||||
field :taggable, type: Boolean, default: false
|
||||
field :categorizable, type: Boolean, default: false
|
||||
field :sidebar_order,type: Integer,default: 0
|
||||
|
||||
has_many :categories, dependent: :destroy, :autosave => true
|
||||
has_and_belongs_to_many :tags, dependent: :destroy, :autosave => true
|
||||
|
||||
def refetch_setting!(reg)
|
||||
self[:taggable] = reg.is_taggable
|
||||
self[:categorizable] = reg.is_categorizable
|
||||
end
|
||||
|
||||
def get_registration
|
||||
OrbitApp::Module::Registration.find_by_key(key)
|
||||
|
@ -28,4 +36,16 @@ class ModuleApp
|
|||
reg = get_registration
|
||||
reg.nil? ? 'Init is not defined completely' : get_registration.get_label_i18n
|
||||
end
|
||||
|
||||
def taggable
|
||||
get_registration.is_taggable
|
||||
end
|
||||
|
||||
def taggable_model
|
||||
get_registration.taggable_model
|
||||
end
|
||||
|
||||
def categorizable
|
||||
get_registration.is_categorizable
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
class Tag
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
field :name, localize: true
|
||||
field :is_default, type: Boolean, default: false
|
||||
|
||||
has_many :taggings, dependent: :destroy
|
||||
has_and_belongs_to_many :module_app
|
||||
|
||||
def show_names_slash
|
||||
span_names = []
|
||||
Site.first.in_use_locales.each do |locale|
|
||||
span_names << "<span class='tag'>#{self.name_translations[locale]}</span>"
|
||||
end
|
||||
span_names.join(" / ").html_safe
|
||||
end
|
||||
|
||||
def get_module_tagging_count(model)
|
||||
Tagging.where(:tag=>self.id, :taggable_type=>model).count
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
class Tagging
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
belongs_to :tag
|
||||
belongs_to :taggable, polymorphic: true
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
<div id="delete_tags" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3 id="myModalLabel"><%= t('tag.delete') %></h3>
|
||||
</div>
|
||||
<div class="modal-body tags">
|
||||
<span class="text-warning text-center"><%= t('tag.warning.delete') %></span>
|
||||
<hr>
|
||||
<ul class="tags-groups checkbox-card">
|
||||
</ul>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true"><%= t(:close) %></button>
|
||||
<%= link_to t(:delete_), nil, class: "delete-tags btn btn-danger", method: :post, remote: true %>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,9 @@
|
|||
<%#= flash_messages %>
|
||||
<%#= f.error_messages %>
|
||||
|
||||
<%= f.fields_for :name_translations do |f| %>
|
||||
<% Site.first.in_use_locales.each do |locale| %>
|
||||
<%= f.label :locale, "#{t(:name)} #{t(locale)}" %>
|
||||
<%= f.text_field locale, class: 'input-large', placeholder: "#{t(:name)} #{t(locale)}", value: (@tag.name_translations[locale] rescue nil), id: locale %>
|
||||
<% end %>
|
||||
<% end %>
|
|
@ -0,0 +1,42 @@
|
|||
<!-- footer -->
|
||||
<div class="bottomnav clearfix">
|
||||
<div class="action pull-right">
|
||||
<button id="selectAllTags" class="btn"><%= t(:select_all) %></button>
|
||||
<button id="deselect" class="btn btn-inverse toggable hide"><%= t(:deselect_all) %></button>
|
||||
<%= link_to t(:delete), '#', id: "deleteTags", class: "btn btn-danger toggable hide", rel: '' %>
|
||||
<%= link_to t(:merge), '#', id: "mergerTags", class: "btn btn-success toggable hide", rel: merge_admin_tags_path %>
|
||||
<%= link_to t(:add_to_default), add_to_default_admin_tags_path, id: "addDefault", class: "btn btn-info toggable hide", method: :post, remote: true %>
|
||||
<%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add), '#', class: "btn btn-primary open-slide", data: {title: t('new.tag'), id: 'new'} %>
|
||||
</div>
|
||||
</div>
|
||||
<!-- footer:end -->
|
||||
|
||||
<!-- tags -->
|
||||
<div class="tags">
|
||||
<div id="tags-list">
|
||||
<p class="tag-lead lead muted"><i class="icons-tag"></i> <%= t(:default) %> <span class="badge pull-right"><%= @tags.count %></span></p>
|
||||
<ul class="tags-groups checkbox-card default-tags">
|
||||
<%= render partial: "tag", collection: @tags %>
|
||||
</ul>
|
||||
<% @module_apps.each do |mod| %>
|
||||
<%
|
||||
@mod = mod
|
||||
tags = mod.tags
|
||||
%>
|
||||
<% icon_name = OrbitApp::Module::Registration.find_by_key(mod.key).get_icon_class rescue 'icons-daniel-bruce-2' %>
|
||||
<p class="tag-lead lead muted"><i class="<%= icon_name %>"></i> <%= mod.title %> <span class="badge pull-right"><%= tags.count %></span></p>
|
||||
<ul class="tags-groups checkbox-card module-tags">
|
||||
<%= render partial: "tag", collection: tags, locals: {in_module: true} %>
|
||||
</ul>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<!-- tags:end -->
|
||||
|
||||
<!-- merge -->
|
||||
<%= render 'merge_modal' %>
|
||||
<!-- merge:end -->
|
||||
|
||||
<!-- delete -->
|
||||
<%= render 'delete_modal' %>
|
||||
<!-- delete:end -->
|
|
@ -0,0 +1,28 @@
|
|||
<div id="tags-merger" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<%= form_for :tag, url: nil, remote: true do |f| %>
|
||||
<fieldset>
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3 id="myModalLabel"><%= t('tag.merger') %></h3>
|
||||
</div>
|
||||
<div class="modal-body tags">
|
||||
<div class="clearfix">
|
||||
<%= f.fields_for :name_translations do |f| %>
|
||||
<% Site.first.in_use_locales.each do |locale| %>
|
||||
<%= f.label :locale, "#{t(:name)} #{t(locale)}" %>
|
||||
<%= f.text_field locale, class: 'input-large', placeholder: "#{t(:name)} #{t(locale)}", id: locale %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<span class="help-block"><%= t('tag.merge_help') %></span>
|
||||
<hr>
|
||||
<ul class="tags-groups checkbox-card">
|
||||
</ul>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true"><%= t(:cancel) %></button>
|
||||
<button class="btn btn-primary"><%= t(:submit) %></button>
|
||||
</div>
|
||||
</fieldset>
|
||||
<% end %>
|
||||
</div>
|
|
@ -0,0 +1,21 @@
|
|||
<li class="filter-item <%= tag.is_default ? 'default' : '' %>">
|
||||
|
||||
<% unless defined?(in_module) && tag.is_default %>
|
||||
<p class="card pull-left">
|
||||
<input type="checkbox">
|
||||
</p>
|
||||
<%= hidden_field_tag "ids[]", tag.id, class: "tag_id" %>
|
||||
<% end %>
|
||||
|
||||
<% if defined?(in_module) && tag.is_default %>
|
||||
<a>
|
||||
<span class="amount"><%= tag.get_module_tagging_count @mod.taggable_model %></span>
|
||||
<%= tag.show_names_slash %>
|
||||
</a>
|
||||
<% else %>
|
||||
<%= link_to '#', class: "open-slide", data: {title: t('editing.tag'), id: tag.id.to_s, form: tag.name_translations} do %>
|
||||
<span class="amount"><%= tag.taggings.count %></span>
|
||||
<%= tag.show_names_slash %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</li>
|
|
@ -0,0 +1,35 @@
|
|||
<% content_for :right_nav do %>
|
||||
<div class="searchClear pull-right">
|
||||
<input id="filter-input" class="search-query input-medium" type="text" placeholder="<%= t('search.tags') %>" value="">
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div id="tags_index">
|
||||
<%= render 'index' %>
|
||||
</div>
|
||||
|
||||
<!-- pageslide -->
|
||||
<div id="pageslide">
|
||||
<div class="page-title clearfix">
|
||||
<a class="pull-right" href="javascript:$.pageslide.close()">
|
||||
<i class="icons-arrow-left-2"></i>
|
||||
</a>
|
||||
<span></span>
|
||||
</div>
|
||||
<div class="view-page">
|
||||
<div class="nano">
|
||||
<div class="content">
|
||||
<%= form_for :tag, url: nil, remote: true do |f| %>
|
||||
<fieldset>
|
||||
<%= render :partial => "form", :locals => { :f => f } %>
|
||||
<div class="form-actions">
|
||||
<a href="javascript:$.pageslide.close()" class="btn btn-small"><%= t(:cancel) %></a>
|
||||
<%= f.submit t(:submit), class: 'btn btn-primary btn-small' %>
|
||||
</div>
|
||||
</fieldset>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- pageslide:end -->
|
|
@ -0,0 +1,9 @@
|
|||
$("#delete_tags").modal('hide');
|
||||
$("#tags-merger").modal('hide');
|
||||
$("#tags_index").html("<%= j render 'index' %>")
|
||||
$.pageslide.close();
|
||||
openSlide();
|
||||
$('.card').cardCheck({
|
||||
item: $('.card input[type="checkbox"]'),
|
||||
});
|
||||
checkedLength()
|
|
@ -0,0 +1 @@
|
|||
<%= render 'new' %>
|
|
@ -5,14 +5,32 @@
|
|||
<%= render 'shared/meta' %>
|
||||
<%= render 'shared/google_font' %>
|
||||
<%= stylesheet_link_tag "back_end", media: "all", "data-turbolinks-track" => true %>
|
||||
<%= stylesheet_link_tag params[:controller] if Rails.application.assets.find_asset "#{params[:controller]}.css" %>
|
||||
<%= yield :page_specific_css %>
|
||||
<%= javascript_include_tag "back_end" %>
|
||||
<%= render 'shared/ie_html5_fix' %>
|
||||
<%= javascript_include_tag params[:controller] if Rails.application.assets.find_asset "#{params[:controller]}.js" %>
|
||||
<%= yield :page_specific_javascript %>
|
||||
<%= csrf_meta_tags %>
|
||||
</head>
|
||||
<body>
|
||||
<body id="dashboards">
|
||||
<%= render 'layouts/orbit_bar_backend' %>
|
||||
<%= render 'layouts/side_bar' %>
|
||||
<section id="main-wrap">
|
||||
<div class="wrap-inner">
|
||||
<div id="filter" class="topnav clearfix">
|
||||
<ul class="breadcrumb text-info pull-left">
|
||||
<% if @module_app.present?%>
|
||||
<%= back_end_breadcrumb %>
|
||||
<%else%>
|
||||
<%#= site_breadcrumb %>
|
||||
<%end%>
|
||||
</ul>
|
||||
<%= yield :right_nav %>
|
||||
</div>
|
||||
<%= yield %>
|
||||
</div>
|
||||
</section>
|
||||
<%= javascript_include_tag "lib/pageslide.js" %>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
<% flash.each do |key, msg| %>
|
||||
<%= content_tag :p, msg, :class => [key, "alert alert-error in fade"] %>
|
||||
<% end %>
|
||||
|
||||
<div class="form">
|
||||
<h3 class="login-logo">Log In to Orbit</h3>
|
||||
<div>
|
||||
|
@ -12,9 +11,7 @@
|
|||
</div>
|
||||
<div class="form-block">
|
||||
<div class="form-list clearfix">
|
||||
<form class="content" accept-charset="UTF-8" action="/sessions" method="post">
|
||||
<%= form_tag sessions_path do %>
|
||||
|
||||
<%= form_tag sessions_path, :class => 'content' do %>
|
||||
<div class="control-group clear">
|
||||
<label for="user_email">
|
||||
<i class="icon-user"></i>
|
||||
|
@ -25,27 +22,20 @@
|
|||
<label for="user_password">
|
||||
<i class="icon-lock"></i>
|
||||
</label>
|
||||
<%= password_field_tag :password, :placeholder => t(:dots), :id=>"user_password" %>
|
||||
<%= password_field_tag :password, nil, :placeholder => t(:dots), :id=>"user_password" %>
|
||||
</div>
|
||||
<br/>
|
||||
<div class="field">
|
||||
<%= label_tag :remember_me %>
|
||||
<%= check_box_tag :remember_me, 1, params[:remember_me] %>
|
||||
</div>
|
||||
|
||||
<%= button_tag(type: 'submit', class: "btn btn-primary") do %>
|
||||
<%= t(:login) %>
|
||||
<label class="checkbox">
|
||||
<%= check_box_tag :remember_me %><small><%= label_tag :remember_me %></small>
|
||||
</label>
|
||||
<button class="btn btn-primary" name="button" type="submit"><%= t(:login) %></button>
|
||||
<% end %>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
<%= link_to content_tag(:small, t(:forgot_password)) %>
|
||||
</div>
|
||||
<br/>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
|
@ -3,9 +3,26 @@ require File.expand_path('../application', __FILE__)
|
|||
|
||||
# Initialize the Rails application.
|
||||
Orbit::Application.initialize!
|
||||
|
||||
if Site.count == 0
|
||||
site = Site.new
|
||||
site.title = "Orbit"
|
||||
site.valid_locales = [:en, :zh_tw]
|
||||
site.in_use_locales = site.valid_locales
|
||||
site.save
|
||||
end
|
||||
|
||||
if Page.count == 0
|
||||
home = Page.new
|
||||
home.name_translations = {:en=>"home",:zh_tw=>"首頁"}
|
||||
home.url = ""
|
||||
home.save
|
||||
end
|
||||
|
||||
if User.count==0
|
||||
user = User.new
|
||||
user.user_name = "rulingcom"
|
||||
user.password = "bjo4xjp6"
|
||||
user.email = "orbit@rulingcom.com"
|
||||
user.save
|
||||
end
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
# Use this hook to configure impressionist parameters
|
||||
Impressionist.setup do |config|
|
||||
# Define ORM. Could be :active_record (default), :mongo_mapper or :mongoid
|
||||
# config.orm = :active_record
|
||||
config.orm = :mongoid
|
||||
end
|
|
@ -0,0 +1,19 @@
|
|||
OrbitApp.registration "Tag", type: 'ModuleApp' do
|
||||
module_label 'module_name.tag'
|
||||
base_url File.expand_path File.dirname(__FILE__)
|
||||
|
||||
side_bar do
|
||||
head_label_i18n 'module_name.tag', icon_class: "icons-tag"
|
||||
head_link_path "admin_tags_path"
|
||||
active_for_controllers ({public: ['admin/tags']})
|
||||
|
||||
# available_for [:admin, :manager]
|
||||
|
||||
# context_link 'all',
|
||||
# link_path: "admin_tags_path",
|
||||
# priority: 1,
|
||||
# active_for_action: {tags: :index},
|
||||
# available_for: [:admin, :manager]
|
||||
|
||||
end
|
||||
end
|
|
@ -20,16 +20,22 @@
|
|||
# available at http://guides.rubyonrails.org/i18n.html.
|
||||
|
||||
en:
|
||||
en: English
|
||||
zh_tw: Chinese
|
||||
_locale: English
|
||||
more: "More"
|
||||
search:
|
||||
tags: Search Tags
|
||||
site_: Site
|
||||
site_info: Site Info
|
||||
site_map: Site Map
|
||||
sitemap: Sitemap
|
||||
site_name: Site Name
|
||||
site_structure: Structure
|
||||
submit: Submit
|
||||
modules: Modules
|
||||
mobile_settings: Mobile Settings
|
||||
name: Name
|
||||
search_engine: Search Engine
|
||||
templates: Templates
|
||||
preference: Preferences
|
||||
|
@ -44,6 +50,10 @@ en:
|
|||
password: Password
|
||||
all: All
|
||||
add: Add
|
||||
new:
|
||||
tag: New tag
|
||||
editing:
|
||||
tag: Editing tag
|
||||
|
||||
site:
|
||||
system_preference: System Preference
|
||||
|
@ -81,3 +91,6 @@ en:
|
|||
dots: ●●●●●●
|
||||
register: Register
|
||||
registered: Registered
|
||||
|
||||
module_name:
|
||||
tag: Tag
|
||||
|
|
|
@ -23,7 +23,7 @@ Orbit::Application.routes.draw do
|
|||
# You can have the root of your site routed with "root"
|
||||
root 'pages#home'
|
||||
|
||||
locales = Site.find_by(site_active: true).in_use_locales rescue I18n.available_locales
|
||||
locales = Site.first.in_use_locales rescue I18n.available_locales
|
||||
|
||||
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
|
||||
resources :users
|
||||
|
@ -31,6 +31,15 @@ Orbit::Application.routes.draw do
|
|||
namespace :admin do
|
||||
resources :dashboards
|
||||
resources :items
|
||||
resources :tags do
|
||||
collection do
|
||||
post 'add_to_default'
|
||||
post 'delete_tags'
|
||||
post 'merge'
|
||||
post 'remove_default'
|
||||
post 'update_included_default'
|
||||
end
|
||||
end
|
||||
|
||||
resources :sites do
|
||||
get 'mail_setting'
|
||||
|
|
|
@ -37,6 +37,9 @@ module OrbitApp
|
|||
@side_bar = nil
|
||||
@module_label = @name
|
||||
@widget_methods = []
|
||||
@is_taggable = false
|
||||
@taggable_model = nil
|
||||
@is_categorizable = false
|
||||
block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
|
||||
setup_module_app
|
||||
end
|
||||
|
@ -48,6 +51,7 @@ module OrbitApp
|
|||
def setup_module_app
|
||||
module_app = get_module_app
|
||||
module_app = ModuleApp.new(:key=>@key,:title=>name) if module_app.nil?
|
||||
module_app.refetch_setting!(self)
|
||||
module_app.save(:validate=>false)
|
||||
end
|
||||
|
||||
|
@ -82,6 +86,27 @@ module OrbitApp
|
|||
@side_bar.get_icon_class
|
||||
end
|
||||
|
||||
def taggable(model)
|
||||
@is_taggable = true
|
||||
@taggable_model = model.classify
|
||||
end
|
||||
|
||||
def is_taggable
|
||||
@is_taggable
|
||||
end
|
||||
|
||||
def taggable_model
|
||||
@taggable_model
|
||||
end
|
||||
|
||||
def categorizable
|
||||
@is_categorizable = true
|
||||
end
|
||||
|
||||
def is_categorizable
|
||||
@is_categorizable
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
module OrbitTag
|
||||
module Taggable
|
||||
|
||||
def self.included(base)
|
||||
base.has_many :taggings, as: :taggable, autosave: true, dependent: :destroy
|
||||
base.accepts_nested_attributes_for :taggings, allow_destroy: true
|
||||
end
|
||||
|
||||
def tags
|
||||
self.taggings.blank? ? [] : self.taggings.map{|t| t.tag}.compact
|
||||
end
|
||||
|
||||
def tags=(tags)
|
||||
tags = [tags].flatten.uniq
|
||||
Tagging.where(:taggable=>self.id).destroy_all
|
||||
tags.each do |tag|
|
||||
self.taggings.build(tag: tag)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -0,0 +1,11 @@
|
|||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the '{}' from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
# column: value
|
|
@ -0,0 +1,11 @@
|
|||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the '{}' from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
# column: value
|
|
@ -0,0 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class TagTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class TaggingTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
Loading…
Reference in New Issue