Merge branch 'make_jsFunc_for_journalP' of github.com:Rulingcom/orbit into make_jsFunc_for_journalP

This commit is contained in:
chris 2012-11-26 05:02:58 +08:00
commit 1e89c30150
5 changed files with 66 additions and 21 deletions

View File

@ -50,7 +50,7 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ //
return false; return false;
}) })
$("div[container=true]").unbind("click").on("click",".journal_paper_edit",function(){ $("div[container=true]").unbind(".edit").on("click.edit",".journal_paper_edit",function(){
$.ajax({ $.ajax({
url : $(this).attr("href"), url : $(this).attr("href"),
type : "get", type : "get",
@ -64,6 +64,29 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ //
}) })
return false; return false;
}) })
$("div[container=true]").unbind(".delete").on("click.delete",".journal_paper_delete",function(){
var delurl = $(this).attr("href");
var parent = $(this).parent();
o.confirm({
buttons : ["Yes","No"],
highlighted : 2,
message : "Are you sure, you want to delete this paper?"
},function(value){
if(value){
$.ajax({
url : delurl,
type : "DELETE",
success : function(data){
if(data.success){
parent.hide("slide",function(){parent.remove();});
o.notify(data.msg,"success");
}
}
})
}
})
return false;
})
} }
@ -89,7 +112,7 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ //
li; li;
$.each(journalData,function(i,journal){ $.each(journalData,function(i,journal){
$.each(journal.papers,function(j,paper){ $.each(journal.papers,function(j,paper){
li = $('<li class="list_t_item"><div class="list_item_action"><a href="" class="icon-check-empty"></a><a href="" class="icon-star-empty"></a></div><div class="list_t_title">'+journal.title+'</div><div class="list_t_des">'+paper.title+'</div><a class="journal_paper_edit" href="'+paper.url_edit+'">Edit</a></li>'); li = $('<li class="list_t_item"><div class="list_item_action"><a href="" class="icon-check-empty"></a><a href="" class="icon-star-empty"></a></div><div class="list_t_title">'+journal.title+'</div><div class="list_t_des">'+paper.title+'</div><a class="journal_paper_edit" href="'+paper.url_edit+'">Edit</a> <a class="journal_paper_delete" href="'+paper.url_delete+'">Delete</a></li>');
column.find("ul").append(li); column.find("ul").append(li);
if(counter%5==0){ if(counter%5==0){
$("#journal_p div#paper_list div.overview").append(column); $("#journal_p div#paper_list div.overview").append(column);
@ -118,7 +141,7 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ //
var img = $('<div class="list_t_des"><a href="'+file.url+'" target="_blank" ><img src="'+file.icon+'" />'+thistitle+'</a></div>'); var img = $('<div class="list_t_des"><a href="'+file.url+'" target="_blank" ><img src="'+file.icon+'" />'+thistitle+'</a></div>');
li.append(img); li.append(img);
}) })
li.append('<a class="journal_paper_edit" href="'+paper.url_edit+'">Edit</a>'); li.append('<a class="journal_paper_edit" href="'+paper.url_edit+'">Edit</a> <a class="journal_paper_delete" href="'+paper.url_delete+'">Delete</a>');
column.find("ul").append(li); column.find("ul").append(li);
if(counter%5==0){ if(counter%5==0){
$("#journal_p div#paper_list div.overview").append(column); $("#journal_p div#paper_list div.overview").append(column);
@ -137,7 +160,7 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ //
li; li;
$.each(journalData,function(i,journal){ $.each(journalData,function(i,journal){
$.each(journal.papers,function(j,paper){ $.each(journal.papers,function(j,paper){
li = $('<li class="list_t_item"><div class="list_item_action"><a href="" class="icon-check-empty"></a><a href="" class="icon-star-empty"></a></div><div class="list_t_title">'+paper.title+'</div><div class="list_t_des">'+paper.keywords+'</div><a class="journal_paper_edit" href="'+paper.url_edit+'">Edit</a></li>'); li = $('<li class="list_t_item"><div class="list_item_action"><a href="" class="icon-check-empty"></a><a href="" class="icon-star-empty"></a></div><div class="list_t_title">'+paper.title+'</div><div class="list_t_des">'+paper.keywords+'</div><a class="journal_paper_edit" href="'+paper.url_edit+'">Edit</a> <a class="journal_paper_delete" href="'+paper.url_delete+'">Delete</a></li>');
column.find("ul").append(li); column.find("ul").append(li);
if(counter%5==0){ if(counter%5==0){
$("#journal_p div#paper_list div.overview").append(column); $("#journal_p div#paper_list div.overview").append(column);
@ -157,7 +180,7 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ //
li; li;
$.each(journalData,function(i,journal){ $.each(journalData,function(i,journal){
$.each(journal.papers,function(j,paper){ $.each(journal.papers,function(j,paper){
li = $('<li class="list_t_item"><div class="list_item_action"><a href="" class="icon-check-empty"></a><a href="" class="icon-star-empty"></a></div><div class="list_t_title">'+paper.title+'</div><a class="journal_paper_edit" href="'+paper.url_edit+'">Edit</a></li>'); li = $('<li class="list_t_item"><div class="list_item_action"><a href="" class="icon-check-empty"></a><a href="" class="icon-star-empty"></a></div><div class="list_t_title">'+paper.title+'</div><a class="journal_paper_edit" href="'+paper.url_edit+'">Edit</a> <a class="journal_paper_delete" href="'+paper.url_delete+'">Delete</a></li>');
column.find("ul").append(li); column.find("ul").append(li);
if(counter%5==0){ if(counter%5==0){
$("#journal_p div#paper_list div.overview").append(column); $("#journal_p div#paper_list div.overview").append(column);
@ -176,7 +199,7 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ //
li; li;
$.each(journalData,function(i,journal){ $.each(journalData,function(i,journal){
$.each(journal.papers,function(j,paper){ $.each(journal.papers,function(j,paper){
li = $('<li class="list_t_item" style="height:auto;"><div class="list_item_action"><a href="" class="icon-check-empty"></a><a href="" class="icon-star-empty"></a></div><div class="list_t_title">'+paper.title+'</div><div class="list_t_des">'+paper.abstract+'</div><a class="journal_paper_edit" href="'+paper.url_edit+'">Edit</a></li>'); li = $('<li class="list_t_item" style="height:auto;"><div class="list_item_action"><a href="" class="icon-check-empty"></a><a href="" class="icon-star-empty"></a></div><div class="list_t_title">'+paper.title+'</div><div class="list_t_des">'+paper.abstract+'</div><a class="journal_paper_edit" href="'+paper.url_edit+'">Edit</a> <a class="journal_paper_delete" href="'+paper.url_delete+'">Delete</a></li>');
column.find("ul").append(li); column.find("ul").append(li);
$("#journal_p div#paper_list div.overview").append(column); $("#journal_p div#paper_list div.overview").append(column);
column = $('<div class="g_col list_t"><ul></ul></div>'); column = $('<div class="g_col list_t"><ul></ul></div>');

View File

@ -57,9 +57,23 @@ class Desktop::CoAuthorsController < ApplicationController
@co_author = CoAuthor.find(params[:id]) @co_author = CoAuthor.find(params[:id])
@co_author.destroy @co_author.destroy
respond_to do |format| #respond_to do |format|
format.html { redirect_to desktop_co_authors_url, :layout => false } # format.html { redirect_to desktop_co_authors_url, :layout => false }
format.json { head :no_content } # format.json { head :no_content }
#end
end
def get_co_authors_json
@co_authors = CoAuthor.where(name_id: current_user.id)
data = Array.new
@co_authors.each do |co_author|
data << {
author: co_author.co_author,
email: co_author.email,
type: co_author.type
}
end end
render json: JSON.pretty_generate(data)
end end
end end

View File

@ -80,6 +80,12 @@ class Desktop::JournalPagesController < ApplicationController
end end
end end
def destroy
@writing_journal = WritingJournal.find(params[:id])
@writing_journal.destroy
render :json => {success: true,msg: "Paper deleted successfully!"}
end
def get_journals_json def get_journals_json
publications = WritingJournal.where(create_user_id: current_user.id) publications = WritingJournal.where(create_user_id: current_user.id)

View File

@ -1,7 +1,8 @@
<div class="toolbar hh2"> <div class="toolbar hh2">
<div class="fn_g hp"> <div class="fn_g hp">
<%= f.submit "Save", name: "commit", value: "Save", class: "fn_btn hh2 thmc2 thmtxt" %> <%= f.submit "Save", name: "commit", value: "Save", class: "fn_btn hh2 thmc2 thmtxt" %>
<!-- <%= submit_tag "Cancel", :class=>"fn_btn hh2 bt-cancel thmc2 thmtxt" %>--> <!-- class: bt-cancle can't be remove
<%= submit_tag "Cancel", class: "bt-cancel fn_btn hh2 thmc2 thmtxt" %> -->
</div> </div>
<div class="hh2 hp sdm"> <div class="hh2 hp sdm">
<div class="sdm_t hh2">Entry Year</div> <div class="sdm_t hh2">Entry Year</div>
@ -48,10 +49,10 @@
<div class="s_grid_con s_form"> <div class="s_grid_con s_form">
<ul> <ul>
<li class="s_grid_row"> <li class="s_grid_row">
<%= f.text_area :paper_title, size: "20x2", value: @writing_journal.paper_title ||= "Paper Title", class: "s_grid_6 s_grid"%> <%= f.text_area :paper_title, size: "20x2", placeholder: "Paper Title", class: "s_grid_6 s_grid"%>
</li> </li>
<li class="s_grid_row"> <li class="s_grid_row">
<%= f.text_field :journal_title, size: "20" ,value: @writing_journal.journal_title ||= "Journal Title", class: "s_grid_6 s_grid"%> <%= f.text_field :journal_title, size: "20", placeholder: "Journal Title", class: "s_grid_6 s_grid"%>
<span class="icon-plus input_append"></span> <span class="icon-plus input_append"></span>
</li> </li>
<li class="s_grid_row"> <li class="s_grid_row">
@ -85,34 +86,34 @@
</li> </li>
<li class="s_grid_row"> <li class="s_grid_row">
<%= label_tag("", "ISSN(ISBN)", class: "s_grid_2 s_grid") %><%= f.text_field :isbn, size: "20" ,value: @writing_journal.isbn ||= "829872987", class: "s_grid_4 s_grid"%> <%= label_tag("", "ISSN(ISBN)", class: "s_grid_2 s_grid") %><%= f.text_field :isbn, size: "20", placeholder: "829872987", class: "s_grid_4 s_grid"%>
</li> </li>
<li class="s_grid_row"> <li class="s_grid_row">
<%= label_tag("", "Volume No.", class: "s_grid_2 s_grid") %><%= f.text_field :vol_no, size: "20" ,value: @writing_journal.vol_no ||= "829872987", class: "s_grid_4 s_grid"%> <%= label_tag("", "Volume No.", class: "s_grid_2 s_grid") %><%= f.text_field :vol_no, size: "20", placeholder: "829872987", class: "s_grid_4 s_grid"%>
</li> </li>
<li class="s_grid_row"> <li class="s_grid_row">
<%= label_tag("", "Issue No.", class: "s_grid_2 s_grid") %><%= f.text_field :issue_no, size: "20" ,value: @writing_journal.issue_no ||= "829872987", class: "s_grid_4 s_grid"%> <%= label_tag("", "Issue No.", class: "s_grid_2 s_grid") %><%= f.text_field :issue_no, size: "20", placeholder:"829872987", class: "s_grid_4 s_grid"%>
</li> </li>
<li class="s_grid_row"> <li class="s_grid_row">
<%= label_tag("", "Total Pages", class: "s_grid_2 s_grid") %><%= f.text_field :total_pages, size: "20" ,value: @writing_journal.total_pages ||= "20", class: "s_grid_4 s_grid"%> <%= label_tag("", "Total Pages", class: "s_grid_2 s_grid") %><%= f.text_field :total_pages, size: "20", placeholder:"20", class: "s_grid_4 s_grid"%>
</li> </li>
<li class="s_grid_row"> <li class="s_grid_row">
<%= label_tag("", "Pages", class: "s_grid_2 s_grid") %><%= label_tag("", "from", class: "s_grid_1 s_grid") %><%= f.text_field :form_to_start, size: "10" ,value: @writing_journal.form_to_start ||= "1", class: "s_grid_1 s_grid"%><%= label_tag("", "to", class: "s_grid_1 s_grid") %><%= f.text_field :form_to_end, size: "10" ,value: @writing_journal.form_to_end ||= "20", class: "s_grid_1 s_grid"%> <%= label_tag("", "Pages", class: "s_grid_2 s_grid") %><%= label_tag("", "from", class: "s_grid_1 s_grid") %><%= f.text_field :form_to_start, size: "10", placeholder: "1", class: "s_grid_1 s_grid"%><%= label_tag("", "to", class: "s_grid_1 s_grid") %><%= f.text_field :form_to_end, size: "10", placeholder: "20", class: "s_grid_1 s_grid"%>
</li> </li>
<li class="s_grid_row"> <li class="s_grid_row">
<%= label_tag("", "Reference URL", class: "s_grid_2 s_grid") %><%= f.text_field :url, size: "20" ,value: @writing_journal.url ||= "www.sample.com", class: "s_grid_4 s_grid"%> <%= label_tag("", "Reference URL", class: "s_grid_2 s_grid") %><%= f.text_field :url, size: "20", placeholder: "www.sample.com", class: "s_grid_4 s_grid"%>
</li> </li>
</ul> </ul>
</div> </div>
<div class="s_grid_con s_form"> <div class="s_grid_con s_form">
<ul> <ul>
<li class="s_grid_row"> <li class="s_grid_row">
<%= f.text_area :authors, size: "20x2", value: @writing_journal.authors ||= "Authors", class: "s_grid_6 s_grid"%> <%= f.text_area :authors, size: "20x2", placeholder: "Authors", class: "s_grid_6 s_grid"%>
<span class="icon-plus input_append"></span> <span class="icon-plus input_append"></span>
</li> </li>
<li class="s_grid_row"> <li class="s_grid_row">
@ -184,14 +185,14 @@
--> -->
</li> </li>
<li class="s_grid_row"> <li class="s_grid_row">
<%= f.text_area :note, size: "20x2", value: @writing_journal.note ||= "Note", class: "s_grid_6 s_grid"%> <%= f.text_area :note, size: "20x2", plcaeholder: "Note", class: "s_grid_6 s_grid"%>
</li> </li>
</ul> </ul>
</div> </div>
<div class="s_grid_con s_form"> <div class="s_grid_con s_form">
<ul> <ul>
<li class="s_grid_row"> <li class="s_grid_row">
<%= f.text_area :abstract, size: "20x26", value: @writing_journal.abstract ||= "Abstract", class: "s_grid_6 s_grid"%> <%= f.text_area :abstract, size: "20x26", placeholder: "Abstract", class: "s_grid_6 s_grid"%>
</li> </li>
</ul> </ul>
</div> </div>

View File

@ -151,6 +151,7 @@ Orbit::Application.routes.draw do
namespace :desktop do namespace :desktop do
match "desktop" => "desktop#desktop" match "desktop" => "desktop#desktop"
match '/journal_pages/get_journals_json' => 'journal_pages#get_journals_json' match '/journal_pages/get_journals_json' => 'journal_pages#get_journals_json'
match '/co_authors/get_co_authors_json' => 'co_authors#get_co_authors_json'
match '/desktop'=>'desktop#desktop' match '/desktop'=>'desktop#desktop'
match '/app_manager'=>'desktop#app_manager' match '/app_manager'=>'desktop#app_manager'
match '/sections'=>'desktop#sections' match '/sections'=>'desktop#sections'