Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ bundle exec rake db:create # To create the database

bundle exec rake db:migrate # To run the migrations

bundle exec rake db:seed #to run the seed file.

bundle exec rails s # Start the rails server.


Open 'http://localhost:3000' in your browser.
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
//= require bootstrap-sprockets
//= require cocoon
//= require daily_log
//= require edit_log


122 changes: 70 additions & 52 deletions app/assets/javascripts/daily_log.js
Original file line number Diff line number Diff line change
@@ -1,58 +1,76 @@
function DailyLog() {
$(document).ready(function() {
var add_task = $(".add_field_button");
$(add_task).click(function(e){
$('.task').append("<br><input type='text' class='form-control' maxlength='300' name='projects[]LogText[]' placeholder=' enter LogEntry' required='required' ></input>")

function DailyLog() {
$(document).delegate('.add_field_button', 'click', function()
{
var project_id= $(this).parent().parent().children().eq(0).val();
$(this).parent().children().eq(1).append("<br><input type='text' class='form-control' maxlength='300' name='log_entry["+project_id+"][]' placeholder='enter LogEntry' required='required' ></input>");
});

var add_project = $(".add_project_button");
$(add_project).click(function(e){
$('.project').append("<hr><div class='form-group'><select class='added'></select> <br> <h3>Task</h3><input class='form-control' name='projects[]LogText[]' maxlength='300' placeholder='enter LogEntry' required='required' type='textarea'></div><div><button class='btn btn-default add_field_button'>add more</button></div>");
var attrid="projects[]";
$('.added').attr('name', attrid).append($('#projects_').html());
$(document).delegate('.add_project_button', 'click', function()
{
$('.project').append("<hr><div class='form-group'><select class='newproject added' required='required'></select> <br> <h5 class ='task'>Task</h3><div><input class='form-control' maxlength='300' placeholder='enter LogEntry' required='required' type='textarea'><div></div><br><button class='btn btn-default add_field_button'>Add Task</button></div>");
var attrid="projects[]";
$('.newproject').attr('name',attrid).append($('#projects_').html());
$('.newproject').removeClass('newproject');
});
$('input[name="daterange"]').daterangepicker();
});
$('input[name="daterange"]').on('apply.daterangepicker', function(ev, picker) {
var project_id= $("#projects_filter").val();
$('.user_summary').load('/daily_logs/user_logs',{ start_date: picker.startDate.format('YYYY-MM-DD'), end_date: picker.endDate.format('YYYY-MM-DD'),"project_id": project_id});
});
$('select').change(alert_me_test);
function alert_me_test(){
var project_id= $("#projects_filter").val();
$('.user_summary').load('/daily_logs/user_logs',{"project_id": project_id});
}
$('#context1 .menu .item')
.tab({
context: $('#context1')
})
;
var today = new Date();
$('#example1').calendar({
onChange: function (date, text) {
var newValue = text;
$('.dynamic').load('/daily_logs/refresh',{ "log_date":newValue});
},
type: 'date',
maxDate: new Date(today.getFullYear(), today.getMonth(), today.getDate())
})
$('.top.menu .item').tab({'onVisible':function(){
var newValue = $(this).attr("dataval")
$('.dynamic').load('/daily_logs/refresh',{ "log_date":newValue});
}});
$('.imageclass').on('click',function(){
var userid=$(this).attr("id");
$('.user_list').load('/daily_logs/user_logs',{"user_id":userid});
});


$(document).ready(function() {
$('input[name="daterange"]').daterangepicker();
});
$('input[name="daterange"]').on('apply.daterangepicker', function(ev, picker) {
var project_id= $("#projects_filter").val();
$('.user_summary').load('/daily_logs/user_logs',{ start_date: picker.startDate.format('YYYY-MM-DD'), end_date: picker.endDate.format('YYYY-MM-DD'),"project_id": project_id});
});
$('.projects_filter').change(alert_me_test);
function alert_me_test(){
var project_id= $("#projects_filter").val();
var datepicker = $('input[name="daterange"]').data('daterangepicker');
var today=moment().format('DD-MMM-YYYY');
if(datepicker.startDate.format('DD-MMM-YYYY')==today)
{
$('.user_summary').load('/daily_logs/user_logs',{"project_id": project_id});
}
else
{
$('.user_summary').load('/daily_logs/user_logs',{start_date:datepicker.startDate.format('YYYY-MM-DD'),end_date:datepicker.endDate.format('YYYY-MM-DD'),"project_id": project_id});
}
}
$('#context1 .menu .item')
.tab({
context: $('#context1')
})
;
var today = new Date();
$('#example1').calendar({
onChange: function (date, text) {
var newValue = text;
$('.dynamic').load('/daily_logs/refresh',{ "log_date":newValue});
},
type: 'date',
maxDate: new Date(today.getFullYear(), today.getMonth(), today.getDate())
})
$('.top.menu .item').tab({'onVisible':function(){
// TODO dont you need to put semi colon at EOL
var newValue = $(this).attr("dataval")
$('.dynamic').load('/daily_logs/refresh',{ "log_date":newValue});
}});
$('.imageclass').on('click',function(){
var userid=$(this).attr("id");
$('.user_list').load('/daily_logs/user_logs',{"user_id":userid});
});

$('.secondary.menu .item').tab({'onVisible':function(){
var x=$(this).attr('data-tab');
if(x=="first")
location.reload();
$('.secondary.menu .item').tab({'onVisible':function(){
// TODO use proper variable names
var x=$(this).attr('data-tab');
if(x=="first")
location.reload();

}}) ;
}}) ;
// $('.added').change(function() {
$(document).delegate('.added', 'change', function()
{
var project_id =$(this).val();
var name= 'log_entry['+project_id+'][]';
$(this).next().next().next().children().eq(1).children().filter('.form-control').attr('name',name);
$(this).next().next().next().children().filter('.form-control').attr('name',name);
});
};

35 changes: 35 additions & 0 deletions app/assets/javascripts/edit_log.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
function EditLog() {
$(document).delegate('.add_field_button', 'click', function()
{
var project_id= $(this).parent().parent().children().eq(0).children().val();
if(project_id=="")
{
var project_id= $(this).parent().parent().children().eq(0).children().attr("value");
}
$(this).parent().children().eq(0).append("<input type='text' class='form-control NewlyAdded' maxlength='300' name='new_log_entries["+project_id+"][]' placeholder='enter LogEntry' required='required' ></input><br>");
});
$(document).delegate('.added', 'change', function()
{
var project_id =$(this).val();
if(project_id=="")
{
project_id= $(this).attr("value");
}
var name= 'new_log_entries['+project_id+'][]';
$(this).parent().parent().children().eq(2).children().eq(0).children().filter('.NewlyAdded').attr('name',name);
$(this).parent().parent().children().eq(2).children().eq(0).children().filter('.existing').each(function(i){
var oldName= $(this).attr('name');
var newName='log_entries['+project_id+']'+oldName.substring(oldName.lastIndexOf('['));
$(this).attr('name',newName);
});
});
$(document).delegate('.add_project_button','click',function()
{
var value= $('#projects_').attr('value');
var attrid ="projects[]"
$('.project').append("<div><div><select class='newproject added' required='required' value ='"+value+"'></select></div><h5 class ='task'>Task</h5><div><div><input type='text' class ='form-control NewlyAdded' maxlength='300' placeholder='enterLogEntry' required='required'></input></br></div><button class ='btn btn-default add_field_button'>Add Task</button></div></div>");
$('.newproject').attr('name',attrid).append($('#projects_').html());
$('.newproject').removeClass('newproject')
});
};

Loading