diff --git a/app/controllers/admin/journal_types_controller.rb b/app/controllers/admin/journal_types_controller.rb new file mode 100644 index 0000000..a475bd0 --- /dev/null +++ b/app/controllers/admin/journal_types_controller.rb @@ -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 diff --git a/app/models/journal_type.rb b/app/models/journal_type.rb new file mode 100644 index 0000000..4ae8e4c --- /dev/null +++ b/app/models/journal_type.rb @@ -0,0 +1,7 @@ +class JournalType + include Mongoid::Document + include Mongoid::Timestamps + + field :title, type: String, localize: true + +end diff --git a/app/views/admin/journal_papers/_list_journal_type.html.erb b/app/views/admin/journal_papers/_list_journal_type.html.erb new file mode 100644 index 0000000..0355ade --- /dev/null +++ b/app/views/admin/journal_papers/_list_journal_type.html.erb @@ -0,0 +1,10 @@ +<% # encoding: utf-8 %> + + + <%= list_journal_type.title %> + + + <%= t(:edit) %> + <%= link_to t(:delete_), admin_journal_type_path(list_journal_type), "data-confirm" => t('sure?'), :method => :delete, :remote => true,:class=>"archive_toggle action" %> + + \ No newline at end of file diff --git a/app/views/admin/journal_types/_form.html.erb b/app/views/admin/journal_types/_form.html.erb new file mode 100644 index 0000000..a0c12dc --- /dev/null +++ b/app/views/admin/journal_types/_form.html.erb @@ -0,0 +1,24 @@ +<%= form_for(@journal_type, :html =>{:class=>"form-horizontal", :style=>"margin: 0;"}, :remote => true, :url => @url ) do |f| %> + + + + + +<% end %> \ No newline at end of file diff --git a/app/views/admin/journal_types/_list.js.erb b/app/views/admin/journal_types/_list.js.erb new file mode 100644 index 0000000..a43a135 --- /dev/null +++ b/app/views/admin/journal_types/_list.js.erb @@ -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'); \ No newline at end of file diff --git a/app/views/admin/journal_types/edit.js.erb b/app/views/admin/journal_types/edit.js.erb new file mode 100644 index 0000000..104a65b --- /dev/null +++ b/app/views/admin/journal_types/edit.js.erb @@ -0,0 +1 @@ +$('#journal_type_modal').html("<%= j render 'form' %>"); \ No newline at end of file diff --git a/app/views/admin/journal_types/new.js.erb b/app/views/admin/journal_types/new.js.erb new file mode 100644 index 0000000..104a65b --- /dev/null +++ b/app/views/admin/journal_types/new.js.erb @@ -0,0 +1 @@ +$('#journal_type_modal').html("<%= j render 'form' %>"); \ No newline at end of file