fix conflict
This commit is contained in:
commit
a5a35956b3
|
@ -2,32 +2,47 @@ class MissionsController < ApplicationController
|
|||
|
||||
before_action :authenticate
|
||||
|
||||
#获取当前项目某状态的任务列表
|
||||
#======================================>获取当前项目某状态的任务列表
|
||||
|
||||
def getlist
|
||||
#Todo
|
||||
pid = params[:project_id]
|
||||
stu = params[:status_type]
|
||||
missions = []
|
||||
Mission.where(:project_id => pid).where(:status => stu) do |i|
|
||||
missions += [{
|
||||
:id => i.id,
|
||||
:name => i.name,
|
||||
:content => i.content
|
||||
#missions = []
|
||||
details = []
|
||||
missions = Mission.where("project_id = ? AND status = ?",pid,stu).all
|
||||
|
||||
missions.each do |mission|
|
||||
|
||||
puts mission.inspect
|
||||
|
||||
details += [{
|
||||
:id => mission.id,
|
||||
:name => mission.name,
|
||||
:content => mission.content
|
||||
}]
|
||||
|
||||
end
|
||||
|
||||
# Mission.where(:project_id => pid).where(:status => stu) do |i|
|
||||
# missions += [{
|
||||
# :id => i.id,
|
||||
# :name => i.name,
|
||||
# :content => i.content
|
||||
# }]
|
||||
# end
|
||||
render :json => {
|
||||
:code => 0,
|
||||
:data => missions
|
||||
}
|
||||
end
|
||||
|
||||
#获取任务详细信息
|
||||
#======================================>获取任务详细信息
|
||||
|
||||
def detail
|
||||
#Todo
|
||||
id = params[:id]
|
||||
mission = Mission.find(id)
|
||||
mission_id = params[:id]
|
||||
mission = Mission.find_by(id: mission_id)
|
||||
userid = Mission_user.find_by_name("mission_id")
|
||||
username = User.find(userid).pluck("name")
|
||||
comments = []
|
||||
|
@ -53,7 +68,7 @@ class MissionsController < ApplicationController
|
|||
}
|
||||
end
|
||||
|
||||
#修改任务信息
|
||||
#======================================>修改任务信息
|
||||
|
||||
def update
|
||||
#Todo
|
||||
|
@ -87,18 +102,23 @@ class MissionsController < ApplicationController
|
|||
render :json => {:code => 0}
|
||||
end
|
||||
|
||||
#当前用户发表评论
|
||||
#======================================>当前用户发表评论
|
||||
|
||||
def commentPublish
|
||||
#Todo
|
||||
put = Comments.new()
|
||||
put.content = params[:content]
|
||||
put.mission_id = params[:mission_id]
|
||||
put.user_id = session[:user_id]
|
||||
now = Datetime.now
|
||||
put.created_at = now
|
||||
put.updated_at = now
|
||||
put.save!
|
||||
content = params[:content]
|
||||
mission_id = params[:mission_id]
|
||||
user_id = session[:user_id]
|
||||
puts user_id
|
||||
params_comment = {content: content,mission_id: mission_id,user_id: user_id}
|
||||
puts params_comment
|
||||
comment = Comments.new(params_comment)
|
||||
|
||||
# now = Datetime.now
|
||||
# put.created_at = now
|
||||
# put.updated_at = now
|
||||
comment.save!
|
||||
|
||||
render :json => {:code => 0}
|
||||
end
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ users = [
|
|||
{:name => '陈翊', :password => '123456', :email => '1085730215@qq.com', :phone => '18269771988', :created_at => "2016/12/28", :updated_at => "2016/12/27"}
|
||||
]
|
||||
projects = [
|
||||
{:name => 'AAAA',:content => 'i like helloworld',:mission_count => '20',:users_count => '15',:shares_count => '15'}
|
||||
{:id=>'1001',:name => 'AAAA',:content => 'i like helloworld',:mission_count => '20',:users_count => '15',:shares_count => '15'}
|
||||
]
|
||||
|
||||
users.each do |user|
|
||||
|
|
|
@ -30,15 +30,19 @@
|
|||
</style>
|
||||
<script>
|
||||
var pre;
|
||||
function change_iframe( seq,obj ){
|
||||
function change_iframe(seq,obj ){
|
||||
//0:项目选择
|
||||
//1:任务
|
||||
//2:分享
|
||||
//3:通知
|
||||
//4:修改个人信息
|
||||
//5:项目详情 edited by cy
|
||||
var src_array=["project_select","task","share","inform","alter_info","project_detail"];
|
||||
var src="pages/"+src_array[seq]+".html";
|
||||
if( seq==0 || seq==5 )
|
||||
if(seq == 5){
|
||||
$("#cy_close").click();
|
||||
}
|
||||
if( seq==0 ) //edited by cy
|
||||
window.location=src;
|
||||
else
|
||||
document.getElementById("main").src=src;
|
||||
|
@ -125,7 +129,8 @@
|
|||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
|
||||
<button type="button" id="cy_close" class="close" data-dismiss="modal" aria-hidden="true">
|
||||
<!-- edited by cy -->
|
||||
×
|
||||
</button>
|
||||
<h3 class="modal-title" id="myModalLabel">
|
||||
|
@ -164,6 +169,7 @@
|
|||
<script src="pages/include/main.js"></script>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
initCurrent();
|
||||
$.ajax({
|
||||
type: "get",
|
||||
dataType: "json",
|
||||
|
|
|
@ -1,7 +1,29 @@
|
|||
var LoginUserInfo={
|
||||
selectProject:-1,
|
||||
name:'',
|
||||
id:-1,
|
||||
email:'',
|
||||
phone:''
|
||||
function initCurrent(){
|
||||
if(getProjectId()==null){
|
||||
window.location="pages/project_select.html";
|
||||
}
|
||||
LoginUserInfo={
|
||||
selectProject:getProjectId(),
|
||||
name:'',
|
||||
id:-1,
|
||||
email:'',
|
||||
phone:''
|
||||
}
|
||||
}
|
||||
//获取url中的get参数列表
|
||||
function getGetArray(){
|
||||
var GetArrayString = window.location.search;
|
||||
var GetArrayStrings = GetArrayString.substr(1).split("&");
|
||||
var GetArray = new Array();
|
||||
for(var i = 0; i < GetArrayStrings.length; ++i){
|
||||
var optemp = GetArrayStrings[i].split("=");
|
||||
GetArray[optemp[0]]=optemp[1];
|
||||
}
|
||||
return GetArray;
|
||||
}
|
||||
|
||||
//获取当前项目的id值
|
||||
function getProjectId(){
|
||||
var g = getGetArray();
|
||||
return g["projectid"];
|
||||
}
|
|
@ -77,7 +77,7 @@
|
|||
</div>
|
||||
<!-- /.box-body -->
|
||||
<div class="box-footer">
|
||||
<button onclick="submit_query()" class="btn btn-primary pull-right">提交修改</button>
|
||||
<button onclick="cy_submit()" class="btn btn-primary pull-right">提交修改</button>
|
||||
</div>
|
||||
<!-- /.box-footer -->
|
||||
</div>
|
||||
|
@ -96,7 +96,7 @@
|
|||
<div class="box-body">
|
||||
<div class="row">
|
||||
<div class="col-lg-9 col-md-push-2">
|
||||
<table class="table" style="text-align:center">
|
||||
<table id="cy_user_lists" class="table" style="text-align:center">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="text-align:center">姓名</th>
|
||||
|
@ -120,10 +120,10 @@
|
|||
<!-- /.row -->
|
||||
<div class="form-group row has-feedback">
|
||||
<div class="col-sm-6 col-md-push-2">
|
||||
<input type="text" class="form-control" value="" id="address" name="address" placeholder="输入新成员邮箱">
|
||||
<input type="text" class="form-control" value="" id="cy_new_user" name="address" placeholder="输入新成员邮箱">
|
||||
</div>
|
||||
<div class="col-sm-2 col-md-push-2">
|
||||
<button class="btn btn-primary btn-success">添加成员</button>
|
||||
<button onclick="cy_addUser()" class="btn btn-primary btn-success">添加成员</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- ./form-group -->
|
||||
|
@ -153,7 +153,121 @@
|
|||
<script src="../dist/js/demo.js"></script>
|
||||
<!-- date select and query -->
|
||||
<!-- Custom Scripts -->
|
||||
<script src="include/main.js"></script>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$.ajax({
|
||||
type:"get",
|
||||
dataType:"json",
|
||||
url:"/projects.json",
|
||||
data:{
|
||||
"id":parent.LoginUserInfo.selectProject
|
||||
},
|
||||
statusCode: {
|
||||
200: function(rpstr) {// 请求成功
|
||||
var robj = eval('('+rpstr+')');
|
||||
if(robj["code"]=="0"){
|
||||
$("#name").val(robj["name"]);
|
||||
$("#address").val(robj["content"]);
|
||||
var users = robj["users"];
|
||||
for(var i = 0; i < users.length; ++i){
|
||||
var tduser = $("<td></td>").text(users[i]["nickname"]);
|
||||
var btn = $("<button></button>").text("删除");
|
||||
btn.attr("class","btn btn-primary btn-danger");
|
||||
btn.attr("onclick","cy_deleteUser("+users[i]['id']+")");
|
||||
var tdbtn = $("<td></td>").append(btn);
|
||||
$("#cy_user_lists").children("tbody").append($("<tr></tr>").append(tduser,tdbtn));
|
||||
}
|
||||
}
|
||||
else{
|
||||
//todo
|
||||
}
|
||||
},
|
||||
401:function(){// 未授权
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
function cy_addUser(){
|
||||
$.ajax({
|
||||
type:"post",
|
||||
dataType:"json",
|
||||
url:"/projects.json",
|
||||
data:{
|
||||
"user_id":$("#cy_new_user"),
|
||||
"project_id":parent.LoginUserInfo.selectProject
|
||||
},
|
||||
statusCode: {
|
||||
200: function(rpstr) {// 请求成功
|
||||
var robj = eval('('+rpstr+')');
|
||||
if(robj["code"]==0){
|
||||
window.location.reload();
|
||||
}
|
||||
else{
|
||||
//todo
|
||||
}
|
||||
},
|
||||
401:function(){// 未授权
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
function cy_deleteUser(id){
|
||||
return;
|
||||
$.ajax({
|
||||
type:"delete",
|
||||
dataType:"json",
|
||||
url:"/projects.json",
|
||||
data:{
|
||||
"project_id":parent.LoginUserInfo.selectProject,
|
||||
"user_id":id
|
||||
//todo (write todo for find, need to be edited)
|
||||
},
|
||||
statusCode: {
|
||||
200: function(rpstr) {// 请求成功
|
||||
var robj = eval('('+rpstr+')');
|
||||
if(robj["code"]==0){
|
||||
window.location.reload();
|
||||
}
|
||||
else{
|
||||
//todo
|
||||
}
|
||||
},
|
||||
401:function(){// 未授权
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
function cy_submit(){
|
||||
$.ajax({
|
||||
type:"patch",
|
||||
dataType:"json",
|
||||
url:"/projects.json",
|
||||
data:{
|
||||
"project_id":parent.LoginUserInfo.selectProject,
|
||||
"name":$("#name").val(),
|
||||
"content":$("#address").val()
|
||||
//todo (write todo for find, need to be edited)
|
||||
},
|
||||
statusCode: {
|
||||
200: function(rpstr) {// 请求成功
|
||||
var robj = eval('('+rpstr+')');
|
||||
if(robj["code"]==0){
|
||||
window.location.reload();
|
||||
}
|
||||
else{
|
||||
//todo
|
||||
}
|
||||
},
|
||||
401:function(){// 未授权
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -183,50 +183,50 @@
|
|||
dataType:"json",
|
||||
url:"/projects.json",
|
||||
statusCode: {
|
||||
200: function() {// 请求成功
|
||||
var bg_color = ["bg-yellow","bg-blue","bg-purple","bg-red"];
|
||||
var jstr = htmlobj.responseText;
|
||||
var robj = eval('('+jstr+')');
|
||||
console.log(jstr);
|
||||
if(robj["code"]==0){
|
||||
var data = robj["data"];
|
||||
for(var i=data.length-1;i>=0;--i){
|
||||
var template = $("#cy_template");
|
||||
var tp = template.clone("true");
|
||||
var id = data[i]["id"];
|
||||
tp.find("#cy_template_name").html(data[i]["name"]);
|
||||
tp.find("#cy_template_content").html(data[i]["content"]);
|
||||
tp.find("#cy_template_mission_count").html(data[i]["mission_count"]);
|
||||
tp.find("#cy_template_users_count").html(data[i]["users_count"]);
|
||||
tp.find("#cy_template_shares_count").html(data[i]["shares_count"]);
|
||||
tp.find("#cy_template_enterbtn").attr("onclick","cy_enter("+id+");");
|
||||
200: function() {// 请求成功
|
||||
var bg_color = ["bg-yellow","bg-blue","bg-purple","bg-red"];
|
||||
var jstr = htmlobj.responseText;
|
||||
var robj = eval('('+jstr+')');
|
||||
console.log(jstr);
|
||||
if(robj["code"]==0){
|
||||
var data = robj["data"];
|
||||
for(var i=data.length-1;i>=0;--i){
|
||||
var template = $("#cy_template");
|
||||
var tp = template.clone("true");
|
||||
var id = data[i]["id"];
|
||||
tp.find("#cy_template_name").html(data[i]["name"]);
|
||||
tp.find("#cy_template_content").html(data[i]["content"]);
|
||||
tp.find("#cy_template_mission_count").html(data[i]["mission_count"]);
|
||||
tp.find("#cy_template_users_count").html(data[i]["users_count"]);
|
||||
tp.find("#cy_template_shares_count").html(data[i]["shares_count"]);
|
||||
tp.find("#cy_template_enterbtn").attr("onclick","cy_enter("+id+");");
|
||||
|
||||
tp.find("#cy_template_name").attr("id","cy_name_"+id);
|
||||
tp.find("#cy_template_content").attr("id","cy_content_"+id);
|
||||
tp.find("#cy_template_mission_count").attr("id","cy_mission_count_"+id);
|
||||
tp.find("#cy_template_users_count").attr("id","cy_users_count_"+id);
|
||||
tp.find("#cy_template_shares_count").attr("id","cy_shares_count_"+id);
|
||||
tp.find("#cy_template_enterbtn").attr("id","cy_enter_"+id);
|
||||
tp.find("#cy_template_name").attr("id","cy_name_"+id);
|
||||
tp.find("#cy_template_content").attr("id","cy_content_"+id);
|
||||
tp.find("#cy_template_mission_count").attr("id","cy_mission_count_"+id);
|
||||
tp.find("#cy_template_users_count").attr("id","cy_users_count_"+id);
|
||||
tp.find("#cy_template_shares_count").attr("id","cy_shares_count_"+id);
|
||||
tp.find("#cy_template_enterbtn").attr("id","cy_enter_"+id);
|
||||
|
||||
tp.find("#cy_template_bg").attr("class","widget-user-header "+bg_color[Math.floor(Math.random()*4)]);
|
||||
tp.find("#cy_template_bg").attr("id","cy_bg_"+id);
|
||||
tp.find("#cy_template_bg").attr("class","widget-user-header "+bg_color[Math.floor(Math.random()*4)]);
|
||||
tp.find("#cy_template_bg").attr("id","cy_bg_"+id);
|
||||
|
||||
|
||||
tp.attr("id","cy_project_"+id);
|
||||
tp.attr("id","cy_project_"+id);
|
||||
|
||||
tp.css("display","block");
|
||||
tp.css("display","block");
|
||||
|
||||
$("#cy_container").prepend(tp);
|
||||
}
|
||||
}
|
||||
else{
|
||||
//todo
|
||||
}
|
||||
},
|
||||
401:function(){// 未授权
|
||||
alert("用户名或密码错误!");
|
||||
}
|
||||
$("#cy_container").prepend(tp);
|
||||
}
|
||||
}
|
||||
else{
|
||||
//todo
|
||||
}
|
||||
},
|
||||
401:function(){// 未授权
|
||||
alert("用户名或密码错误!");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
$("#creat_project").click(function(){
|
||||
|
@ -249,12 +249,12 @@
|
|||
}
|
||||
}
|
||||
});
|
||||
function cy_enter(id){
|
||||
LoginUserInfo.selectProject=id;
|
||||
console.log(id);
|
||||
//window.location.href="../index.html";
|
||||
}
|
||||
});
|
||||
|
||||
function cy_enter(id){
|
||||
console.log(id);
|
||||
window.location.href="../index.html?projectid="+id;
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
|
|
|
@ -528,7 +528,9 @@
|
|||
<script src="../dist/js/demo.js"></script>
|
||||
<!-- date select and query -->
|
||||
<!-- Custom Scripts -->
|
||||
<script src="include/main.js"></script>
|
||||
<script>
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -2,6 +2,77 @@ require 'rails_helper'
|
|||
|
||||
RSpec.describe MissionsController, type: :controller do
|
||||
|
||||
describe ""
|
||||
# describe "GET #getlist" do
|
||||
|
||||
# it "return a valid json format of missions" do
|
||||
|
||||
# register = create(:user)
|
||||
# user = User.find_by(email: register.email)
|
||||
# session[:user_id] = user.id
|
||||
|
||||
# user1 = create(:user)
|
||||
# user2 = create(:user)
|
||||
# params = {name: "project addUsers test",content: "addUsers test"}
|
||||
# project = Project.new(params)
|
||||
# project.users << register
|
||||
# project.save
|
||||
|
||||
# params_mission = {name: "mission1",content: "mission content",deadline:"2016-10-17 10:00:00",priority:1,status:1,project_id: project.id}
|
||||
# params_mission2 = {name: "mission2",content: "mission content2",deadline:"2016-10-17 10:00:00",priority:1,status:2,project_id: project.id}
|
||||
# mission = Mission.new(params_mission)
|
||||
# mission2 = Mission.new(params_mission2)
|
||||
# mission.save
|
||||
# mission2.save
|
||||
# get :getlist,project_id: project.id,status_type: 1
|
||||
|
||||
# puts response.body
|
||||
|
||||
|
||||
# end
|
||||
|
||||
# end
|
||||
|
||||
# describe "GET #detail" do
|
||||
|
||||
# it "return a correct json format detail" do
|
||||
|
||||
# register = create(:user)
|
||||
# params = {name: "project addUsers test",content: "addUsers test"}
|
||||
# project = Project.new(params)
|
||||
# project.users << register
|
||||
# project.save
|
||||
|
||||
# params_mission = {name: "mission1",content: "mission content",deadline:"2016-10-17 10:00:00",priority:1,status:1,project_id: project.id}
|
||||
# params_mission2 = {name: "mission2",content: "mission content2",deadline:"2016-10-17 10:00:00",priority:1,status:2,project_id: project.id}
|
||||
# mission = Mission.new(params_mission)
|
||||
# mission.save
|
||||
# get :detail,id: mission.id
|
||||
|
||||
# end
|
||||
|
||||
# end
|
||||
|
||||
describe "POST #comments" do
|
||||
|
||||
it "can publish comments successfully" do
|
||||
|
||||
|
||||
register = create(:user)
|
||||
params = {name: "project addUsers test",content: "addUsers test"}
|
||||
project = Project.new(params)
|
||||
project.users << register
|
||||
project.save
|
||||
|
||||
params_mission = {name: "mission1",content: "mission content",deadline:"2016-10-17 10:00:00",priority:1,status:1,project_id: project.id}
|
||||
params_mission2 = {name: "mission2",content: "mission content2",deadline:"2016-10-17 10:00:00",priority:1,status:2,project_id: project.id}
|
||||
mission = Mission.new(params_mission)
|
||||
mission.save
|
||||
|
||||
post :commentPublish,mission_id: mission.id,content: "用户评论"
|
||||
puts "hello world"
|
||||
puts response.body
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue