This commit is contained in:
2018-04-06 10:48:39 +02:00
parent 6f6cda4125
commit 49bd541cb8
10 changed files with 169 additions and 49 deletions
@@ -8,8 +8,8 @@
dbo.documentsDataService = {
getdocuments: function ( foreignID, tablename, callback ) {
$.getJSON( 'index.php/projects/documentsController/getDocuments/' + foreignID + '/' + tablename )
getdocuments: function ( foreignID, callback ) {
$.getJSON( 'index.php/projects/documentsController/getDocuments/' + foreignID )
.done( function ( data ) {
callback( data );
} );
+2 -2
View File
@@ -33,8 +33,8 @@ $( function () {
$('body').delay(500).fadeIn(1500);
} );
function uploadFile( file, foreignID, tablename, callback ) {
var url = 'index.php/utils/fileUpload/upload/' + foreignID + '/' + tablename;
function uploadFile( file, foreignID, callback ) {
var url = 'index.php/utils/fileUpload/upload/' + foreignID;
var xhr = new XMLHttpRequest();
var fd = new FormData();
xhr.open( "POST", url, true );
+70
View File
@@ -44,6 +44,8 @@ $( function () {
outstanding : ko.observable(),
toForecast : ko.observable(),
totalForecast : ko.observable(),
documents : ko.observableArray( [] ),
comments : ko.observableArray( [] ),
init: function () {
var vm = dbo.editProjectModal;
@@ -747,6 +749,8 @@ $( function () {
vm.reservations.push( new vm.Reservation( p ) );
} );
vm.refreshDocuments();
vm.busy = false;
dbo.charts.drawHoursVsBudget( 340, 230, 'hours-vs-budget' );
@@ -879,7 +883,73 @@ $( function () {
this.reservationamount = ko.observable( data.reservationamount );
this.payed = ko.observable( data.payed );
this.inEdit = ko.observable( data.inEdit || false );
},
addDocument: function ( data, evt ) {
var vm = dbo.editProjectModal;
uploadFile( evt.target.files[0], vm.projectID, function () {
vm.refreshDocuments();
} );
},
addComment: function () {
var vm = dbo.editProjectModal;
dbo.commentsDataService.addComment( vm.selectedRowID(), vm.tableName, function ( commentID ) {
dbo.commentModel.showComment( commentID, function () {
vm.refreshComments();
} )
} );
},
editComment: function () {
var vm = dbo.editProjectModal;
dbo.commentModel.showComment( this.id, function () {
vm.refreshComments();
} );
},
downloadDocument: function () {
window.open( 'index.php/projects/documentscontroller/downloaddocument/' + this.id );
},
refreshComments: function () {
var vm = dbo.editProjectModal;
dbo.commentsDataService.getComments( vm.selectedRowID(), vm.tableName, function ( data ) {
vm.comments.removeAll();
console.log( data );
$.each( data, function ( i, p ) {
vm.comments.push( new vm.Comment( p ) );
} );
} );
},
refreshDocuments: function () {
var vm = dbo.editProjectModal;
dbo.documentsDataService.getdocuments( vm.projectID, function ( data ) {
vm.documents.removeAll();
$.each( data, function ( i, p ) {
vm.documents.push( new vm.Document( p ) );
} )
} );
},
Comment: function ( data ) {
this.id = data.id;
this.comment_date = data.comment_date;
this.fullname = data.user.fullname;
this.comment = ko.observable( data.comment );
},
Document: function ( data ) {
this.id = data.id;
this.originalname = data.originalname;
this.uploaddate = data.uploaddate;
this.fullname = data.user.fullname;
}
};
dbo.editProjectModal.totalHours = ko.pureComputed( function () {
@@ -10,7 +10,6 @@ dbo.documentService = {
tableName: 'OFFER',
removeFile: function (that) {
var vm = dbo.offersService.vm;