add files

This commit is contained in:
Peter Chiu 2023-02-27 11:54:06 +08:00
parent 5d14333c33
commit bd63df803c
7 changed files with 88 additions and 0 deletions

View File

@ -0,0 +1,43 @@
class Admin::JournalTypesController < OrbitMemberController
before_action :allow_admin_only
def new
@journal_type = JournalType.new
@url = admin_journal_types_path(@journal_type)
render :layout=>false
end
def create
@journal_type = JournalType.new(journal_type_params)
@journal_type.save
@journal_types = JournalType.all
render :partial=>'list', :layout=>false
end
def edit
@journal_type = JournalType.find(params[:id])
@url = admin_journal_paper_journal_type_path(@journal_type)
render :layout=>false
end
def update
@journal_type = JournalType.find(params[:id])
@journal_type.update_attributes(journal_type_params)
@journal_type.save
@journal_types = JournalType.all
render :partial=>'list', :layout=>false
end
def destroy
journal_type = JournalType.find(params[:id])
journal_type.destroy
@journal_types = JournalType.all
render :partial=>'list', :layout=>false
end
private
def journal_type_params
params.require(:journal_type).permit! rescue nil
end
end

View File

@ -0,0 +1,7 @@
class JournalType
include Mongoid::Document
include Mongoid::Timestamps
field :title, type: String, localize: true
end

View File

@ -0,0 +1,10 @@
<% # encoding: utf-8 %>
<tr id="<%= dom_id list_journal_type %>">
<td><%= list_journal_type.title %></td>
<td class="span2">
<a href="<%= edit_admin_journal_type_path(list_journal_type) %>#journal_type_modal" data-toggle="modal" data-remote="true" class="action"><%= t(:edit) %></a>
<%= link_to t(:delete_), admin_journal_type_path(list_journal_type), "data-confirm" => t('sure?'), :method => :delete, :remote => true,:class=>"archive_toggle action" %>
</td>
</tr>

View File

@ -0,0 +1,24 @@
<%= form_for(@journal_type, :html =>{:class=>"form-horizontal", :style=>"margin: 0;"}, :remote => true, :url => @url ) do |f| %>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel"><%= t("personal_journal.journal_type") %></h3>
</div>
<div class="modal-body">
<%= f.fields_for :title_translations do |f| %>
<% @site_in_use_locales.each do |locale| %>
<div class="control-group">
<%= label_tag t(locale), t(locale), :class => 'control-label' %>
<div class="controls">
<%= f.text_field locale, :value => (@journal_type.title_translations[locale] rescue nil) %>
</div>
</div>
<% end %>
<% end %>
</div>
<div class="modal-footer">
<%= f.submit t('submit'), :class=>'btn btn-primary' %>
<a class="btn" data-dismiss="modal"><%= t('cancel')%></a>
</div>
<% end %>

View File

@ -0,0 +1,2 @@
$('#journal_types tbody').html("<%= j render :partial => '/admin/journal_papers/list_journal_type', :collection => @journal_types %>");
$('#journal_type_modal').modal('hide');

View File

@ -0,0 +1 @@
$('#journal_type_modal').html("<%= j render 'form' %>");

View File

@ -0,0 +1 @@
$('#journal_type_modal').html("<%= j render 'form' %>");