From 101e045ac1fe770d8e775180514353bea6f4fe81 Mon Sep 17 00:00:00 2001 From: Karl Cordes Date: Wed, 23 Mar 2011 16:01:09 +1100 Subject: [PATCH] Changed big job table --- controllers/jobs_controller.php | 2 +- views/jobs/index.ctp | 13 ++- webroot/css/quotenik.css | 7 ++ webroot/js/jobindex.js | 143 ++++++++++++++++++++++---------- 4 files changed, 120 insertions(+), 45 deletions(-) diff --git a/controllers/jobs_controller.php b/controllers/jobs_controller.php index 8337b12c..cba7d3f3 100755 --- a/controllers/jobs_controller.php +++ b/controllers/jobs_controller.php @@ -25,7 +25,7 @@ class JobsController extends AppController { function index_grid() { - + $this->layout = 'grid'; $jobs = $this->paginate(); $this->set('jobs', $jobs); diff --git a/views/jobs/index.ctp b/views/jobs/index.ctp index c6440aec..26b17499 100755 --- a/views/jobs/index.ctp +++ b/views/jobs/index.ctp @@ -137,11 +137,20 @@ echo $javascript->link('addjob'); - + + + - + diff --git a/webroot/css/quotenik.css b/webroot/css/quotenik.css index a143941b..3135733d 100755 --- a/webroot/css/quotenik.css +++ b/webroot/css/quotenik.css @@ -1264,4 +1264,11 @@ span.addLineItem { .viewLink { cursor: pointer; +} + + +#grid { + width: 100%; + height: 100%; + overflow: scroll; } \ No newline at end of file diff --git a/webroot/js/jobindex.js b/webroot/js/jobindex.js index d1e8887f..872dc622 100755 --- a/webroot/js/jobindex.js +++ b/webroot/js/jobindex.js @@ -1,51 +1,110 @@ -/* jobindex.js - * - * Implement Edit in Place - * - */ - - -$(function() { - - - -}); - -function doGet(link) { - - $.get("/jobs/edit/"+link, function(data){ - $("#editDiv").html(data); - }); - return; +function requiredFieldValidator(value) { + if (value == null || value == undefined || !value.length) + return { + valid:false, + msg:"This is a required field" + }; + else + return { + valid:true, + msg:null + }; } - - -function getParent(object) { - return object.parent('tr').attr('id') +var grid; +var data = []; +var columns = [ +{ + id:"title", + name:"Title", + field:"title", + width:120, + cssClass:"cell-title", + editor:TextCellEditor, + validator:requiredFieldValidator +}, +{ + id:"desc", + name:"Description", + field:"description", + width:100, + editor:LongTextCellEditor +}, +{ + id:"duration", + name:"Duration", + field:"duration", + editor:TextCellEditor +}, +{ + id:"%", + name:"% Complete", + field:"percentComplete", + width:80, + resizable:false, + formatter:GraphicalPercentCompleteCellFormatter, + editor:PercentCompleteCellEditor +}, +{ + id:"start", + name:"Start", + field:"start", + minWidth:60, + editor:DateCellEditor +}, +{ + id:"finish", + name:"Finish", + field:"finish", + minWidth:60, + editor:DateCellEditor +}, +{ + id:"effort-driven", + name:"Effort Driven", + width:80, + minWidth:20, + maxWidth:80, + cssClass:"cell-effort-driven", + field:"effortDriven", + formatter:BoolCellFormatter, + editor:YesNoCheckboxCellEditor } +]; +var options = { + editable: true, + enableAddRow: true, + enableCellNavigation: true, + asyncEditorLoading: false, + autoEdit: false +}; -/* - * - * $(".editWindow").click(function() { +$(function() +{ + for (var i=0; i<500; i++) { + var d = (data[i] = {}); + d["title"] = "Task " + i; + d["description"] = "This is a sample task description.\n It can be multiline"; + d["duration"] = "5 days"; + d["percentComplete"] = Math.round(Math.random() * 100); + d["start"] = "01/01/2009"; + d["finish"] = "01/05/2009"; + d["effortDriven"] = (i % 5 == 0); + } - //$(this).attr("name"); + grid = new Slick.Grid("#myGrid", data, columns, options); - doGet($(this).attr("name")); - $("#editDiv").dialog('open'); + //grid.registerPlugin(new Slick.CellRangeSelector()); - return false; + grid.setSelectionModel(new Slick.CellSelectionModel()); + + grid.onAddNewRow.subscribe(function(e, args) { + var item = args.item; + var column = args.column; + grid.invalidateRow(data.length); + data.push(item); + grid.updateRowCount(); + grid.render(); }); - - $("#editDiv").hide(); - - - - $("#editDiv").dialog({ - autoOpen: false, - width: 900, - modal: true - - }); - */ \ No newline at end of file +}); \ No newline at end of file