offer fileupload and comments
This commit is contained in:
@@ -13,9 +13,13 @@ dbo.offersInit = function () {
|
||||
} else {
|
||||
dbo.offersModel = {
|
||||
|
||||
offers : ko.observableArray( [] ),
|
||||
offer : ko.observable(),
|
||||
archive: ko.observable( false ),
|
||||
tableName : 'OFFER',
|
||||
offers : ko.observableArray( [] ),
|
||||
offer : ko.observable(),
|
||||
archive : ko.observable( false ),
|
||||
comments : ko.observableArray( [] ),
|
||||
documents : ko.observableArray( [] ),
|
||||
selectedRowID: ko.observable(),
|
||||
|
||||
init: function () {
|
||||
var vm = dbo.offersModel;
|
||||
@@ -47,6 +51,43 @@ dbo.offersInit = function () {
|
||||
} );
|
||||
},
|
||||
|
||||
selectOffer: function () {
|
||||
var vm = dbo.offersModel;
|
||||
|
||||
vm.selectedRowID( this.id );
|
||||
|
||||
vm.refreshComments();
|
||||
|
||||
vm.refreshDocuments();
|
||||
},
|
||||
|
||||
addDocument: function ( data, evt ) {
|
||||
var vm = dbo.offersModel;
|
||||
uploadFile( evt.target.files[0], vm.selectedRowID(), vm.tableName, function () {
|
||||
vm.refreshDocuments();
|
||||
} );
|
||||
},
|
||||
|
||||
addComment: function () {
|
||||
var vm = dbo.offersModel;
|
||||
dbo.commentsDataService.addComment( vm.selectedRowID(), vm.tableName, function ( commentID ) {
|
||||
dbo.commentModel.showComment( commentID, function () {
|
||||
vm.refreshComments();
|
||||
} )
|
||||
} );
|
||||
},
|
||||
|
||||
editComment: function () {
|
||||
var vm = dbo.offersModel;
|
||||
dbo.commentModel.showComment( this.id, function () {
|
||||
vm.refreshComments();
|
||||
} );
|
||||
},
|
||||
|
||||
downloadDocument: function () {
|
||||
window.open( 'index.php/projects/documentscontroller/downloaddocument/' + this.id );
|
||||
},
|
||||
|
||||
archiveOffer: function () {
|
||||
var vm = dbo.offersModel;
|
||||
var self = this;
|
||||
@@ -93,6 +134,42 @@ dbo.offersInit = function () {
|
||||
} );
|
||||
},
|
||||
|
||||
removeFile: function () {
|
||||
var vm = dbo.offersModel;
|
||||
var self = this;
|
||||
|
||||
tellMe( {
|
||||
title : 'verwijderen document',
|
||||
message : 'weet u zeker dat u hjet document wilt verwijderen, dit kan niet ongedaan worden gemaakt',
|
||||
notify : true,
|
||||
noText : 'nee verwijder het document niet',
|
||||
yesText : 'ja verwijder het document',
|
||||
modalClass: 'modal-warning'
|
||||
}, function ( response ) {
|
||||
console.log( response );
|
||||
if ( response ) {
|
||||
dbo.documentsDataService.removeDocument( self.id, function ( data ) {
|
||||
if ( data.result ) {
|
||||
tellMe( {
|
||||
title : 'document verwijderd',
|
||||
message : 'het document is succesvol verwijderd',
|
||||
modalClass: 'modal-success'
|
||||
}, function () {
|
||||
vm.refreshDocuments();
|
||||
} );
|
||||
} else {
|
||||
tellMe( {
|
||||
title : 'fout bij verwijderen document',
|
||||
message : 'het document kan niet worden verwijderd',
|
||||
modalClass: 'modal-danger'
|
||||
} );
|
||||
}
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
||||
},
|
||||
|
||||
refreshOffers: function () {
|
||||
var vm = dbo.offersModel;
|
||||
|
||||
@@ -104,6 +181,30 @@ dbo.offersInit = function () {
|
||||
} );
|
||||
},
|
||||
|
||||
refreshComments: function () {
|
||||
var vm = dbo.offersModel;
|
||||
|
||||
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.offersModel;
|
||||
|
||||
dbo.documentsDataService.getdocuments( vm.selectedRowID(), vm.tableName, function ( data ) {
|
||||
vm.documents.removeAll();
|
||||
|
||||
$.each( data, function ( i, p ) {
|
||||
vm.documents.push( new vm.Document( p ) );
|
||||
} )
|
||||
} )
|
||||
},
|
||||
|
||||
Offer: function ( data ) {
|
||||
this.id = data.id;
|
||||
this.acceptance_chance = data.acceptance_chance;
|
||||
@@ -115,6 +216,20 @@ dbo.offersInit = function () {
|
||||
this.accepteddate = data.accepteddate ? dbo.helpers.mysql2date( data.accepteddate ) : null;
|
||||
this.acceptance_chance = data.acceptance_chance ? data.acceptance_chance : 0;
|
||||
this.archive = data.archive;
|
||||
},
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user