|
|
@ -25,6 +25,7 @@ |
|
|
|
//
|
|
|
|
//
|
|
|
|
// See doc/COPYRIGHT.rdoc for more details.
|
|
|
|
// See doc/COPYRIGHT.rdoc for more details.
|
|
|
|
// ++
|
|
|
|
// ++
|
|
|
|
|
|
|
|
import {WorkPackageNotificationService} from 'core-components/wp-edit/wp-notification.service'; |
|
|
|
|
|
|
|
|
|
|
|
/*eslint no-eval: "error"*/ |
|
|
|
/*eslint no-eval: "error"*/ |
|
|
|
export class CostBudgetSubformController { |
|
|
|
export class CostBudgetSubformController { |
|
|
@ -44,7 +45,9 @@ export class CostBudgetSubformController { |
|
|
|
// Updater URL for the rows contained here
|
|
|
|
// Updater URL for the rows contained here
|
|
|
|
public updateUrl: string; |
|
|
|
public updateUrl: string; |
|
|
|
|
|
|
|
|
|
|
|
constructor(public $element, public $http, public wpNotificationsService) { |
|
|
|
constructor(public $element:ng.IAugmentedJQuery, |
|
|
|
|
|
|
|
public $http:ng.IHttpService, |
|
|
|
|
|
|
|
public wpNotificationsService:WorkPackageNotificationService) { |
|
|
|
this.container = $element.find('.budget-item-container'); |
|
|
|
this.container = $element.find('.budget-item-container'); |
|
|
|
this.rowIndex = parseInt(this.itemCount); |
|
|
|
this.rowIndex = parseInt(this.itemCount); |
|
|
|
|
|
|
|
|
|
|
@ -68,7 +71,7 @@ export class CostBudgetSubformController { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Refreshes the given row after updating values |
|
|
|
* Refreshes the given row after updating values |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public refreshRow(row_identifier) { |
|
|
|
public refreshRow(row_identifier:string) { |
|
|
|
var row = this.$element.find('#' + row_identifier); |
|
|
|
var row = this.$element.find('#' + row_identifier); |
|
|
|
var request = this.buildRefreshRequest(row, row_identifier); |
|
|
|
var request = this.buildRefreshRequest(row, row_identifier); |
|
|
|
|
|
|
|
|
|
|
@ -77,7 +80,7 @@ export class CostBudgetSubformController { |
|
|
|
method: 'POST', |
|
|
|
method: 'POST', |
|
|
|
data: request, |
|
|
|
data: request, |
|
|
|
headers: { 'Accept': 'application/javascript' } |
|
|
|
headers: { 'Accept': 'application/javascript' } |
|
|
|
}).then(response => { |
|
|
|
}).then((response:any) => { |
|
|
|
eval(response.data); |
|
|
|
eval(response.data); |
|
|
|
}).catch(response => { |
|
|
|
}).catch(response => { |
|
|
|
this.wpNotificationsService.handleErrorResponse(response); |
|
|
|
this.wpNotificationsService.handleErrorResponse(response); |
|
|
@ -103,14 +106,14 @@ export class CostBudgetSubformController { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns the params for the update request |
|
|
|
* Returns the params for the update request |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private buildRefreshRequest(row, row_identifier) { |
|
|
|
private buildRefreshRequest(row:JQuery, row_identifier:string) { |
|
|
|
var request = { |
|
|
|
var request:any = { |
|
|
|
element_id: row_identifier, |
|
|
|
element_id: row_identifier, |
|
|
|
fixed_date: angular.element('#cost_object_fixed_date').val() |
|
|
|
fixed_date: angular.element('#cost_object_fixed_date').val() |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// Augment common values with specific values for this type
|
|
|
|
// Augment common values with specific values for this type
|
|
|
|
row.find('.budget-item-value').each((_i, el) => { |
|
|
|
row.find('.budget-item-value').each((_i:number, el:HTMLElement) => { |
|
|
|
var field = angular.element(el); |
|
|
|
var field = angular.element(el); |
|
|
|
request[field.data('requestKey')] = field.val(); |
|
|
|
request[field.data('requestKey')] = field.val(); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -126,7 +129,10 @@ function costsBudgetSubform() { |
|
|
|
updateUrl: '@', |
|
|
|
updateUrl: '@', |
|
|
|
itemCount: '@' |
|
|
|
itemCount: '@' |
|
|
|
}, |
|
|
|
}, |
|
|
|
link: (scope, element, attr, ctrl) => { |
|
|
|
link: (scope:ng.IScope, |
|
|
|
|
|
|
|
element:ng.IAugmentedJQuery, |
|
|
|
|
|
|
|
attr:ng.IAttributes, |
|
|
|
|
|
|
|
ctrl:any) => { |
|
|
|
const template = element.find('.budget-row-template'); |
|
|
|
const template = element.find('.budget-row-template'); |
|
|
|
ctrl.rowTemplate = template[0].outerHTML; |
|
|
|
ctrl.rowTemplate = template[0].outerHTML; |
|
|
|
template.remove(); |
|
|
|
template.remove(); |
|
|
|