Skip to content
Snippets Groups Projects
Commit 4c70dcfa authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

Task #8574: split controller into two: for dataretreival and gridcontrol. Bind...

Task #8574: split controller into two: for dataretreival and gridcontrol. Bind them via service. Use in html.
parent fb7bf709
Branches
Tags
No related merge requests found
......@@ -4750,7 +4750,8 @@ SAS/ResourceAssignment/ResourceAssignmentEditor/lib/CMakeLists.txt -text
SAS/ResourceAssignment/ResourceAssignmentEditor/lib/__init__.py -text
SAS/ResourceAssignment/ResourceAssignmentEditor/lib/fakedata.py -text
SAS/ResourceAssignment/ResourceAssignmentEditor/lib/static/app/app.js -text
SAS/ResourceAssignment/ResourceAssignmentEditor/lib/static/app/controllers/controller.js -text
SAS/ResourceAssignment/ResourceAssignmentEditor/lib/static/app/controllers/datacontroller.js -text
SAS/ResourceAssignment/ResourceAssignmentEditor/lib/static/app/controllers/gridcontroller.js -text
SAS/ResourceAssignment/ResourceAssignmentEditor/lib/static/css/bootstrap.min.css -text
SAS/ResourceAssignment/ResourceAssignmentEditor/lib/static/css/main.css -text
SAS/ResourceAssignment/ResourceAssignmentEditor/lib/static/favicon.ico -text
......
......@@ -17,6 +17,14 @@ file(GLOB_RECURSE angular_moment_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} stat
file(GLOB_RECURSE moment_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} static/js/moment/*)
file(GLOB_RECURSE bootstrap_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} static/css/bootstrap.min.css)
set(app_files
static/favicon.ico
static/app/app.js
static/app/controllers/datacontroller.js
static/app/controllers/gridcontroller.js
static/css/main.css
templates/index.html)
set(web_files
${jquery_files}
${angular_files}
......@@ -27,11 +35,7 @@ set(web_files
${angular_moment_files}
${moment_files}
${bootstrap_files}
static/favicon.ico
static/app/app.js
static/app/controllers/controller.js
static/css/main.css
templates/index.html)
${app_files})
install(FILES ${web_files}
DESTINATION ${PYTHON_INSTALL_DIR}/resourceassignementeditor)
......
// $Id$
var app = angular.module('raeApp', ['ngTouch', 'ui.grid', 'gantt', 'gantt.table', 'gantt.movable', 'gantt.tooltips']);
var app = angular.module('raeApp',
['ngTouch',
'ui.grid',
'gantt',
'gantt.table',
'gantt.movable',
'gantt.tooltips',
'DataControllerMod',
'GridControllerMod']);
app.factory("dataService", function(){
var self = this;
self.tasks = [];
self.resources = [];
return self;
});
// $Id$
angular.module('raeApp').controller('DataController', ['$http', '$scope', function($http, $scope) {
var store = this;
this.tasks = [];
this.gtasks = [];
var dataControllerMod = angular.module('DataControllerMod', []);
dataControllerMod.controller('DataController', ['$http', '$scope', 'dataService', function($http, $scope, dataService) {
var self = this;
self.dataService = dataService;
function getTasks() {
$http.get('/rest/tasks').success(function(result) {
// for(var key in result.data) {
self.dataService.tasks = result.tasks;
});
};
function getResources() {
$http.get('/rest/resourceitems').success(function(result) {
// for(var key in result.resourceitems) {
// var elem = result.tasks[key];
// elem.from = new Date(elem.from);
// elem.to = new Date(elem.to);
// }
store.tasks = result.tasks;
store.gtasks = result.tasks;
self.dataService.resources = result.resourceitems;
});
};
getTasks();
getResources();
this.test = [
{name: 'row1', tasks: [
{name: 'task1', from: new Date(2013, 10, 26, 8, 0, 0), to: new Date(2013, 10, 26, 8, 0, 0)},
{name: 'task2', from: new Date(2013, 11, 26, 8, 0, 0), to: new Date(2013, 11, 26, 9, 0, 0)}
]
},
{name: 'row2', tasks: [
{name: 'task3', from: new Date(2013, 10, 26, 8, 0, 0), to: new Date(2013, 13, 26, 8, 0, 0)}
]
}];
}
]);
// $Id: controller.js 32761 2015-11-02 11:50:21Z schaap $
var gridControllerMod = angular.module('GridControllerMod', ['DataControllerMod']);
gridControllerMod.controller('GridController', ['$scope', 'dataService', function($scope, dataService) {
$scope.dataService = dataService;
$scope.$watch('dataService.tasks', function() {
if('tasks' in $scope.dataService && $scope.dataService.tasks.length > 0)
$scope.gridOptions.data = $scope.dataService.tasks[0]['tasks'];
else
$scope.gridOptions.data = []
}, true);
$scope.columns = [{ field: 'name' }, { field: 'from' }, { field: 'to' }];
$scope.gridOptions = {
enableSorting: true,
columnDefs: $scope.columns,
data: []
};
}
]);
......@@ -19,17 +19,20 @@
<script src="/static/js/angular-gantt/angular-gantt.js"></script>
<script src="/static/js/angular-gantt/angular-gantt-plugins.js"></script>
<script src="/static/app/app.js"></script>
<script src="/static/app/controllers/controller.js"></script>
<script src="/static/app/controllers/datacontroller.js"></script>
<script src="/static/app/controllers/gridcontroller.js"></script>
</head>
<body>
{% raw %}
<div ng-controller="DataController as dataCtrl">
<div ng-controller="GridController as gridCtrl">
<strong>Tasks:</strong>
<div id="grid1" ui-grid="{ data: dataCtrl.tasks }" ui-grid-move-columns class="grid"></div>
<div id="grid1" ui-grid="gridOptions" ui-grid-move-columns class="grid"></div>
</div>
<br/>
<br/>
<br/>
<div gantt "{ data= dataCtrl.gtasks }" style="min-height:300px">
<div ng-controller="DataController as dataCtrl">
<div gantt "{ data= dataCtrl.dataService.resources }" style="min-height:300px">
<gantt-table></gantt-table>
<gantt-movable></gantt-movable>
<gantt-tooltips></gantt-tooltips>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment